Hello all!
I'm trying to submit a refund using customerProfileId and customerPaymentProfileId per this documentation:
You can also issue an unlinked refund for a customer profile transaction. In this case, the following rules apply:
Note: A refund transaction will not appear in the history of the payment profile unless you generate the refund with the payment profile.
but I can't find any php source code reference to complete this transaction and I've been unsuccessful at getting anything other than this:
Transaction Failed
Error code : 33
Error message : Credit card number is required.
This is a snippet of the code I'm using so far:
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("0015");
$creditCard->setExpirationDate("XXXX");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
//create a transaction
//testing purposes only
$customerProfileId = "XXXXXXXXXX"; // X's have replaced actual values for display here.
$customerPaymentProfileId = "XXXXXXXXXX"; // X's have replaced actual values for display here.
//end test credentials
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType( "refundTransaction");
$transactionRequest->setAmount($amount);
//$transactionRequest->setPayment($paymentOne);
//$transactionRequest->setRefTransId($refTransId);
$transactionRequest->customerProfileId = $customerProfileId;
$transactionRequest->customerPaymentProfileId = $customerPaymentProfileId;
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest( $transactionRequest);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
Thank you for any assistance in this matter,
Robert
Solved! Go to Solution.
07-28-2018 09:40 AM
Nevermind... figured it out. I needed to access the profile information in a different way.
// set payment profile for customer
$paymentProfile = new AnetAPI\PaymentProfileType();
$paymentProfile->setpaymentProfileId( $customerPaymentProfileId );
// set customer profile
$customerProfile = new AnetAPI\CustomerProfilePaymentType();
$customerProfile->setCustomerProfileId( $customerProfileId );
$customerProfile->setPaymentProfile( $paymentProfile );
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType( "refundTransaction");
$transactionRequest->setAmount( $amount );
$transactionRequest->setProfile( $customerProfile );
07-28-2018 10:13 AM
Nevermind... figured it out. I needed to access the profile information in a different way.
// set payment profile for customer
$paymentProfile = new AnetAPI\PaymentProfileType();
$paymentProfile->setpaymentProfileId( $customerPaymentProfileId );
// set customer profile
$customerProfile = new AnetAPI\CustomerProfilePaymentType();
$customerProfile->setCustomerProfileId( $customerProfileId );
$customerProfile->setPaymentProfile( $paymentProfile );
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType( "refundTransaction");
$transactionRequest->setAmount( $amount );
$transactionRequest->setProfile( $customerProfile );
07-28-2018 10:13 AM