Showing results for 
Search instead for 
Did you mean: 

Refund payments using AIM API

I am having trouble Refunding a transcation using the AIM API. Here is my code so far using PHP:


$payment = new AuthnetAIM('blah', 'blahblah');
$payment->setTransactionType("CREDIT"); //This is for refunds only
$payment->setTransaction(XXXX1111, 1.00, "$transaction_id");
$payment->setParameter("x_email", $email);
$payment->setParameter("x_email_customer", TRUE); //Enable auto customer email
$payment->setParameter("x_description", "Refund");

 I keep getting an error message saying that the expiration date is required. Any thoughts? In the documentation it says that only the last 4 of the credit card used, amount, and transaction ID are required.


Did you test it with a hardcode $transaction_id, because it could think this is a unlinked credit which the expiration date is required.


could be this also


Thanks for your response. No matter if I send only 4 digits or XXXX and digits, it still does not work. Also, the transaction took place yesterday so it is "settled" and within the 120 day timeframe. Any other thoughts?

Maybe is not getting the transactionid is there a reason for the double quote? and could you echo params before sending to ?

I have done this with and without the double quotes but neither works. I have echoed out the variables and they contain the correct info. Is there a place with some sample code you know of?

try a simple browser url post, copy the link to a text file and change it with your info




If this is a Card Present account. replace x_trans_id with  x_ref_trans_id

Here is a new code I found:



        'refId' => rand(1000000, 100000000),
        'transactionRequest' => array(
            'transactionType' => 'refundTransaction',
            'amount' => 1.00,
            'payment' => array(
                'creditCard' => array(
                    'cardNumber' => 'XXXX1023',
                    'expirationDate' => '122016',
                    'refTransId' => '4926823799'
            'authCode' => '2165668159'

 But is is given me an error. It says: 


The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'refTransId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'cardCode' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.


So is this a Card Present or Card Not Present account?



said refTransID is after authCode node and not in the payment node