This repository provides an example of how to integrate Xsolla PayStation and handle payment processing with server-side validation using webhooks.
Before running this project, ensure you have the following installed:
- Docker
- Docker Compose
- Homebrew (for macOS users)
- Composer (for PHP package management)
- Ngrok (for exposing your local environment to the web)
First, create a .env
file from the provided .env.example
template:
cp .env.example .env
Next, fill in the necessary values in the .env file
If Ngrok is not installed, install it using Homebrew (macOS only):
brew install ngrok/ngrok/ngrok
Add your Ngrok authentication token to your default configuration file:
ngrok config add-authtoken {YOUR_NGROK_AUTH_TOKEN}
This will allow you to use Ngrok to expose your local environment publicly.
Next, install the required PHP packages inside the Docker container:
docker exec -it xsolla_example bash -c 'cd /app/xsolla-example ; composer install'
Build and start the project using Docker Compose:
docker-compose --env-file ./.env -f docker/docker-compose.yml down
docker-compose --env-file ./.env -f docker/docker-compose.yml up --build
The application will now be running on http://localhost:8080.
Start Ngrok to expose your local environment for webhook handling:
docker exec -it xsolla_example bash -c 'ngrok http 8080'
Ngrok will provide a publicly accessible URL. Copy the forwarding URL (e.g., https://.ngrok.io) to use with Xsolla webhooks.
Open your browser and navigate to: http://localhost:8080
To generate a new order, click on the Get token button. This will generate a token for your payment process.
Click on the generated payment URL to open the Xsolla PayStation UI.
Fill in the payment details in the UI and click the Pay button.
- Test card for payment details (https://developers.xsolla.com/solutions/payments/testing/test-cards/)
Once the payment is completed, send a webhook to your Ngrok URL to notify the payment result.
You should receive a response from the payment webhook handler confirming that the payment was successful.