【问题标题】:How to get customer profile using CIM in Authorize.Net?如何在 Authorize.Net 中使用 CIM 获取客户资料?
【发布时间】:2013-09-18 04:13:33
【问题描述】:

我在 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();

【问题讨论】:

    标签: php payment-gateway payment authorize.net authorize.net-cim


    【解决方案1】:

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

    【讨论】:

    • 好的,我能理解。您能否提供一种使用个人资料 ID 而非所有个人资料获取个人资料的方法。
    【解决方案2】:

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

    Authorize.Net 通过复合键(商家客户 ID、电子邮件和描述)定义唯一的客户资料,因此您必须确保这是唯一的。如果您尝试再次创建相同的复合键,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.
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-17
      • 2012-01-04
      • 2012-11-13
      • 1970-01-01
      • 2012-02-11
      • 2016-01-05
      • 2015-01-16
      • 2012-10-30
      相关资源
      最近更新 更多