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:


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
	Console.WriteLine("Customer Signature: ________________________");

Pre-formatted Receipt

Starting from PayServer and PayClient version 1.28, you have access to pre-formatted receipts. These receipts can be printed right away without any necessity for further formatting. The pre-formatted receipts are flexible to be adjusted according to your printer's character limit for each line.

Setting Pre-formatted Receipts Line Limit

In order to define the maximum characters of each line of pre-formatted receipts, add the following setting to your PayServer config.yaml file:

     max_line_length: 40 # optional; will default to some predefined value if omitted

Please note that 40 is just an example value. The actual value depends on your printer's limit that it can print on its paper. Longer lines will be wrapped to their respective next lines in the returned output.

Retrieving Pre-formatted Receipts

Once you have defined the maximum line length of your pre-formatted receipts, you can simply print them for both customer receipt and merchant receipt. To retrieve the lines, there is an element called lines whose data type is an array of strings at the top level of both CustomerReceipt and MerchantReceipt.

foreach (var line in transaction.CustomerReceipt.Lines) {

foreach (var line in transaction.MerchantReceipt.Lines) {