Skip to main content

Android Intent API

This API enables 3rd party Android apps running on yetipay devices to initiate a payment on the device and be notified of the result.

The API must first be Initialised and then you may call Start Payment to toggle to the yetipay app. After the transaction completes, you'll receive a me.yetipay.app.action.TX_COMPLETE response describing the outcome.

Initialise API

Action: me.yetipay.app.action.INIT

Example:

val intent = Intent("me.yetipay.app.action.INIT")
startActivityForResult(intent, REQUEST_CODE)

Response: me.yetipay.app.action.INIT_COMPLETE

ExtraTypeValues
me.yetipay.app.extra.INIT_RESULTBooleantrue = success, false = failure
me.yetipay.app.extra.INIT_RESULT_DETAILStringOK, COMPLETED, E1, A10, T1

Result Details:

  • OK - Successfully initialized
  • COMPLETED - Already initialized
  • E1 - Failed to start
  • A10 - Provisioning error
  • T1 - Timeout

Initialise API is idempotent.


Start Payment

Action: me.yetipay.app.action.SALE

ExtraTypeRequiredDescription
me.yetipay.app.extra.BASE_AMOUNTIntYesAmount to charge (minor units)

Example:

val intent = Intent("me.yetipay.app.action.SALE")
intent.putExtra("me.yetipay.app.extra.BASE_AMOUNT", amountInMinorUnits) // Int
startActivityForResult(intent, REQUEST_CODE)

Response: me.yetipay.app.action.TX_COMPLETE

ExtraTypeDescription
me.yetipay.app.extra.BASE_AMOUNTIntTotal amount paid (minor units)
me.yetipay.app.extra.GRATUITY_AMOUNTIntTotal tip amount (minor units)
me.yetipay.app.extra.TRANSACTION_RESULTStringAUTHORISED, FAILED, DECLINED, CANCELLED
me.yetipay.app.extra.CARD_SCHEMEStringCard scheme (e.g., visa, mastercard, amex) - optional

Transaction Results:

  • AUTHORISED - Payment successful
  • FAILED - Payment failed
  • DECLINED - Payment declined by issuer
  • CANCELLED - User cancelled payment

Complete Example

class MainActivity : AppCompatActivity() {

companion object {
const val REQUEST_PAYMENT = 1001
}

fun startPayment(amountPence: Int) {
val intent = Intent("me.yetipay.app.action.SALE")
intent.putExtra("me.yetipay.app.extra.BASE_AMOUNT", amountPence)
startActivityForResult(intent, REQUEST_PAYMENT)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

if (requestCode == REQUEST_PAYMENT && resultCode == RESULT_OK) {
val result = data?.getStringExtra("me.yetipay.app.extra.TRANSACTION_RESULT")
val amount = data?.getIntExtra("me.yetipay.app.extra.BASE_AMOUNT", 0)
val tip = data?.getIntExtra("me.yetipay.app.extra.GRATUITY_AMOUNT", 0)
val cardScheme = data?.getStringExtra("me.yetipay.app.extra.CARD_SCHEME")

when (result) {
"AUTHORISED" -> handleSuccess(amount, tip, cardScheme)
"DECLINED" -> handleDeclined()
"FAILED" -> handleFailure()
"CANCELLED" -> handleCancelled()
}
}
}
}

Notes

  • All amounts are in minor units (e.g., pence, cents)
  • CARD_SCHEME extra is only present on successful payments and may be null
  • Device must be initialized (INIT) before processing payments (SALE)
  • Result code RESULT_CANCELED indicates user backed out without completing the flow