Should you require more flexibility than the ready-made receipts provide, you can also send out or print your own receipts including the payment related data!
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.
Sample Receipt
Required Receipt information
The image above shows where the data contained in the response below should be displayed:
- Full address of the merchant, including the country.
Iterate over
merchantDetails
, for each line item printvalue
. -
receiptType.value
-
transactionType.value
-
amountAndCurrency.value
- The payment details, e.g. the masked account number.
Iterate over
paymentDetails
, for each line item print thelabel
andvalue
. -
statusText.value
-
date.value
andtime.value
- The clearing details, e.g. the merchant identifier.
Iterate over
clearingDetails
, for each line item print thelabel
andvalue
. - If
printSignatureLine
is true, then you have to print a signature line on your merchant receipt.
Accessing Receipt data
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.
Here is how to access receipt data:
MPTransactionProcess *process = [transactionProvider startTransactionWithParameters:transactionParameters accessoryParameters:accessoryParameters registered:[...] statusChanged:[...] actionRequired:[...] completed:^(MPTransactionProcess *process, MPTransaction *transaction, MPTransactionProcessDetails *details) { MPReceipt *receipt = transaction.merchantReceipt; // For the Customer Receipt //MPReceipt *receipt = transaction.customerReceipt; NSLog(@"MERCHANT DETAILS"); for (MPReceiptLineItem* lineItem in receipt.merchantDetails) { NSString *label = lineItem.label; NSString *value = lineItem.value; NSLog(@"%@: %@", label, value); } NSLog(@" "); NSLog(@"%@: %@", receipt.receiptType.label, receipt.receiptType.value); NSLog(@"%@: %@", receipt.transactionType.label, receipt.transactionType.value); NSLog(@"%@: %@", receipt.amountAndCurrency.label, receipt.amountAndCurrency.value); NSLog(@" "); NSLog(@"PAYMENT DETAILS"); for (MPReceiptLineItem* lineItem in receipt.paymentDetails) { NSString *label = lineItem.label; NSString *value = lineItem.value; NSLog(@"%@: %@", label, value); } NSLog(@" "); NSLog(@"%@: %@", receipt.statusText.label, receipt.statusText.value); NSLog(@"%@: %@", receipt.date.label, receipt.date.value); NSLog(@"%@: %@", receipt.time.label, receipt.time.value); NSLog(@" "); NSLog(@"CLEARING DETAILS"); for (MPReceiptLineItem* lineItem in receipt.clearingDetails) { NSString *label = lineItem.label; NSString *value = lineItem.value; NSLog(@"%@: %@", label, value); } NSLog(@" "); // --- Optional NSLog(@"%@: %@", receipt.identifier.label, receipt.identifier.value); // --- // --- Only for the Merchant Receipt if(receipt.printSignatureLine) { NSLog(@"Customer Signature:"); NSLog(@"___________________"); } }];
Pre-formatted Receipts
Starting from SDK version 2.41, you now have access to pre-formatted receipts that represent the format described above. 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, do the following assignment:
provider.maxReceiptLineLength = 40;
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.
Printing 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 by calling receipt.lines
. The call returns a list of strings
which you can loop through to easily print out.
NSLog(@"Merchant Receipt"); for (NSString *line in transaction.merchantReceipt.lines) { NSLog(@"%@", line); } NSLog(@"Customer Receipt"); for (NSString *line in transaction.customerReceipt.lines) { NSLog(@"%@", line); }
Should you require more flexibility than the ready-made receipts provide, you can also send out or print your own receipts including the payment related data!
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.
Sample Receipt
Required Receipt information
The image above shows where the data contained in the response below should be displayed:
- Full address of the merchant, including the country.
Iterate over each line item
getMerchantDetails()
returns and print what thegetValue()
method returns. -
getReceiptType().getValue()
-
getTransactionType().getValue()
-
getAmountAndCurrency().getValue()
- The payment details, e.g. the masked account number.
Iterate over each line item
getPaymentDetails()
returns and print what thegetLabel()
andgetValue()
methods return. -
getStatusText().getValue()
-
getDate().getValue()
andgetTime().getValue()
- The clearing details, e.g. the merchant identifier.
Iterate over each line item
getClearingDetails()
returns and print what thegetLabel()
andgetValue()
methods return. - If
isSignatureLineRequired()
is true, then you have to print a signature line on your merchant receipt.
Accessing Receipt data
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.
Here is how to access receipt data:
TransactionProcess paymentProcess = transactionProvider.startTransaction(transactionParameters, accessoryParameters, new TransactionProcessWithRegistrationListener() { @Override public void onCompleted(TransactionProcess process, Transaction transaction, TransactionProcessDetails processDetails) { // For the Merchant Receipt Receipt receipt = transaction.getMerchantReceipt(); // For the Customer Receipt // Receipt receipt = transaction.getCustomerReceipt(); Log.d("RECEIPT", "MERCHANT DETAILS"); for (ReceiptLineItem lineItem : receipt.getMerchantDetails()) Log.d("RECEIPT", lineItem.getLabel() + ": " + lineItem.getValue()); Log.d("RECEIPT", " "); Log.d("RECEIPT", receipt.getReceiptType().getLabel() + ": " + receipt.getReceiptType().getValue()); Log.d("RECEIPT", receipt.getTransactionType().getLabel() + ": " + receipt.getTransactionType().getValue()); Log.d("RECEIPT", receipt.getAmountAndCurrency().getLabel() + ": " + receipt.getAmountAndCurrency().getValue()); Log.d("RECEIPT", " "); Log.d("RECEIPT", "PAYMENT DETAILS"); for (ReceiptLineItem lineItem : receipt.getPaymentDetails()) Log.d("RECEIPT", lineItem.getLabel() + ": " + lineItem.getValue()); Log.d("RECEIPT", " "); Log.d("RECEIPT", receipt.getStatusText().getLabel() + ": " + receipt.getStatusText().getValue()); Log.d("RECEIPT", receipt.getDate().getLabel() + ": " + receipt.getDate().getValue()); Log.d("RECEIPT", receipt.getTime().getLabel() + ": " + receipt.getTime().getValue()); Log.d("RECEIPT", " "); Log.d("RECEIPT", "CLEARING DETAILS"); for (ReceiptLineItem lineItem : receipt.getClearingDetails()) Log.d("RECEIPT", lineItem.getLabel() + ": " + lineItem.getValue()); Log.d("RECEIPT", " "); // --- Optional Log.d("RECEIPT", receipt.getIdentifier().getLabel() + ": " + receipt.getIdentifier().getValue()); // --- // --- Only for the Merchant Receipt if(receipt.isSignatureLineRequired()) { Log.d("RECEIPT", "Customer Signature"); Log.d("RECEIPT", "___________________"); } } } );
Pre-formatted Receipts
Starting from SDK version 2.50, you now have access to pre-formatted receipts that represent the format described above. 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, call the following method:
transactionProvider.setMaxReceiptLineLength(40);
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.
Printing 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 by calling receipt.getLines()
. The method returns a list of strings
which you can loop through to easily print out.
TransactionProcess paymentProcess = transactionProvider.startTransaction(transactionParameters, accessoryParameters, new TransactionProcessWithRegistrationListener() { @Override public void onCompleted(TransactionProcess process, Transaction transaction, TransactionProcessDetails processDetails) { // For merchant Receipt Receipt merchantReceipt = transaction.getMerchantReceipt(); System.out.println("Merchant Receipt"); for (String line : merchantReceipt.getLines()) { System.out.println(line); } // For customer Receipt Receipt customerReceipt = transaction.getCustomerReceipt(); System.out.println("Customer Receipt"); for (String line : customerReceipt.getLines()) { System.out.println(line); } } } );