Standalone Receipt Printing

You can directly print customer and merchant receipts without going through the Summary screen by using the
createPrintCustomerReceiptIntent
and
createPrintMerchantReceiptIntent
methods defined in MposUi. Code examples of the
createPrintCustomerReceiptIntent
call used to print the customer receipt are shown below.
Kotlin
// transactionIdentifier: The transaction identifier for the receipt to be printed. // isDuplicate: Marks the printed receipt as a duplicate of the original receipt. val intent = mposUi.createPrintCustomerReceiptIntent(transactionIdentifier, false)
Java
// transactionIdentifier: The transaction identifier for the receipt to be printed. // isDuplicate: Marks the printed receipt as a duplicate of the original receipt. Intent intent = mposUi.createPrintCustomerReceiptIntent(transactionIdentifier, false);
To check if the receipt printing process was successful, use the callback function
onActivityResult
. This method is triggered after the Summary screen is closed and will behave the same way as the transaction results, but with a different result code.
Kotlin
// override this function for customised behaviours if needed override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) "onActivityResult: $resultCode".logDebug(TAG) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { val parentLayout: View = activity!!.findViewById(android.R.id.content) when (resultCode) { MposUi.RESULT_CODE_PRINT_SUCCESS -> Snackbar.make(parentLayout, "Printing success", Snackbar.LENGTH_SHORT).show() MposUi.RESULT_CODE_PRINT_FAILED -> Snackbar.make(parentLayout, "Printing failed", Snackbar.LENGTH_SHORT).show() MposUi.RESULT_CODE_EMAIL_FAILED -> Snackbar.make(parentLayout, "Fail while sending email via email", Snackbar.LENGTH_SHORT).show() MposUi.RESULT_CODE_EMAIL_SUCCESS -> Snackbar.make(parentLayout, "Receipt sent via email", Snackbar.LENGTH_SHORT).show() ... } } }
Related Links