Server-side integration

This type of integration is suitable for partners who have already implemented the game logic for authorization, in-game store, and player’s inventory on their servers and want to use Xsolla Pay Station. You will need to get the Pay Station access token and configure the handling of webhooks.

During server integration, the following payment processing logic is implemented:

  1. The client sends a request to the application server to open the payment interface.
  2. The application server sends information about the currency and amount of the payment to the Xsolla server.
  3. The Xsolla server returns a token with purchase details and Pay Station parameters.
  4. The application server sends the received token to the client.
  5. The client opens Pay Station in a browser using the SDK.
  6. After paying for the purchase, a webhook with the payment status is sent to the application server.

Discord server
Connect with the Xsolla team and developers who use Xsolla products.

Integration flow

To integrate the Payments library:

  1. Download and install Android Studio.
  2. Create a new project.
  3. Set up an in-game store and product catalog on your server.
  4. Set up the project in your Publisher Account.
  5. Install the library.
  6. Configure Return URL.
  7. Get a token.
  8. Open the payment UI.
  9. Set up webhook handling.

After the integration is complete, test the payment process.

Note
This guide describes the minimum settings required to quick-start the module. For any questions, contact your Account Manager.

Set up project in your Publisher Account

  1. Sign up to Publisher Account.
  2. Configure a Publisher Account project. The first project is automatically created after you sign up for an account:
    1. In the Projects section, select your project and go to Project settings.
    2. In the General settings tab, add the following:
      • image (optional)
      • project languages (English is set by default)
      • project name for all specified languages
      • game website (optional)
      • project description (optional)
    3. Click Save.

You will need the following parameters for the integration:

  • Merchant ID found in Project settings > Webhooks.

  • API key found in Company settings > API key section.

  • Project ID found in Project settings > Project ID.

  • Secret key found in Project settings > Webhooks section.

Install library

The library is available in Maven Central.

To install the library:

  1. Start Android Studio.
  2. Open build.gradle file of your application.
  3. Add the following line to the dependencies section, where <version_number> is the required version of the Payments library:

Latest version:

Copy
Full screen
Small screen
implementation 'com.xsolla.android:payments:<version_number>'

Configure Return URL

Add the following strings to the project’s strings resources file to specify the Return URL configured in Publisher Account.

Copy
Full screen
Small screen
<string name="xsolla_payments_redirect_scheme">https</string>
<string name="xsolla_payments_redirect_host">example.com</string>
<string name="xsolla_payments_redirect_path_prefix">/payment</string>

There you should set the Return URL split into three parts. The example is for https://example.com/payment.

Get token

To obtain a token, use the Create payment token by server API call. Your server should send a request to the Xsolla server with the following data:

  • the ID of the user who made the purchase
  • amount of payment
  • payment currency
  • purchase details (optional)
  • Pay Station parameters (optional)

You can pass purchase information in one of the following ways:

  • as a list of items via the item parameter
  • as a description of the purchase via the description parameter

Pay Station parameters (e.g., localization language, interface properties, theme) are passed in the settings object. To enable/disable sandbox mode, you need to change the value of the sandbox parameter in the request to receive a token, and change the SDK settings. To change the rest of the Pay Station interface settings, you need to change the parameters of the request for a token.

Note
You can pass additional information using the custom_parameters parameter. This information will also be passed in the configured webhooks.

Open payment UI

Create Pay Station Intent

To open the payment UI, pass the token obtained in the previous step to the XPayments.createIntentBuilder SDK method.

Copy
Full screen
Small screen
val intent = XPayments.createIntentBuilder(getContext())
            .accessToken(AccessToken(token))
            .isSandbox(BuildConfig.IS_SANDBOX)
            .build()

Start activity using created Intent

Copy
Full screen
Small screen
startActivityForResult(intent, RC_PAYSTATION)

Parse activity result

Copy
Full screen
Small screen
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
       super.onActivityResult(requestCode, resultCode, data)
       if (requestCode == RC_PAYSTATION) {
           val result = XPayments.Result.fromResultIntent(data)
       }
   }

Set up webhooks

  1. Go to your project in Publisher Account.
  2. Go to Project settings > Webhooks, specify the Webhook URL, and generate a secret key to sign project webhooks.

  1. Save settings.
  2. Implement the following webhooks for Pay Station:

  1. Go to the Checkout tab and click Connect.

  1. Test the webhook handler.

Note
Acknowledge the receipt of a webhook your server must respond with:
  • HTTP code 204 without a message body
  • HTTP code 400 describing the problem if the specified user was not found or if an invalid signature was passed
You can read more about webhooks, including examples, in the API reference.

  1. Click Pay Station in the side menu and go to Settings.
  2. Set the Checkout toggle to On.

  1. Click Save.

Test payment process

After successfully 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.

Test the payment process by making real payments:

  • Make sure that you have signed a contract with Xsolla.
  • Set .isSandbox(false) while building a Paystation Intent.
  • Set the sandbox parameter to false in the request for the token.

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!
Last updated: July 16, 2021

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!