首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Authorize.Net中使用CIM获取客户信息?

如何在Authorize.Net中使用CIM获取客户信息?
EN

Stack Overflow用户
提问于 2013-09-13 12:57:24
回答 2查看 2.3K关注 0票数 1

我正在工作的CIM (客户信息经理),我已经创建了客户档案使用CIM功能。但是我希望使用客户id而不是客户配置文件id来获取客户配置文件。

代码语言:javascript
复制
 $cim = new AuthnetCIM('***MASKED***', '***MASKED***', AuthnetCIM::USE_DEVELOPMENT_SERVER);
 $cim->setParameter('email', 'fakeemail@example.com');
 $cim->setParameter('description', 'Profile for Joe Smith'); // Optional
 $cim->setParameter('merchantCustomerId', '7789812');

 //create profile function 
 $ss=$cim->createCustomerProfile();

 //and get profile by..
 $profile_id = $cim->getProfileID();
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-13 12:59:23

您不能。您只能使用配置文件ID获取配置文件。这意味着您希望将该ID存储在数据库中,并将其与客户的记录相关联,因此,每当您需要获取他们的配置文件时,您都知道他们的配置文件ID是什么。

票数 3
EN

Stack Overflow用户

发布于 2015-04-10 20:34:17

实际上,如果您必须的话,这是可能的,但是如果可能的话,我仍然建议存储它,但是这个替代方案可能会有帮助。

Authorize.Net通过组合键(Merchant、Email和Description)定义了唯一的客户配置文件,因此必须确保这是唯一的。CreateCustomerProfile(.)如果再次尝试创建相同的复合键,API方法将强制执行唯一性,并返回一个错误。但是,此响应中的消息将包含冲突的客户配置文件id,而且由于复合键是唯一的,并且Authorize.Net强制此复合键的唯一性,所以这必须是客户的Authorize.Net客户配置文件id。

C#中的代码示例

代码语言:javascript
复制
    private long customerProfileId = 0;

    var customerProfile = new AuthorizeNet.CustomerProfileType()
        { 
            merchantCustomerId = "123456789",  
            email = "user@domain.com",
            description = "John Smith",
        };

    var cpResponse = authorize.CreateCustomerProfile(merchantAuthentication, customerProfile, ValidationModeEnum.none);
    if (cpResponse.resultCode == MessageTypeEnum.Ok)
    {
        customerProfileId = cpResponse.customerProfileId;
    }
    else
    {
        var regex = new Regex("^A duplicate record with ID (?<profileId>[0-9]+) already exists.$", RegexOptions.ExplicitCapture);
        Match match = regex.Match(cpResponse.messages[0].text);
        if (match.Success)
            customerProfileId = long.Parse(match.Groups["profileId"].Value);
        else
            //Raise error.
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18786903

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档