On This Page
Tap to Pay on Android Payment Services
Use the information in this section to process Tap to Pay on Android Solution payment
services.
Sale
Use the information in this section to process a sale. This type of transaction combines an
authorization and a capture into a single transaction.
Follow these steps to process a sale.
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentvalue from themposUIobject, and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed, theonActivityResultmethod is triggered. This action returns information about the previous transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUIobject.val transactionObject = mposUi.latestTransaction
Refund
Use this information to process a refund by referencing the original transaction. You
can issue refunds for either the full amount or a partial amount of the original
transaction.
Stand-alone credits are also supported and can be processed independently of a
previous transaction. For more information, see Stand-Alone Credit.
Follow these steps to process a refund.
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentvalue from themposUIobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .refund(“transactionIdentifier”) //Specify amount and currency for partial refunds //.amountAndCurrency(BigDecimal(1.00), Currency.EUR) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed,onActivityResultis triggered. This action returns information about the previous transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRAN SACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved! \nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was decline d, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUIobject.val transactionObject = mposUi.latestTransaction
Stand-Alone Credit
Use this information to process a stand-alone credit. This transaction enables you to
issue a credit without referencing a previous transaction. The customer must present
their payment card.
WARNING
When processing a stand-alone credit, there is no limit on the
credit amount because the transaction does not reference the original purchase. To
help manage risk, it is recommended to use a refund transaction whenever possible.
For more information, see Refund.
Follow these steps to process a stand-alone credit.
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentvalue from themposUIobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .refund(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed,onActivityResultis triggered. This action returns information about the previous transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUIobject.val transactionObject = mposUi.latestTransaction
Check Transaction Status
Use this information to request a check transaction status. This transaction enables you to
retrieve response data for a transaction that was lost or timed out. You must have
the
transactionIdentifier
value for the transaction that you want
to check. When the check transaction status request is complete, the transaction
details show on the Summary screen.Follow these steps to request a check transaction status.
- Obtain thetransactionIdentifiervalue in theonActivityResultmethod of the original transaction.
- Retrieve the transactionsummaryIntentvalue from themposUIobject.
- Use thestartActivitymethod to initiate the Summary screen.val summaryIntent = mposUi.createTransactionSummaryIntent(transactionIdentifier = "transactionIdentifier") startActivityForResult(summaryIntent, MposUi.REQUEST_CODE_SHOW_SUMMARY)
- After the Summary screen is dismissed, theonActivityResultmethod is triggered. This action returns information about the previous transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) // Result code from closing the summary screen if (resultCode == MposUi.RESULT_CODE_SUMMARY_CLOSED) { // Accessing status from the transaction that was just queried val transactionStatus = mposUi.latestTransaction?.status Toast.makeText(activity, "Summary closed. Transaction status: $transactionStatus", Toast.LENGTH_SHORT).show() } }
- You can get the full transaction object by retrieving thelatestTransactionfrom the mposUi object.val transactionObject = mposUi.latestTransaction
Pre-Authorization
Use this information to process a pre-authorization for an initial amount. A
pre-authorization transaction places a temporary hold on the customer's payment
card. The transaction amount can be captured at a later time.
Most authorizations expire within 5 to 7 days, as determined by the issuing bank.
When an authorization expires, your bank, the issuing bank, or payment processor
might require you to resubmit the authorization request and include a capture
request in the same message. For more information, seeCapture.
To help ensure successful transaction processing, monitor authorization timelines and
use combined authorization and capture requests when necessary.
Follow these steps to process a pre-authorization.
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentvalue from themposUIobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .autoCapture(false) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed,onActivityResultis triggered. This action returns information about the previous transaction.Override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUIobject.val transactionObject = mposUi.latestTransaction
Incremental Authorization
Use the information in this section to process an incremental authorization. This type of
transaction can be made on a pre-authorization request to increase the authorized
amount before it is captured.
Follow these steps to process an incremental authorization.
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentvalue from themposUIobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .incrementalAuthorization("transactionIdentifier") .amountAndCurrency(BigDecimal("1.00"), Currency.EUR) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed,onActivityResultmethod is triggered. This action returns information about the previous transaction.Override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRAN SACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionvalue from themposUIobject.val transactionObject = mposUi.latestTransaction
Capture
Use this information to capture a pre-authorized transaction. The capture
request references the approved pre-authorization request.
Follow these steps to process a capture.
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentvalue from themposUIobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .capture("transactionIdentifier") // Specify amount and currency for partial captures // .amountAndCurrency(BigDecimal("1.00"), Currency.EUR) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed,onActivityResultmethod is triggered. This action returns information about the previous transaction.Override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRAN SACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionvalue from themposUIobject.val transactionObject = mposUi.latestTransaction
Sale with On-Reader Tipping
Use the information in this section to process a sale with on-reader tipping. At the
start of each transaction, the terminal prompts the customer to add a tip by showing
suggested tip amounts. The customer chooses or enters a tip amount on the terminal
before presenting their payment card.
Follow these steps to process a sale with on-reader tipping.
- Create aTransactionParametersobject and provide the required information for the payment.
- Create aTippingProcessStepParametersobject to configure the tipping function. The options are percentage choice, tip amount, or total amount.
- Create aTransactionProcessParametersobject to add the tipping step.
- Retrieve thetransactionIntentvalue from themposUIobject, and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .build() // Use to display three tipping percentage choices val tipStep = TippingProcessStepParameters.Builder() .askForPercentageChoice() // Optional to configure tipping percentages | Default values = 10, 15, 20 // .percentages(BigDecimal("10"), BigDecimal("20"), BigDecimal("30")) // Optional to show confirmation screen // .showTotalAmountConfirmationScreen(true) .build() // Use to ask for tip amount // val tipStep = TippingProcessStepParameters.Builder() // .askForTipAmount() // Optional to show confirmation screen // .showTotalAmountConfirmationScreen(true) // .build() // Use to ask for total transaction amount including tip // val tipStep = TippingProcessStepParameters.Builder() // .askForTotalAmount() // Optional to show confirmation screen // .showTotalAmountConfirmationScreen(true) // .build() val processParameters = TransactionProcessParameters.Builder() .addStep(tipStep) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters, processParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is completed and the Summary screen is dismissed,onActivityResultmethod is triggered. This action returns information about the previous transaction.Override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), “Transaction was declined, aborted, or failed”, Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUIobject.val transactionObject = mposUi.latestTransaction
Sale with Installment Details
Use this information to process a sale with installment details. This transaction
includes the required installment payment details in the payment request.
IMPORTANT
This transaction is available only in the Latin American
and Caribbean (LAC) region.
Follow these steps to process a sale with installment details.
- Create anInstallmentDetailsobject and set one ore more of the installment fields.// Set value of the builder to the number of installments val installmentDetails = InstallmentDetailsBuilder(5) // Set to PlanType.ISSUER_FUNDED for issuer funded plans .planType(PlanType.MERCHANT_FUNDED) .includesInterest(true) .governmentPlan(true) .build()
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentfrom themposUiobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .installmentDetails(installmentDetails) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is complete and the Summary screen is dismissed, theonActivityResultis triggered. This action returns information about the last transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUiobject.val transactionObject = mposUi.latestTransaction
Sale with Payment Facilitator Details
Use the information in this section to process a sale with payment facilitator details. This
type of transaction can be used to include required payment facilitator details as
part of the transaction.
Follow these steps to process a sale with payment facilitator details.
- Create aMerchantDetailsobject and set one ore more of the payment facilitator fields.val merchantDetails = MerchantDetailsBuilder() .salesOrganizationId("12345") .subMerchantId("SM67890") .merchantDescriptor("ExampleMerchant") .build()
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentfrom themposUiobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .merchantDetails(merchantDetails) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is complete and the Summary screen is dismissed, theonActivityResultis triggered. This action returns information about the last transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUiobject.val transactionObject = mposUi.latestTransaction
Sale with Tax Details
Use the information in this section to process a sale with tax details. This type of
transaction can be used to include required tax details as part of the
transaction.
Follow these steps to process a sale with tax details.
- Create aTaxDetailsobject and set one ore more of the tax fields.val taxDetails = TaxDetailsBuilder() .merchantTaxId("TaxID1234") .salesSlipNumber(12345678) .includedTaxAmount(BigDecimal("5.00")) .includedLocalTaxAmount(BigDecimal("1.00")) .includedNationalTaxAmount(BigDecimal("2.00")) .build()
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentfrom themposUiobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .taxDetails(taxDetails) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is complete and the Summary screen is dismissed, theonActivityResultis triggered. This action returns information about the last transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUiobject.val transactionObject = mposUi.latestTransaction
Sale with Lodging Details
Use this information to process a sale with lodging details. This transaction
includes the required lodging details in the payment request.
Follow these steps to process a sale with lodging details.
- Create aLodgingDetailsobject and set one or more lodging fields.// Set value of the builder to the duration of stay val lodgingDetails = LodgingDetailsBuilder(3) .checkInDate("030125") .checkOutDate("030425") .guestSmokingPreference("N") .numberOfGuests(2) .numberOfRoomsBooked(1) .guestName("John Doe") .roomLocation("Ocean View") .roomTaxElements("VAT") .roomBedType("KING") .roomRateType("CORPORATE") .specialProgramCode("1") .dailyRoomRate1(BigDecimal("150.00")) .dailyRoomRate2(BigDecimal("160.00")) .dailyRoomRate3(BigDecimal("170.00")) .roomNights1(1) .roomNights2(1) .roomNights3(1) .corporateClientCode("CORP123456") .promotionalCode("PROMO2025") .additionalCoupon("DISCOUNT10") .travelAgencyCode("TA789") .travelAgencyName("Premium Travel Agency") .customerServicePhoneNumber("1-800-555-0199") .tax(BigDecimal("45.00")) .prepaidCost(BigDecimal("200.00")) .foodAndBeverageCost(BigDecimal("125.00")) .roomTax(BigDecimal("30.00")) .adjustmentAmount(BigDecimal("15.00")) .phoneCost(BigDecimal("8.00")) .restaurantCost(BigDecimal("95.00")) .roomServiceCost(BigDecimal("40.00")) .miniBarCost(BigDecimal("25.00")) .laundryCost(BigDecimal("18.00")) .miscellaneousCost(BigDecimal("12.00")) .giftShopCost(BigDecimal("35.00")) .movieCost(BigDecimal("10.00")) .healthClubCost(BigDecimal("20.00")) .valetParkingCost(BigDecimal("30.00")) .cashDisbursementCost(BigDecimal("5.00")) .nonRoomCost(BigDecimal("40.00")) .businessCenterCost(BigDecimal("15.00")) .loungeBarCost(BigDecimal("55.00")) .transportationCost(BigDecimal("75.00")) .gratuityCost(BigDecimal("45.00")) .conferenceRoomCost(BigDecimal("120.00")) .audioVisualCost(BigDecimal("65.00")) .banquetCost(BigDecimal("180.00")) .internetAccessCost(BigDecimal("12.00")) .earlyCheckOutCost(BigDecimal("20.00")) .nonRoomTax(BigDecimal("25.00")) .build()
- Create aTransactionParametersobject and provide the required information for the payment.
- Retrieve thetransactionIntentfrom themposUiobject and use thestartActivitymethod to initiate the transaction flow.val transactionParameters = TransactionParameters.Builder() .charge(BigDecimal("1.00"), Currency.EUR) .customIdentifier("yourReferenceForTheTransaction") .lodgingDetails(lodgingDetails) .build() val transactionIntent = mposUi.createTransactionIntent(transactionParameters) startActivityForResult(transactionIntent, MposUi.REQUEST_CODE_PAYMENT)
- After the transaction is complete and the Summary screen is dismissed, theonActivityResultis triggered. This action returns information about the last transaction.override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == MposUi.REQUEST_CODE_PAYMENT) { when (resultCode) { // Result code from a successful transaction MposUi.RESULT_CODE_APPROVED -> { val transactionIdentifier = data?.getStringExtra(MposUi.RESULT_EXTRA_TRANSACTION_IDENTIFIER) Toast.makeText(findViewById(android.R.id.content),"Transaction approved!\nIdentifier: $transactionIdentifier", Toast.LENGTH_LONG).show() } // Result code from a declined, aborted or failed transaction MposUi.RESULT_CODE_FAILED -> { Toast.makeText(findViewById(android.R.id.content), "Transaction was declined, aborted, or failed", Toast.LENGTH_LONG).show() } } } }
- You can get the full transaction object by retrieving thelatestTransactionfrom themposUiobject.val transactionObject = mposUi.latestTransaction
Email a Customer Receipt
Follow these steps to email a customer receipt from a previous
transaction.
- Retrieve theSendEmailReceiptIntentvariable from themposUIobject and use thestartActivitymethod to initiate the emailing a receipt flow.val SendEmailReceiptIntent = mposUi.createSendEmailReceiptIntent(transactionIdentifier) startActivityForResult(SendEmailReceiptIntent, MposUi.REQUEST_CODE_SEND_EMAIL)
- After the emailing activity is completed, theonActivityResultmethod is triggered. This action returns information about the previous 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_SEND_EMAIL) { if (resultCode == MposUi.RESULT_CODE_EMAIL_SUCCESS) { Snackbar.make(parentLayout, "Receipt sent via email", Snackbar.LENGTH_SHORT).show() } else if (resultCode == MposUi.RESULT_CODE_EMAIL_FAILED) { Snackbar.make(parentLayout, "Fail while sending receipt via email", Snackbar.LENGTH_SHORT).show() } } }