Custom Receipts .NET

After the transaction has been completed, you are required to provide a payment receipt to both the merchant and the shopper.

Sample Receipt

Actual receipt content varies depending on acquirer and payment method.

1 2 3 4 5


6 7 8

 

 

Required Receipt Information

All required data for the payment receipt is available right after the transaction is finished. You can also add this payment receipt data to your already existing checkout receipt. For accessing it, the transaction variable in the TransactionCompleted callback provides the following two properties:

transaction.MerchantReceipt
transaction.CustomerReceipt

You need to make sure, that your custom receipt contains all the required fields stated below and that you are able to also send receipts for successful refunds.

The receipt itself is constructed from multiple ReceiptLineItem items. Each item provides a Label that describes the entry itself, and a Value containing the actual data. When building the receipt on your end, do the following both for transaction.MerchantReceipt and transaction.CustomerReceipt:

  1. Add all the merchant information, such as address including country, by iterating over the MerchantDetails
  2. Specify the receipt type:MerchantReceipt or CustomerReceipt. For a receipt sent to the merchant, it must clearly state Merchant Receipt
  3. Provide the static elements that are available directly on the Receipt object. This includes the
    • Type
    • AmountAndCurrency
    • Subject
    • StatusText
    • Time and Date
  4. Add all payment related information by iterating over the PaymentDetails
  5. And finally add all information from processing the transaction by iterating over the ClearingDetails
  6. Check if you need to print a signature line on the merchant receipt via SignatureLineRequired

The receipts are already embedded in the transaction reference that you receive after a successful transaction. The transaction object provides access to the receipt for both, the merchant and the customer.

Receipts are only attached if the transaction did not fail, so always make sure to check the transaction and both receipt properties before accessing them.

The fields in the customer and merchant receipts can be accessed in the following way:

// Merchant Receipt
var receipt = transaction.MerchantReceipt;
Console.WriteLine("Merchant Receipt " + receipt.Type.Value);
// or Customer Receipt
// var receipt = transaction.CustomerReceipt;
// Console.WriteLine("Customer Receipt " + receipt.Type.Value));

Console.WriteLine("MERCHANT DETAILS:");
foreach (var merchantDetail in receipt.MerchantDetails)
{
    Console.WriteLine("\t " + merchantDetail.Label + ": " + merchantDetail.Value);
}

Console.WriteLine("Amount: " + receipt.AmountAndCurrency.Value);
Console.WriteLine("Time: " + receipt.Time.Value);
Console.WriteLine("Date: " + receipt.Date.Value);
Console.WriteLine("Subject: " + receipt.Subject.Value);
Console.WriteLine("Status: " + receipt.StatusText.Value);

// -- Optional
Console.WriteLine("Transaction identifier: " + receipt.Identifier.Value);
// --

Console.WriteLine("PAYMENT DETAILS:");
foreach (var paymentDetail in receipt.PaymentDetails)
{
    Console.WriteLine("\t " + paymentDetail.Label + ": " + paymentDetail.Value);
}

Console.WriteLine("CLEARING DETAILS:");
foreach (var clearingDetail in receipt.ClearingDetails)
{
    Console.WriteLine("\t " + clearingDetail.Label + ": " + clearingDetail.Value);
}

						
// Usually only on the Merchant Receipt
if(receipt.SignatureLineRequired)
{
	Console.WriteLine("Customer Signature: ________________________");
}