Integrate SDK on application side
- Implement the logic of getting payment tokens in one of the following ways:
- Using the Store library (recommended):
- To purchase a single item, call the
createOrderByItemSku
method. - To purchase the items in the cart:
- After the user has filled the cart, call the
fillCurrentCartWithItems
method. - Call the
createOrderFromCartById
orcreateOrderFromCurrentCart
method.
- After the user has filled the cart, call the
- To purchase a single item, call the
- Using the Store library (recommended):
- Using the IGS & BB API.
- Using your own server methods or BaaS solution methods.
- Implement the logic of payment UI opening:
Note
Review the demo project for an implementation example.
Copy
- kotlin
val intent = XPayments.createIntentBuilder(this)
.accessToken(AccessToken(token))
.isSandbox(BuildConfig.IS_SANDBOX)
.build()
startActivityForResult(intent, RC_PAYSTATION)
- Implement payment result handling:
Copy
- kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RC_PAYSTATION) {
val (status, _) = XPayments.Result.fromResultIntent(data)
when (status) {
XPayments.Status.COMPLETED -> showSnack(getString(R.string.payment_completed))
XPayments.Status.CANCELLED -> showSnack(getString(R.string.payment_cancelled))
XPayments.Status.UNKNOWN -> showSnack(getString(R.string.payment_unknown))
}
}
}
Note
Review the demo project for an implementation example.
Your progress
Found a typo or other text error? Select the text and press Ctrl+Enter.