SDKs for Android / Track order status
  Back to Docs

SDKs for Android

Track order status

Notice
The SDK allows you to track the order status on the client side of your application. However, we recommend setting up a Payment webhook handler to receive order information in the back end of your application. This allows you to implement additional validation of completed purchases.

After a user makes a purchase, your application can perform the following actions:

  • show the order status in the application UI
  • credit a user’s balance after a successful payment
  • grant the purchased items after a successful payment

When using the SDK to implement the logic of these actions, you can track the order status in the following ways:

Subscribe to order status changes

To subscribe to order status changes, use the getOrderStatus SDK method from the Store library and pass the following parameters to the method:

  • listener — listener object of type OrderStatusListener.
  • orderId — order ID received from the purchase via the shopping cart, one-click purchase, or purchase for virtual currency as the parameter.
SDK reference documentation
Learn more about SDK methods and its parameters.

Example of calling the XStore.getOrderStatus method:

Copy
Full screen
Small screen
XStore.getOrderStatus(object : OrderStatusListener() {

               override fun  onStatusUpdate(status: OrderResponse.Status) {

                   if(status == OrderResponse.Status.DONE) {

                       Log.d("MainActivity", "Success")

                   }

               }

               override fun  onFailure() {

                   Log.d("MainActivity", "Failure")

               }

           }, orderId)

We recommend to call XStore.getOrderStatus method when opening payment UI.

Purchase methods encapsulate several methods for tracking the order status. Tracking is performed according to the following algorithm:

  1. A web socket connection is established.
  2. If the web socket connection is established successfully and order status changes to done or cancel, tracking stops. If a web socket connection fails or the response contains incorrect data, the order status is tracked using short-polling.
  3. Order status tracking continues with short-polling. A simple HTTP order status request is sent once every 3 seconds. Tracking stops if order status changes to done or cancel.

Request order status

You can also request order status, for example, when redirecting the user to the application from the payment UI. Use the statuses returned by the XPayments class to track when the payment UI is closed.

Notice
The statuses returned by the XPayments class indicate whether the user has completed a purchase flow in the payment UI and are not the same as payment transaction statuses.

The XPayments class can return the following statuses:

  • XPayments.Status.COMPLETED — the user completed the payment and returned to the application.
  • XPayments.Status.CANCELLED — the user closed the payment UI without completing the payment.
  • XPayments.Status.UNKNOWN — аn error occurred during payment, for example, when the bank rejected the transaction.

To get the current status of a payment transaction, use the getOrder method of the Store library. Pass the order ID received from the purchase via the shopping cart, one-click purchase, or purchase for virtual currency as the parameter.

Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Rate this page
Rate this page
Is there anything we can improve?

Don’t want to answer

Thank you for your feedback!

Useful links

Last updated: March 26, 2024

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!