01-29-2013 05:28 PM
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:45 PM - edited 01-29-2013 05:48 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:53 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 06:06 PM - edited 01-29-2013 06:08 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:22 PM - edited 01-29-2013 06:24 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:35 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-30-2013 04:18 AM
So is this a Card Present or Card Not Present account?
said refTransID is after authCode node and not in the payment node