cancel
Showing results for 
Search instead for 
Did you mean: 

Can't process refund using CIM in PHP

I'm trying to build a tool to process refunds in PHP using anet_php_sdk-1_8_5_1. 

 

Here is my code to process the refund:

 

 

$refund = new AuthorizeNetCIM;
$transaction = new AuthorizeNetTransaction;
$transaction->amount = $authAmount;
$transaction->customerProfileId = $customerProfileId;
$transaction->customerPaymentProfileId = $paymentProfileId;
$transaction->transId = $transactionid;
$response = $refund->createCustomerProfileTransaction("Refund", $transaction);
$transactionResponse = $response->getTransactionResponse();
echo json_encode($transactionResponse) . "<br>";

 

 

The response I get from the server is:

 

{"approved":false,"declined":null,"error":true,"held":null,"response_code":null,"response_subcode":null,"response_reason_code":null,"response_reason_text":null,"authorization_code":null,"avs_response":null,"transaction_id":null,"invoice_number":null,"description":null,"amount":null,"method":null,"transaction_type":null,"customer_id":null,"first_name":null,"last_name":null,"company":null,"address":null,"city":null,"state":null,"zip_code":null,"country":null,"phone":null,"fax":null,"email_address":null,"ship_to_first_name":null,"ship_to_last_name":null,"ship_to_company":null,"ship_to_address":null,"ship_to_city":null,"ship_to_state":null,"ship_to_zip_code":null,"ship_to_country":null,"tax":null,"duty":null,"freight":null,"tax_exempt":null,"purchase_order_number":null,"md5_hash":null,"card_code_response":null,"cavv_response":null,"account_number":null,"card_type":null,"split_tender_id":null,"requested_amount":null,"balance_on_card":null,"response":null,"error_message":"Error connecting to AuthorizeNet"}

 

I had no trouble executing a getTransactionDetails request using the same credentials. Why would it not be able to connect now using the createCustomerProfileTransaction?

ericrmr
Member
3 REPLIES 3

In addition, I was able to void a transaction just fine, using similar code:

 

$void = new AuthorizeNetCIM;
$transaction = new AuthorizeNetTransaction;
$transaction->transId = $transactionid;
$response = $void->createCustomerProfileTransaction("Void", $transaction);
$transactionResponse = $response->getTransactionResponse();

 

This worked perfectly. It's only the "Refund" transaction that didn't work.

ericrmr
Member

Hello @ericrmr

 

Can you try Refund a Transaction using the transaction ID instead of the payment profile?

 

Richard

The problem is I don't have the CC # or expiration date. That's tied to the payment profile. In our database we store the transaction ID, customer profile ID, and payment profile ID.

 

I can query the amount from the transaction details, but if I try to query the customer profile, I just get a bunch of X's for the CC # and expiration date.