This repository offers an example of integrating Xsolla PayStation for payment processing using Maven, Java, Servlets, Tomcat, and Ngrok.
Ensure the following tools are installed on your system before proceeding:
Copy the .env.example file and rename it to .env:
cp .env.example .env
Update the .env file with the appropriate values. Your project ID is available in your Xsolla Publisher Account.
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
mvn clean install
The output xsolla-example.war file will be in the target directory.
It's crucial to remember that your project needs to be rebuilt whenever changes are made to the codebase or .env variables.
Run the project using Docker Compose:
It's crucial to remember that your Docker need to be rebuilt too after every project rebuilt.
docker-compose up --build
The application will be accessible at http://localhost:8080/xsolla-example/client-side.
Ngrok provides a public URL for accessing your local server. You can open the Ngrok dashboard at http://localhost:4040.
Copy the resulting URL and append /xsolla-example/webhook to it (for example, https://.ngrok-free.app/xsolla-example/webhook) and add it to the webhook settings of your project at https://publisher.xsolla.com/<YOUR_MERCHANT>/projects/<YOUR_PROJECT>/edit/webhooks/.
Create a product in your Xsolla Publisher Account. Navigate to your project > store > virtual items > add item, or open the page directly at https://publisher.xsolla.com/<YOUR_MERCHANT>/projects/<YOUR_PROJECT>/storefront/virtual-items.
Open the example UI at http://localhost:8080/xsolla-example/client-side.
Payment process:
- Client: Push button "Auth" -> login -> for get auth token (field "User token" will be filled)
- Game-client: Generate json data for payment -> received payment token -> redirect client to payment page
- Server: Receive a webhook for validate user
- Client: Make a payment
- Server: Receive a webhook of payment result and provide a customer with a product