Reply
Highlighted
Contributor
Posts: 17
Registered: ‎05-29-2018
Accepted Solution

How to submit refund using customerProfileId and customerPaymentPaymentProfileId?

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:

  • You must be enrolled in Expanded Credit Capabilities (ECC). For more information about ECC, go to http://www.authorize.net/content/dam/authorize/documents/ecc.pdf.
  • You must include customerProfileId and customerPaymentProfileId.
  • customerShippingAddressId is optional.
  • Do not include transId, creditCardNumberMasked, bankRoutingNumberMasked, or bankAccountNumberMasked.

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


Accepted Solutions
Highlighted
Solution
Accepted by topic author SilkySully
‎07-28-2018 10:14 AM
Contributor
Posts: 17
Registered: ‎05-29-2018

Re: How to submit refund using customerProfileId and customerPaymentPaymentProfileId?

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 );

 

View solution in original post


All Replies
Highlighted
Solution
Accepted by topic author SilkySully
‎07-28-2018 10:14 AM
Contributor
Posts: 17
Registered: ‎05-29-2018

Re: How to submit refund using customerProfileId and customerPaymentPaymentProfileId?

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 );