Skip to content


Repository files navigation

Siru Payment Gateway PHP SDK

Siru Payment Gateway Software development kit for PHP 7.1+.



  • PHP 7.1+
  • HTTP client supported by one of the transports or your own transport. Built-in transports support Guzzle, Symfony HTTP client and Wordpress HTTP API.


Easiest way to include the SDK is to use composer. Open a command console, enter your project directory and execute:

$ composer require sirumobile/siru-php-sdk:^1.0

or by adding the following lines to your composer.json file:

    "require": {
        "sirumobile/siru-php-sdk": "^1.0"


To get started, you need your merchantId and merchant secret. If you don't have your credentials, contact Siru Mobile to discuss which payment methods are available to you and we will send you your sandbox credentials.

Then go through our API documentation to learn more about each API and message payloads.


Here is a simple example on how to create new transaction and redirect user to Siru payment flow:

# web/checkout.php


 * Siru\Signature is used to sign outgoing messages and verify
 * responses from API. Replace $merchantId and $secret with your own credentials.
$signature = new \Siru\Signature($merchantId, $secret);

 * Siru\API is used to retrieve API specific classes and setting default values
 * for outgoing requests. It requires instance of Siru\Signature as parameter.
$api = new \Siru\API($signature);

// Select sandbox environment (default)

// You can set default values for all payment requests (not required)
  'variant' => 'variant4',
  'purchaseCountry' => 'GB'

// Create payment
try {

  $transaction = $api->getPaymentApi()
    ->set('basePrice', '5.00')
    ->set('redirectAfterSuccess', '')
    ->set('redirectAfterFailure', '')
    ->set('redirectAfterCancel', '')
    ->set('customerNumber', '0401234567')
    ->set('title', 'Concert ticket')
    ->set('description', 'Concert ticket to see an awesome band live')
  header('location: ' . $transaction['redirect']);

} catch(\Siru\Exception\TransportException $e) {
  echo "Unable to contact Payment API. Error was: " . $e->getMessage();

} catch(\Siru\Exception\ApiException $e) {
  echo "API request failed with error code " . $e->getCode() . ": " . $e->getMessage();
  foreach($e->getErrorStack() as $error) {
    echo $error . "<br />";

On your redirectAfter* URLs you will need to verify that user has actually arrived from Siru Mobile payment flow and all parameters are authentic:

# /web/checkout/success.php, failure.php or cancel.php
$signature = new \Siru\Signature($merchantId, $secret);

if(isset($_GET['siru_event']) == true) {
  if($signature->isNotificationAuthentic($_GET)) {
    // User was redirected from Siru payment page and query parameters are authentic

It is recommended that you also setup a callback URL using notifyAfterSuccess, notifyAfterFailure and notifyAfterCancel fields where Siru will automatically send notification when payment status changes. This allows you to complete the transaction even if user fails to return to your checkout page for example due to a network failure.

// /web/checkout/callback.php
$signature = new \Siru\Signature($merchantId, $secret);

$entityBody = file_get_contents('php://input');
$entityBodyAsJson = json_decode($entityBody, true);

if($signature->isNotificationAuthentic($entityBodyAsJson)) {
  // Notification was sent by Siru Mobile and is authentic

You can also use \Siru\Signature as standalone to create signature for your own code.

 * Imaginary example on calculating Signature without using \Siru\API.
$paymentRequestFields = [
  // ... required fields as described in API documentation.

$hash = $signature->createMessageSignature($paymentRequestFields, [], Signature::FILTER_EMPTY | Signature::SORT_FIELDS);
$paymentRequestFields['signature'] = $hash;
$paymentRequestJson = json_encode($paymentRequestFields);

// Send request using what ever HTTP
$response = $myHttpClient->send('', 'POST', $paymentRequestJson);

// Then you would check API response status, parse the JSON string in response body
// and redirect user to the payment page.

API documentation

API documentation is available here.