cancel
Showing results for 
Search instead for 
Did you mean: 

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=\"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!

webdesignz
Member
4 REPLIES 4

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

webdesignz
Member

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
stymiee
Expert
Expert

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

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.