Как получить customerpaymentrofileId от существующего customerprofileid в authorize.net

Как получить customerpaymentrofileId от существующего customerprofileid в authorize.net Я новичок в autorize.net. Мне нужно получить customerpaymentrofileId клиента customerprofileid, так что я могу использовать их для взимания платы за транзакцию в Authorize.net.

$email="soumik@esolzmail.com";
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("1212121");
$merchantAuthentication->setTransactionKey("12121221");
$refId = 'ref' . time();

// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$paymentCreditCard = new AnetAPI\PaymentType();
$paymentCreditCard->setCreditCard($creditCard);

// Create the Bill To info
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName("Ellen");
$billto->setLastName("Johnson");
$billto->setCompany("Souveniropolis");
$billto->setAddress("14 Main Street");
$billto->setCity("Pecan Springs");
$billto->setState("TX");
$billto->setZip("44628");
$billto->setCountry("USA");

// Create a Customer Profile Request
//  1. create a Payment Profile
//  2. create a Customer Profile
//  3. Submit a CreateCustomerProfile Request
//  4. Validate Profiiel ID returned

$paymentprofile = new AnetAPI\CustomerPaymentProfileType();

$paymentprofile->setCustomerType('individual');
$paymentprofile->setBillTo($billto);
$paymentprofile->setPayment($paymentCreditCard);
$paymentprofiles[] = $paymentprofile;
$customerprofile = new AnetAPI\CustomerProfileType();
$customerprofile->setDescription("Customer 2 Test PHP 1");

//$customerprofile->setMerchantCustomerId("M_".time());
$customerprofile->setEmail($email."d");
$customerprofile->setPaymentProfiles($paymentprofiles);

$request = new AnetAPI\CreateCustomerProfileRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId( $refId);
$request->setProfile($customerprofile);
$controller = new AnetController\CreateCustomerProfileController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
{
echo "Succesfully create customer profile : " . $response->getCustomerProfileId() . "\n";
$paymentProfiles = $response->getCustomerPaymentProfileIdList();
echo "SUCCESS: PAYMENT PROFILE ID : " . $paymentProfiles[0] . "\n";
}
else
{
echo "ERROR :  Invalid response\n";
$errorMessages = $response->getMessages()->getMessage();
echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
}
//return $response;

echo "response=> <pre>"; print_r($response); echo "</pre>";

0

Решение

Вы можете использовать GetCustomerProfile запросить идентификатор профиля, чтобы получить список профилей оплаты, ответ будет содержать список профилей оплаты.

Для реализации php вы можете посмотреть этот пример кода PHP: https://github.com/AuthorizeNet/sample-code-php/blob/master/CustomerProfiles/get-customer-profile.php

1

Другие решения

Других решений пока нет …