我正在工作的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();发布于 2013-09-13 12:59:23
您不能。您只能使用配置文件ID获取配置文件。这意味着您希望将该ID存储在数据库中,并将其与客户的记录相关联,因此,每当您需要获取他们的配置文件时,您都知道他们的配置文件ID是什么。
发布于 2015-04-10 20:34:17
实际上,如果您必须的话,这是可能的,但是如果可能的话,我仍然建议存储它,但是这个替代方案可能会有帮助。
Authorize.Net通过组合键(Merchant、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.
}https://stackoverflow.com/questions/18786903
复制相似问题