cancel
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 Authorize.net auto customer email
$payment->setParameter("x_description", "Refund");
$payment->process();

 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.

three3
Contributor
7 REPLIES 7

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

http://community.developer.authorize.net/t5/Integration-and-Testing/AIM-Refund-Issue/m-p/13022/highl...

RaynorC1emen7
Expert

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 authorize.net ?

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

 

link

 

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

Here is a new code I found:

 

require('../../config.inc.php');
    require('../../AuthnetXML.class.php');

    $xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY);
    $xml->createTransactionRequest(array(
        '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?

 

Schema

https://api.authorize.net/xml/v1/schema/AnetApiSchema.xsd

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