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.
01-29-2013 05:28 PM
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
01-29-2013 05:45 PM - edited 01-29-2013 05:48 PM
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?
01-29-2013 05:53 PM
Maybe is not getting the transactionid is there a reason for the double quote? and could you echo params before sending to authorize.net ?
01-29-2013 06:02 PM
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?
01-29-2013 06:06 PM - edited 01-29-2013 06:08 PM
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
01-29-2013 06:22 PM - edited 01-29-2013 06:24 PM
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'.
01-29-2013 06:35 PM
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
01-30-2013 04:18 AM