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
| Extra | Type | Values |
|---|---|---|
me.yetipay.app.extra.INIT_RESULT | Boolean | true = success, false = failure |
me.yetipay.app.extra.INIT_RESULT_DETAIL | String | OK, COMPLETED, E1, A10, T1 |
Result Details:
OK- Successfully initializedCOMPLETED- Already initializedE1- Failed to startA10- Provisioning errorT1- Timeout
Initialise API is idempotent.
Start Payment
Action: me.yetipay.app.action.SALE
| Extra | Type | Required | Description |
|---|---|---|---|
me.yetipay.app.extra.BASE_AMOUNT | Int | Yes | Amount 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
| Extra | Type | Description |
|---|---|---|
me.yetipay.app.extra.BASE_AMOUNT | Int | Total amount paid (minor units) |
me.yetipay.app.extra.GRATUITY_AMOUNT | Int | Total tip amount (minor units) |
me.yetipay.app.extra.TRANSACTION_RESULT | String | AUTHORISED, FAILED, DECLINED, CANCELLED |
me.yetipay.app.extra.CARD_SCHEME | String | Card scheme (e.g., visa, mastercard, amex) - optional |
Transaction Results:
AUTHORISED- Payment successfulFAILED- Payment failedDECLINED- Payment declined by issuerCANCELLED- 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_SCHEMEextra is only present on successful payments and may be null- Device must be initialized (
INIT) before processing payments (SALE) - Result code
RESULT_CANCELEDindicates user backed out without completing the flow