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.
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?
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'.