Hi. I am new to the AIM API. I currently have ARB (assuming AIM works with ARB) and I am trying to figure out how to submit a refund transaction. I read AIM documentation and also the Guide to Issuing Credit but found no complete example of how to do it. I have come up with this....can someone tell me if this will work? I would like to know if I am on the right track before testing it:
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$xml .= "<createTransactionRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
$xml .= "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">\n";
$xml .= " <merchantAuthentication>\n";
$xml .= " <name>".$loginname."</name>\n";
$xml .= " <transactionKey>".$transactionkey."</transactionKey>\n";
$xml .= " </merchantAuthentication>\n";
$xml .= " <refId>".$orderid."</refId>\n";
$xml .= "<transactionRequest>\n";
$xml .= "<transactionType>refundTransaction</transactionType>\n";
$xml .= "<refTransId>transaction ID here</refTransId>\n";
$xml .= "<cardNumber>.$_SESSION[payment].</cardNumber>\n";
$xml .= "</transactionRequest>\n";
$xml .= "</createTransactionRequest>";
Appreciate your help. Thanks!
12-03-2011 06:52 AM
also, do I need to specify the amount of refund or does the transaction ID take care of that?
12-03-2011 06:54 AM
You do need to specify the amount as partial refunds are allowed so you need to make sure the request is not ambiguous.
Your XML looks to be correct so go ahead and test it. If it isn't correct for some reason that's the best way to find out as you will get a spcecific error message in the response.
12-03-2011 07:27 AM - edited 12-03-2011 07:29 AM
great - thanks for your help. I will give it a test.
12-03-2011 09:42 AM
FYI, I know the code examples don't explain this technique, but it's really bad coding to print one line at a time. You're much better off using a block:
<?php $xml = <<<BLOCK <?xml version="1.0" encoding="utf-8"?> <createTransactionRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>$loginname</name> <transactionKey>$transactionkey</transactionKey> </merchantAuthentication> <refId>$orderid</refId> <transactionRequest> <transactionType>refundTransaction</transactionType> <refTransId>transaction ID here</refTransId> <cardNumber>{$_SESSION['payment']}</cardNumber> </transactionRequest> </createTransactionRequest> BLOCK; ?>
Also, how did card number (even the last 4 digits) get into $_SESSION? It's bad from a security perspective to save that data from page to page.
I don't believe you have to specify a refund amount if it's equal to the original charge, which will be almost all refunds.
12-03-2011 10:05 AM