1

我在 CIM(客户信息管理器)工作,我已经使用 CIM 功能创建了客户资料。但我想使用客户 ID 而不是客户资料 ID 获取客户资料。

 $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();
4

2 回答 2

3

你不能。您只能使用配置文件 ID 获取配置文件。这意味着您需要将该 ID 存储在您的数据库中并将其与客户的记录相关联,以便在您需要获取他们的个人资料时知道他们的个人资料 ID 是什么。

于 2013-09-13T12:59:23.663 回答
0

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

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

C# 中的代码示例

    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.
    }
于 2015-04-10T20:34:17.760 回答