This repository provides an example of how to integrate Xsolla PayStation and handle payment processing
Video instruction - https://www.youtube.com/watch?v=sFxa2rZvF2Y
cp .env.example .env
Next, fill in the necessary values in the .env file
Project ID can be found in your Xsolla Publisher Account.
docker-compose --env-file ./.env -f docker/docker-compose.yml up --build
The application will be running on http://localhost:8080
If you don't have public IP and domain, you can use Ngrok to expose your local environment for webhook handling. (you should put your Ngrok auth token to .env before run docker container)
docker exec -it xsolla_example bash -c 'ngrok http 8080'
Ngrok will provide a publicly accessible URL like https://<random>.ngrok-free.app
You can open ngrok panel on http://localhost:4040 for looking incoming requests
In you Xsolla Publisher Account -> your project -> Project settings -> Webhooks
OR open the page: https://publisher.xsolla.com/<YOUR_MERCHANT>/projects/<YOUR_PROJECT>/edit/webhooks/
Your should set your webhook handler URL.
In this example its will be:
https://<your>.ngrok-free.app/webhook.php
In your Xsolla Publisher Account -> your project -> store -> virtual items -> add item OR open the page: https://publisher.xsolla.com/<YOUR_MERCHANT>/projects/<YOUR_PROJECT>/storefront/virtual-items and create a product.
Open example UI: http://localhost:8080 and edit json data for get token (set sku of project, user id, etc.)
Payment process:
- as server: create a token by your json data
- as client: open payment page with your token
- as server: receive a webhook for validate user
- as client: make a payment
- as server: receive a webhook of payment result and provide a customer with a product
Differences:
- server side: you keep your projectId, ApiKey on server side + generate json for payments on your server.
- client side: authorization user on client side + generate json for payments on client side.
In your Xsolla Publisher Account -> your project -> Login -> New login project Or open the page: https://publisher.xsolla.com/<YOUR_MERCHANT>/projects/<YOUR_PROJECT>/login
And copy your Login ID to .env
And open http://localhost:8080/client-side.php
Payment process:
- as client: push button "Auth" -> login -> for get auth token (field "User token" will be filled)
- as game-client: generate json data for payment -> redirect client to payment page
- server: receive a webhook for validate user
- as client: make a payment
- server: receive a webhook of payment result and provide a customer with a product