我正在设置一个symfony2 Web应用程序,以便在创建用户时,该应用程序应该在authorize.net的客户信息管理(CIM)上创建一个配置文件。
我在参数.yml中设置了凭据:
authorizenet_login_id: MY_ACTUAL_LOGIN_ID
authorizenet_tran_key: MY_ACTUAL_KEY
authorizenet_test_mode: true
这是我要求 CIM 的地方:
public function createUserPaymentProfile(Entity'User $user, $andFlush = true)
{
$paymentProfile = $this->getAuthorizeNetPaymentProfile(
$user->getOriginalCardNumber(),
$user->getExpirationDate()
);
$customerProfile = new 'AuthorizeNetCustomer;
$customerProfile->merchantCustomerId = $user->getId();
$customerProfile->email = $user->getEmail();
$customerProfile->paymentProfiles[] = $paymentProfile;
$response = $this->authorizeNetCIM->createCustomerProfile($customerProfile);
if ($response->isOk()) {
$customerProfileId = $response->getCustomerProfileId();
$user->setAuthorizeNetCustomerProfileId($customerProfileId);
$customerPaymentProfileIds = $response->getCustomerPaymentProfileIds();
$customerPaymentProfileId = is_array($customerPaymentProfileIds)
? $customerPaymentProfileIds[0]
: $customerPaymentProfileIds;
$user->setAuthorizeNetCustomerPaymentProfileId($customerPaymentProfileId);
$this->em->persist($user);
if ($andFlush) {
$this->em->flush();
}
}
return $response;
}
但是,我在以下行中没有得到任何回复:
$response = $this->authorizeNetCIM->createCustomerProfile($customerProfile);
这是响应的var_dump:
object(AuthorizeNetCIM_Response)#899 (2) { ["xml"]=> NULL ["response"]=> bool(false) }
更新:我调试了 curl 调用,这是我从 curl 响应中收到的错误消息:SSL:证书验证失败(结果:5)
SDK 中的 cert.pem 文件可能已过期。这篇文章有一个描述为我解决了这个问题:
https://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Authorize-Net-Begins-Infrastructure-and-SHA-2-Certificate/bc-p/50166#M445
只需将 SDK 中 authnet/lib/ssl 目录中的 cert.pem 文件替换为以下位置的新文件:http://curl.haxx.se/ca/cacert.pem
上面的 authorize.net 链接也提到了这个SO问题:cURL需要CURLOPT_SSL_VERIFYPEER=FALSE