Print a Customer or Merchant Receipt

Follow these steps to print a customer or merchant receipt from a previous transaction:
  1. Retrieve the
    PrintCustomerReceiptIntent
    from the
    mposUi
    object and use the
    startActivity
    method to initiate the printing a receipt flow.
    // Use to print a customer receipt val PrintCustomerReceiptIntent = mposUi.createPrintCustomerReceiptIntent(transactionIdentifier, false) startActivityForResult(PrintCustomerReceiptIntent, MposUi.REQUEST_CODE_PRINT_CUSTOMER_RECEIPT) // Use to print a merchant receipt val PrintMerchantReceiptIntent = mposUi.createPrintMerchantReceiptIntent(transactionIdentifier, false) startActivityForResult(PrintMerchantReceiptIntent, MposUi.REQUEST_CODE_PRINT_MERCHANT_RECEIPT)
  2. After the printing activity is completed,
    onActivityResult
    is triggered. This action returns information about the last transaction.
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) "onActivityResult: $resultCode".logDebug(TAG) val parentLayout: View = activity!!.findViewById(android.R.id.content) if (requestCode == MposUi.REQUEST_CODE_PRINT_CUSTOMER_RECEIPT || requestCode == MposUi.REQUEST_CODE_PRINT_MERCHANT_RECEIPT) { if (resultCode == MposUi.RESULT_CODE_PRINT_SUCCESS) { Snackbar.make(parentLayout, "Printing success", Snackbar.LENGTH_SHORT).show() } else if (resultCode == MposUi.RESULT_CODE_PRINT_FAILED) { Snackbar.make(parentLayout, "Printing failed", Snackbar.LENGTH_SHORT).show() } }