2017 © Pedro Peláez
 

library xsolla-sdk-php

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

image

xsolla/xsolla-sdk-php

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

  • Wednesday, June 6, 2018
  • by xsolla
  • Repository
  • 12 Watchers
  • 24 Stars
  • 49,510 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 18 Forks
  • 2 Open issues
  • 24 Versions
  • 19 % Grown

The README.md

Xsolla SDK for PHP

Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality Downloads Join the chat at https://gitter.im/xsolla/xsolla-sdk-php GitHub license, (*1)

An official PHP SDK for interacting with Xsolla API, (*2)

Payment UI screenshot, (*3)

This SDK can be used for: * obtaining an authorization token * processing of basic webhooks (user_validation, payment, refund, etc.), (*4)

Features

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

Requirements

  • PHP ^7.3 or ^8.0
  • The following PHP extensions are required:
    • curl
    • json

Getting Started

Please register your Publisher Account and create the project. In order to use the PHP SDK Library you'll need: * MERCHANT_ID * API_KEY * PROJECT_ID * PROJECT_KEY, (*5)

You can obtain these parameters using the information in your Company Profile and Project Settings., (*6)

Installation

Installing via Composer

The recommended way to install Xsolla SDK for PHP is through Composer., (*7)

``` bash $ cd /path/to/your/project $ composer require xsolla/xsolla-sdk-php, (*8)


After installing, you need to require Composer's autoloader: ```php require '/path/to/vendor/autoload.php';

Installing via Phar

You can download the packaged phar and include it in your scripts to get started:, (*9)

``` php require '/path/to/xsolla.phar';, (*10)


### Installing via Zip You can [download the zip file](https://github.com/xsolla/xsolla-sdk-php/releases), unzip it into your project to a location of your choosing, and include the autoloader: ``` php require '/path/to/xsolla-autoloader.php';

Quick Examples

Receive webhooks

There is a build in server class to help you to handle the webhooks., (*11)

Solution with webhook server:, (*12)

<?php

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

$callback = function (Message $message) {
    switch ($message->getNotificationType()) {
        case NotificationTypeDictionary::USER_VALIDATION:
            /** @var Xsolla\SDK\Webhook\Message\UserValidationMessage $message */
            // TODO if user not found, you should throw Xsolla\SDK\Exception\Webhook\InvalidUserException
            break;
        case NotificationTypeDictionary::PAYMENT:
            /** @var Xsolla\SDK\Webhook\Message\PaymentMessage $message */
            // TODO if the payment delivery fails for some reason, you should throw Xsolla\SDK\Exception\Webhook\XsollaWebhookException
            break;
        case NotificationTypeDictionary::REFUND:
            /** @var Xsolla\SDK\Webhook\Message\RefundMessage $message */
            // TODO if you cannot handle the refund, you should throw Xsolla\SDK\Exception\Webhook\XsollaWebhookException
            break;
        default:
            throw new XsollaWebhookException('Notification type not implemented');
    }
};

$webhookServer = WebhookServer::create($callback, PROJECT_KEY);
$webhookServer->start();

Solution with just helper classes in some php function:, (*13)


public function handleRequest() { $request = Request::createFromGlobals(); $message = Message::fromArray($request->toArray()); switch ($message->getNotificationType()) { case NotificationTypeDictionary::USER_VALIDATION: /** * https://developers.xsolla.com/webhooks/operation/user-validation/ * @var Xsolla\SDK\Webhook\Message\UserValidationMessage $message */ if ($message->getUserId() !== 'our_user_id') { return YourResponseClass(json_encode(['error' => ['code' => 'INVALID_USER', 'message' => 'Invalid user']]), 400); } break; case NotificationTypeDictionary::PAYMENT: /** @var Xsolla\SDK\Webhook\Message\PaymentMessage $message */ break; case NotificationTypeDictionary::REFUND: /** @var Xsolla\SDK\Webhook\Message\RefundMessage $message */ break; default: throw new \Exception('Notification type not implemented'); } return YourResponseClass('', 200); }

Once you've finished the handling of notifications on your server, please set up the URL that will receive all webhook notifications on the Settings page for your project., (*14)

Troubleshooting

You can find solutions for the most frequently encountered errors in our documentation., (*15)

Contributing

Please take a look at the CONTRIBUTING.md to see how to get your changes merged in., (*16)

Additional resources

The Versions

06/06 2018

dev-master

9999999-dev http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

06/06 2018

dev-AnastasiaTW-patch-2

dev-AnastasiaTW-patch-2 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

06/06 2018

dev-AnastasiaTW-patch-1

dev-AnastasiaTW-patch-1 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

21/07 2017

v2.6.2

2.6.2.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

26/10 2016

v2.6.1

2.6.1.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

31/05 2016

v2.6.0

2.6.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

18/05 2016

v2.5.0

2.5.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

11/05 2016

v2.4.1

2.4.1.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

27/04 2016

v2.4.0

2.4.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

03/02 2016

v2.3.0

2.3.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

13/01 2016

v2.2.0

2.2.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

28/09 2015

v2.1.0

2.1.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

10/08 2015

v2.0.0

2.0.0.0 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

27/07 2015

v2.0.0-BETA1

2.0.0.0-beta1 http://xsolla.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api payment sdk games xsolla

05/08 2014

v1.1.1

1.1.1.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

28/07 2014

v1.1.0

1.1.0.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

18/07 2014

v1.0.7

1.0.7.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

17/07 2014

v1.0.6

1.0.6.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

10/06 2014

v1.0.5

1.0.5.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

04/06 2014

v1.0.4

1.0.4.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

22/04 2014

v1.0.3

1.0.3.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

27/02 2014

v1.0.2

1.0.2.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

25/02 2014

v1.0.1

1.0.1.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla

21/02 2014

v1.0.0

1.0.0.0 http://xsolla.github.io

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by xsolla developers

api payment sdk games xsolla