Authorize.net email receipt api
Authorize.net's Email Receipt API is a feature that allows you to send a receipt to your customers via email after a successful transaction. Here's an overview of how to use it:
Prerequisites
- You need to have an Authorize.net account and be using their API to process transactions.
- You need to have the
Email Receipt
feature enabled in your Authorize.net account settings.
API Request
To send an email receipt, you'll need to make a POST request to the https://api.authorize.net/soap/v1/TransactionSearch
endpoint. The request should include the following parameters:
transactionId
: The ID of the transaction you want to send a receipt for.email
: The email address of the customer who made the transaction.receipt
: A string containing the receipt data, which should include the transaction details, such as the date, amount, and items purchased.
Here's an example of what the request might look like in XML:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/">
<soap:Body>
<TransactionSearchRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>YOUR_MERCHANT_ID</name>
<transactionKey>YOUR_TRANSACTION_KEY</transactionKey>
</merchantAuthentication>
<searchType>TransactionSearch</searchType>
<searchCriteria>
<name>transactionId</name>
<value>1234567890</value>
</searchCriteria>
<email>[email protected]</email>
<receipt>
<![CDATA[<receipt>
<date>2023-02-20</date>
<amount>19.99</amount>
<items>
<item>Item 1</item>
<item>Item 2</item>
</items>
</receipt>]]>
</receipt>
</TransactionSearchRequest>
</soap:Body>
</soap:Envelope>
Response
The API will respond with a TransactionSearchResponse
object, which will include a transactionId
and a receipt
element. The receipt
element will contain the receipt data in the same format as the request.
Here's an example of what the response might look like:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/">
<soap:Body>
<TransactionSearchResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<transactionId>1234567890</transactionId>
<receipt>
<![CDATA[<receipt>
<date>2023-02-20</date>
<amount>19.99</amount>
<items>
<item>Item 1</item>
<item>Item 2</item>
</items>
</receipt>]]>
</receipt>
</TransactionSearchResponse>
</soap:Body>
</soap:Envelope>
Tips and Considerations
- Make sure to replace
YOUR_MERCHANT_ID
andYOUR_TRANSACTION_KEY
with your actual Authorize.net merchant ID and transaction key. - The
receipt
element should contain the transaction details in a format that is easily readable by your customers. - You can customize the receipt template to include additional information, such as a logo or a message.
- The Email Receipt API is only available for transactions that are processed using the Authorize.net API.
- You should test the API in a development environment before deploying it to production.