Integración en el lado del servidor

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.

Flujo de integración

To integrate Xsolla products with your servers using the Game Commerce asset:

  1. Install the asset.
  2. Set up the project in your Publisher Account.
  3. Set up an in-game store and product catalog on your server.
  4. Set up your Unity project.
  5. Get a token.
  6. Open the payment UI.
  7. Set up webhook handling.

After the integration is complete, test the payment process.

Contacte con nuestro equipo de integración
Haga clic en el icono de chat de la esquina inferior derecha y contacte con el equipo de integración a través de una aplicación de mensajería. Le responderemos en tiempo real y le ayudaremos a resolver el problema.
Nota
This guide describes the minimum settings required to quick-start the module. For any questions, contact your Account Manager.

Instalar recurso

Nota
Solo la última versión del SDK está disponible a través de CDN. Si necesita una versión diferente, puede descargarla desde GitHub.
  1. Download Unity.
  2. Pick a personal or professional Unity license based on your preferences.
  3. Create a new Unity project.
  4. Download the asset.
  5. Unzip the package.
  6. In the Unity editor, go to Assets > Import Package > Custom Package in the main menu and select the asset.
  7. Make sure that the Mono compiler is used for creating a game build (for standalone builds only). To do this:
    1. Click Edit > Project Settings in the main menu.
    2. Go to the Other Settings > Configuration section.
    3. Make sure that Mono is chosen in the Scripting Backend field.

After installing the asset, launch the Xsollus demo scene from the Assets > Xsolla > DemoCommon > Scene directory. The demo scene shows the features of the asset and represents a possible implementation of the application logic.

For the demo scene, a project in Publisher Account is preset and an in-game store is fully configured.

Default values for the Xsollus demo scene:

KeyValue
Login ID026201e3-7e40-11ea-a85b-42010aa80004
Project ID77640

You can use the demo scene in two ways:

  • as an example
  • as an initial version of the login system, inventory, and in-game store in order to get a quick result and expand its capabilities if necessary

To use the demo scene or its parts in your application, add it in build settings:

  1. Go to Assets > Xsolla > DemoCommon > Scene and launch the Xsollus scene.
  2. Open File > Build settings and click Add Open Scenes.

Crear proyecto en Cuenta del editor

  1. Sign up to Publisher Account.
  2. Configure your project:
    1. To fill in the game data automatically, provide the Link to your game on any platform. As a result, the image of the game, its name, and description will be added to the project settings.
    2. To fill in the game data manually, click I don’t have a link, set up manually and specify:
      • project languages (English is set by default)
      • project name for all specified languages
      • game website (optional)
    3. Click Create project.

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 Publisher Account beside the name of your project.
  • Secret key found in Project settings > Webhooks section.

Establecer proyecto de Unity

  1. Open your Unity project.
  2. Click Window > Xsolla > Edit Settings in the main menu.
  3. To enable sandbox mode, check the Enable sandbox? box in the Inspector panel.
  1. Design an interface for the login system, in-game store, and other pages for your application. You can create your own solution by following Unity instructions.
  2. Set up event handling according to your application logic using SDK methods.

Obtener 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.

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

Abrir la interfaz de pago

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

Configurar 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.
Nota
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.

Probar el proceso de pago

After successfully configuring the asset, test the payment process. By default, all payments are made in sandbox mode for any users. Use a test bank card to simulate a successful payment process.

To test the payment process with real payments:

  1. Make sure that you have signed a contract with Xsolla.
  2. In your Unity project, uncheck the Enable sandbox? box in the Inspector panel.
  3. Set the sandbox parameter to false in the request for the token.

¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Última actualización: 22 de Enero de 2024

¿Has encontrado una errata u otro error de texto? Selecciona el texto y pulsa Ctrl+Intro.

Informar de un problema
Nos esforzamos por ofrecer contenido de calidad. Tus comentarios nos ayudan a mejorar.
Déjanos tu correo electrónico para que te podamos responder
¡Gracias por tu mensaje!