With the SDK ready, it’s time to create a transaction.

Open the payment sheet

To open the payment sheet call the .launch() method on the SDK.

gr4vySDK.launch(
    context = this,
    token = "[TOKEN]",
    amount = 1299,
    currency = "AUD",
    country = "AU"
)

Replace the [TOKEN] with the JWT created in step 2. Additional options can be provided when launching the SDK.

Handle SDK events

The Gr4vyResultHandler requires you to handle the events emitted by the SDKs as follows.

override fun onGr4vyResult(result: Gr4vyResult) {
  when(result) {
    is Gr4vyResult.GeneralError -> startActivity(Intent(this, FailureActivity::class.java))
    is Gr4vyResult.TransactionCreated -> startActivity(Intent(this, SuccessActivity::class.java))
    is Gr4vyResult.TransactionFailed -> startActivity(Intent(this, FailureActivity::class.java))
  }
}

Learn more about the events triggered by the Android SDK in our events guide.