Xsolla SDK for PHP. Xsolla is the authorized reseller and merchant providing e-commerce services for online games.

Installs: 3 755

Dependents: 0

Stars: 10

Watchers: 7

Forks: 6

Open Issues: 1

Language: PHP

v2.0.0-BETA1 2015-07-27 13:05 UTC


Latest Stable Version Build Status Scrutinizer Code Quality Join the chat at https://gitter.im/xsolla/xsolla-sdk-php GitHub license

An official PHP SDK for interacting with Xsolla API

Payment UI screenshot


  • Full customisation of Payment UI with the help of different methods of getting token.
  • Client for all API methods, making your integration easy and convenient. You can use it for setting up and updating virtual currency, items and subscription plans, for managing the users balance, for checking the finance information with the help of Report API and so on.
  • Convenient webhook server:
    • To start you need only one callback function.
    • All security checking already implemented: signature authentication and IP whitelisting.
    • Full customisation of notification processing logic, if standard server class doesn’t suit you.
  • SDK is built on Guzzle v3, and utilizes many of its features, including persistent connections, parallel requests, events and plugins (via Symfony2 EventDispatcher), service descriptions, over-the-wire logging, caching, flexible batching, and request retrying with truncated exponential back off.


  • PHP 5.3.9+
  • Your php.ini needs to have the date.timezone setting
  • The following PHP extensions are required:
    • curl
    • json


Installing via Composer

The recommended way to install Xsolla SDK for PHP is through Composer.

$ cd /path/to/your/project
$ composer require xsolla/xsolla-sdk-php

Installing via Phar

You can download the packaged phar and include it in your scripts to get started:

require '/path/to/xsolla.phar';

Installing via Zip

You can download the zip file, unzip it into your project to a location of your choosing, and include the autoloader:

require '/path/to/xsolla-autoloader.php';

Quick Examples

Integrate Payment UI

Generate Payment UI token:


use Xsolla\SDK\API\XsollaClient;

$client = XsollaClient::factory(array(
    'merchant_id' => MERCHANT_ID,
    'api_key' => 'API_KEY'
$paymentUIToken = $client->createCommonPaymentUIToken(PROJECT_ID, USER_ID);

Render Payment UI script in your page:

<head lang="en">
    <meta charset="UTF-8">
    <button data-xpaystation-widget-open>Test Button</button>

    <?php \Xsolla\SDK\API\PaymentUI\PaymentUIScriptRenderer::send($paymentUIToken); ?>

Receive webhooks


use Xsolla\SDK\Webhook\WebhookServer;
use Xsolla\SDK\Webhook\Message\Message;
use Xsolla\SDK\Exception\Webhook\XsollaWebhookException;

$callback = function (Message $message) {
    switch ($message->getNotificationType()) {
        case Message::USER_VALIDATION:
            //check user existence
        case Message::PAYMENT:
            //handle payment
        case Message::REFUND:
            //handle refund
            throw new XsollaWebhookException('Notification type not implemented');

$webhookServer = WebhookServer::create($callback, PROJECT_KEY); // https://merchant.xsolla.com/MERCHANT_ID/projects/PROJECT_ID/settings/connection

Additional resources