Skip to main content

Package name

com.lab4pay.pos

Charge

Generating or applying a payment using any card or digital method.

Revert

Reversing a transaction, returning the money to the original account.

High-level flow

  1. Client’s app constructs an explicit Intent targeting Payment app and specifies the desired action.
  2. Client’s app launches the Intent with registerForActivityResult(StartActivityForResult).
  3. The user pays (or cancels).
  4. Payment app returns a result Intent with details via setResult(...) and finish().
  5. Client’s app finalizes the order.

Charge Intent Contract

Request action

com.lab4pay.pos.CHARGE

Request parameters

NameTypeExampleNotes
payConnectIntegratorIdString9e6d06fe0322Your Integrator ID. For reference see the Integrator Registry section
payConnectIdString350344d0718bPay-Connect ID returned from Pairing section
amountInteger2350The amount of the payment, in cents
clientTransactionIdStringref-49152Unique per payment attempt

Response

  • Result codes:
    • Activity.RESULT_OK -> The payment app completed normally and returned a valid result Intent. Additional details are provided in the Intent extras.
    • Activity.RESULT_CANCELED -> Payment flow ended unexpectedly (user exited early or app failed before returning a result). No Intent extras are available.
  • Data: An Intent with Response extras

Response extras

NameTypeRequiredNotes
transactionIdStringYes - When SUCCESSOur unique transaction reference
clientTransactionIdStringYesEchoed from original request
paymentMethodStringYes - When SUCCESSe.g., CARD, MBILLS, VALU
paymentOptionStringNoDepends on payment method. e.g., VISA, MASTERCARD, BTC, USDT
amountIntegerYes - When SUCCESSThe amount of the payment, in cents
tipAmountIntegerYes - When providedThe tip amount of the payment, in cents
currencyStringYesCurrency format ISO 4217
statusStringYesSUCCESS | CANCELED | FAILED

Revert Intent Contract

Request action

com.lab4pay.pos.REVERT

Request parameters

NameTypeExampleNotes
payConnectIntegratorIdString9e6d06fe0322Your Integrator ID. For reference see the Integrator Registry section
payConnectIdString350344d0718bPay-Connect ID returned from Pairing section
transactionIdString41dTf452a3b2The CHARGE transaction ID returned in transactionId
Only the most recent SUCCESS transaction performed on the terminal can be reverted.
Reverts are only available for certain payment methods.

Response

  • Result codes:
    • Activity.RESULT_OK -> The payment app completed normally and returned a valid result Intent. Additional details are provided in the Intent extras.
    • Activity.RESULT_CANCELED -> Payment flow ended unexpectedly (user exited early or app failed before returning a result). No Intent extras are available.
  • Data: An Intent with Response extras

Response extras

NameTypeRequiredNotes
transactionIdStringYesEchoed from original request
statusStringYesSUCCESS | FAILED

Example: Android Intent

class PaymentActivity : AppCompatActivity() {

    private const val TAG = "PaymentActivity"

    private val chargeLauncher =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
            handleChargeResult(result)
        }

    private fun launchCharge() {
        val intent = Intent("com.lab4pay.pos.CHARGE").apply {
            setPackage("com.lab4pay.pos")
            putExtra("amount", 2350)
            putExtra("clientTransactionId", "ref-49152")
        }
        chargeLauncher.launch(intent)
    }

    private fun handleChargeResult(result: ActivityResult) {
        when (result.resultCode) {
            Activity.RESULT_OK -> {
                val data = result.data ?: return
                val status = data.getStringExtra("status")
                val clientTransactionId = data.getStringExtra("clientTransactionId")

                when (status) {
                    "SUCCESS" -> {
                        val transactionId = data.getStringExtra("transactionId")
                        val paymentMethod = data.getStringExtra("paymentMethod")
                        val paymentOption = data.getStringExtra("paymentOption")
                        val amount = data.getIntExtra("amount", 0)
                        val tipAmount = data.getIntExtra("tipAmount", 0)
                        val currency = data.getStringExtra("currency")

                        Log.i(TAG, "Payment successful: id=$transactionId, amount=$amount $currency, method=$paymentMethod, ref=$clientTransactionId, ts=$timestamp")
                        // finalize order and update backend
                    }

                    "FAILED" -> {
                        Log.e(TAG, "Payment failed for ref=$clientTransactionId")
                        // show failure message or retry
                    }

                    "CANCELED" -> {
                        Log.w(TAG, "Payment canceled by user: ref=$clientTransactionId")
                        // handle user cancellation
                    }

                    else -> Log.e(TAG, "Unknown status: $status")
                }
            }

            Activity.RESULT_CANCELED -> {
                Log.w(TAG, "Payment flow aborted. No result Intent returned.")
                // allow retry or mark as incomplete
            }

            else -> Log.w(TAG, "Unexpected resultCode: ${result.resultCode}")
        }
    }
}