Closeout

Android Payments API

North America
Europe
Latin America

Use the CloseoutRequestIntentBuilder class to build an Intent to initiate an activity to manually closeout the current batch of transactions.

Prerequisites

Steps

  1. Build a closeout request.
val builder = CloseoutRequestIntentBuilder()
val intent = builder.build(context)
  1. Use the Intent to initiate the closeout process.

TipOptions

The TipOptions class provides static methods to customize the handling of open tip-adjustable payments.

MethodDescription
ZeroOutOpenTips()For open payments, autopopulates all open payments with a tip amount = 0.
PromptForOpenPayments()For open payments, prompts the merchant to manually enter tip amounts.
ReturnOpenPayments()For open payments, returns payment IDs of outstanding open payments.

📘

Note

A closeout will not be queued if there are open payments.

Example—Zero out all open tips

Zeroing out of all open tips is a headless process without the user interface.

val builder  = CloseoutRequestIntentBuilder()
val tipOptions = CloseoutRequstIntentBuilder.TipOptions.ZeroOutOpenTips()
val intent = builder.tipOptions(tipOptions).build(context)

Example—Prompt for Open Payments

val builder  = CloseoutRequestIntentBuilder()
val tipOptions = CloseoutRequstIntentBuilder.TipOptions.PromptForOpenPayments()
val intent = builder.tipOptions(tipOptions).build(context)
Closeout keypad page - open payments

Closeout keypad - open payments

Additional field

Additional field for the CloseoutRequestIntentBuilder class is:

FieldDescription
leavePreauthsOpen: BooleanIndicates whether to keep authorizations open through closeout.

Response details

When the closeout flow completes, the response is available through onActivityResult().

  • For a successful request, retrieve the Batch object using the Intent: CloseoutRequestIntentBuilder.Response.BATCH
  • For an unsuccessful request, retrieve the failure message using the Intent:
    • CloseoutRequestIntentBuilder.Response.FAILURE_MESSAGE
    • CloseoutRequestIntentBuilder.Response.PAYMENT_IDS if the intent fails because of open payments.

Response example

fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == CLOSEOUT_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                val batch: Batch = data?.getParcelableExtra<Batch>(CloseoutRequestIntentBuilder.Response.BATCH) as Batch
                val closeoutResult = data?.getStringExtra(CloseoutRequestIntentBuilder.Response.CLOSEOUT_RESULT)
            } else {
                // closeout failed, check for error
                val failureMessage = data?.getStringExtra(CloseoutRequestIntentBuilder.Response.FAILURE_MESSAGE)
                val closeoutResult = data?.getStringExtra(CloseoutRequestIntentBuilder.Response.CLOSEOUT_RESULT)
                val paymentIds = data?.getStringArrayListExtra(CloseoutRequestIntentBuilder.Response.PAYMENT_IDS)
            }
        }
    }