Test the payment process

After successful configuring the library, test the payment process. By default, all payments are in the sandbox mode and you can use a test bank card to simulate a successful payment process.

Your application receives information about a completed purchase using an API request, without using webhooks. The purchase process consists of the following steps:

  1. When you open the Pay Station on the client, a UUID is generated for the transaction.
  2. The UUID is passed as part of access_data in the request to open Pay Station as the external identifier of the current transaction.
  3. The client application with the specified frequency requests the current transaction status by the UUID. The response to the request contains the current status of the transaction, the external transaction identifier, and the name and quantity of the purchased product.
  4. Once receipt of a successful transaction is received, purchased items can be credited to the player's inventory according to in-game logic.

Example of the method call:

Copy
Full screen
Small screen
XPayments.checkTransactionStatus(context, projectId, externalId);

Example of the receiver registration:

Copy
Full screen
Small screen
val filter = IntentFilter().apply {
    addAction(XPayments.ACTION_STATUS)
}
val receiver = object : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        val checkTransactionResult = intent.getParcelableExtra<XPayments.CheckTransactionResult>(XPayments.EXTRA_STATUS)
        if (checkTransactionResult?.status == XPayments.CheckTransactionResultStatus.SUCCESS) {
            // Process checkTransactionResult.paymentStatus and add items to local inventory
        } else {
            // Error
        }
    }
}
registerReceiver(receiver, filter)

{
"id":558357638,
"external_id":"647e9698-8ab3-11ea-ab8f-38f9d30e0dd3",
"status": "created",
"purchase": {
"checkout": null,
"virtual_currency": {
"name": "Money",
"quantity": 2
},
"virtual_items": null
}
}



{
"id": 558357634,
"external_id": "647e9698-8ab3-11ea-ab8f-38f9d30e0dd3",
"status": "processing",
"purchase": {
"checkout": null,
"virtual_currency": {
"name": "Money",
"quantity": 2
},
"virtual_items": null
}
}



{
"id": 556094258,
"external_id": "647e9698-8ab3-11ea-ab8f-38f9d30e0dd3",
"status": "canceled",
"purchase": {
"checkout": null,
"virtual_currency": null,
"virtual_items": [
{
"sku": "1468",
"quantity": 1
}
]
}
}
{
"id": 498415945,
"external_id": "647e9698-8ab3-11ea-ab8f-38f9d30e0dd3",
"status": "done",
"purchase": {
"checkout": {
"amount": -0.4,
"currency": "USD"
},
"virtual_currency": null,
"virtual_items": null
}
}

Test the payment process by making real payments:

  • Make sure that you have signed a contract with Xsolla.
  • Set .isSandbox(false) while building an Access Data.
  • Set .isSandbox(false) while building a Paystation Intent.