Generate a Receipt
URL Endpoint: https://easypay5.com/APIcardProcREST/v1.0.0/Intl/ReceiptGenerate
Request Method: POST
Headers:
Session Key is passed to the API via the header:
Content-Type: application/json
Accept: application/json
SessKey: A1842D663E9A4A72XXXXXXXX303541303234373138
REFID will be the transaction ID
ReceiptType will always be 23 for International
Merchant copy use Recipient = 1
Customer Copy use Recipient = 2
For Dual Receipt use Recipient = 3
Consuming the Response
The member named ReceiptHtml holds the receipt data
Important you must replace all Unicode characters to consume clean HTML
Example : CleanHtml = Regex.Replace(my, @"[^\u0000-\u007F]+", string.Empty);
Copied
{
"REFID": "5eef4782-5be1-11ef-bbc1-46647bd59a7a",
"ReceiptType": 23,
"Recipient": 1
}
{
"Intl_ReceiptGenerateResult": {
"ErrCode": 0,
"ErrMsg": "",
"FunctionOk": true,
"ReceiptHtml": "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head runat=\"server\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /> <title></title></head><body> <form id=\"form1\" runat=\"server\"><div style=\" font-size:12px;font-family:Verdana\" align=\"center\"><h3>SALE RECEIPT</h3><br /><div><label>TEST MERCHANT TWO</label><br /><label>222 RAND ROAD</label><br /><label>LONDON, AK 54321</label><br /><label>(555) 555-5555</label></div><br /> <br /><table style=\"text-align:left\"><tr><td>CARDHOLDER NAME:</td><td><label>Smith, Nancy</label></td></tr><tr><td>ACCT NUMBER:</td><td><label>x1111</label></td></tr><tr><td>EXP DATE:</td><td><label>xxxx</label></td></tr><tr><td>TX ID:</td><td><label>5eef4782-5be1-11ef-bbc1-46647bd59a7a</label></td></tr><tr><td><label>PATIENT</label> REF ID:</td><td><label>N/A</label></td></tr><tr><td>TX DATE:</td><td><label>8/16/2024 11:08:23 AM</label></td></tr><tr><td>CARD TYPE:</td><td><label>VI</label></td></tr><tr><td>ENTRY METHOD:</td><td><label>Manual Entry</label></td></tr><tr><td>AMOUNT:</td><td><asp:label runat=\"server\">£8.14 GBR</asp:label></td></tr><tr><td></td><td><asp:label runat=\"server\"></asp:label></td></tr><tr><td>TOTAL(GBP):</td><td><label>£8.14 GBR</label></td></tr></table><br /><div><label>THANK YOU FOR YOUR PATRONAGE</label><br /><label>All Sales Final</label><br /><div><label>I agree to pay TEST MERCHANT TWO the above amount according to card issuer agreement.</label></div><br /><br /><div><label>SIGNATURE</label></div><br /><div>___________________________________</div><h3><b>MERCHANT COPY</b></h3></div></div></form></body></html>",
"RespMsg": "Successfully Returned Transaction Receipt Markup"
}
}
Copied
public async Task<string> GenerateReceipt(HttpClient client) {
// The IntlReceiptGenerateResult class matches the data in the Sample Response tab
IntlReceiptGenerateResult receipt = new IntlReceiptGenerateResult();
var request = new HttpRequestMessage(HttpMethod.Post, "https://easypay5.com/APIcardProcREST/v1.0.0/Intl/ReceiptGenerate");
request.Headers.Add("SessKey", "48872E0041F24449B930333030314130333999999xxx");
ReceiptRequest receiptToGenerate = new ReceiptRequest();
receiptToGenerate.ReceiptType = 23; // international receipt type
receiptToGenerate.Recipient = 1; // Merchant copy
receiptToGenerate.REFID = "3d7b3e84-7451-11ef-9a8c-9683a7fc3633"; // transaction id
// Serialize class into JSON
var payload = JsonSerializer.Serialize(receiptToGenerate);
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
try {
var response = await client.SendAsync(request);
if (response.StatusCode == HttpStatusCode.OK) {
var responseJson = await response.Content.ReadAsStringAsync();
var receiptRoot = JsonSerializer.Deserialize<Root>(responseJson);
receipt = receiptRoot.Intl_ReceiptGenerateResult;
// important values to check
if (receipt.FunctionOk != true) {
string errMsg = receipt.ErrMsg;
int errorCode = receipt.ErrCode;
string addlInfo = receipt.RespMsg;
// log error condition to your system
}
}
return receipt.ReceiptHtml;
}
catch (Exception ex) {
// log any errors
receipt.ErrMsg = ex.Message;
receipt.FunctionOk = false;
return receipt.ErrMsg;
}
}
}