0
authorize.netの既存のcustomerprofileidからcustomerpaymentrofileIdを取得する方法autorize.netの初心者です。私は顧客のcustomerprofileidのcustomerpaymentrofileIdを取得する必要があります。私はAuthorize.netでトランザクションを請求するためにそれらを使用することができます。authorize.netの既存のcustomerprofileidからcustomerpaymentrofileIdを取得する方法
$email="[email protected]";
// 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>";