Posts: 3
Registered: ‎12-03-2011

AIM Credit Card refund

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=\"\"\n";
 $xml .= "xmlns:xsd=\"\" 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!

Posts: 3
Registered: ‎12-03-2011

Re: AIM Credit Card refund

also, do I need to specify the amount of refund or does the transaction ID take care of that?

Posts: 1,476
Topics: 33
Kudos: 33
Solutions: 126
Registered: ‎09-14-2009

Re: AIM Credit Card refund

[ Edited ]

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.

John Conde :: Certified Authorize.Net Developer (Brainyminds) :: Official Authorize.Net Blogger

NEW! Handling Authorize.Net's Webhooks with PHP

Integrate Every Authorize.Net JSON API with One PHP Class (Sample code included)

Tutorials for integrating Authorize.Net with PHP: AIM, ARB, CIM, Silent Post
All About Authorize.Net's Silent Post
Posts: 3
Registered: ‎12-03-2011

Re: AIM Credit Card refund

great - thanks for your help.  I will give it a test.

Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: AIM Credit Card refund

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:


$xml = <<<BLOCK
<?xml version="1.0" encoding="utf-8"?>
<createTransactionRequest xmlns:xsi="" xmlns:xsd="" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<refTransId>transaction ID here</refTransId>

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.