When a user successfully transfers money and that money reaches your account, Paysera requests your indicated address callbackurl and transfers all required information about the performed payment.

Parameter callbackurl is the address of the script on your website, which informs Paysera system about the request on the successful payment. The answer is generated in the following way:

1. Create a folder.

Create a folder named libwebtopay. It will contain all files related to the payment integration.

2. Download libwebtopay library.

Download WebToPay.php file to the created folder libwebtopay.

3. Create a callback.php file.

Create a file named callback.php in the folder libwebtopay. The content of this file has to be:

<?php
require_once('libwebtopay/WebToPay.php');

try {
    $response = WebToPay::checkResponse($_GET, array(
            'sign_password' => 'paslaptis',

            // Path to file to which all requests will be logged
            // If you plan to use this feature, make sure that log file
            // is not accessible from outside.
            //'log'           => 'webtopay.log',
        ));

    echo 'OK Thank you for sending';
}
catch (Exception $e) {
    echo get_class($e).': '.$e->getMessage();
}

It is necessary to transfer all data received from Paysera to the method WebToPay::checkResponse. It is required for the check of data integrity. If there is no parameter at all, or values of parameters are not equal, then WebToPayException exception will be invoked.

Parameter Length Necessary Description
sign_password 32 Yes Project password. You can find it when logged in to Paysera system with your user. Choose "service management" and then press "general settings".

After checking $_GET data, if everything is correct, it is necessary to return the answer. An example is shown above (echo 'OK';). Possible variants of answers:

OK <text>
The text indicated after the keyword OK will be sent back as a responsive message.
Example: "OK Thank you for sending" (the responsive message will be: "Thank you for sending").
NOSMS
The sender will not receive any answer in this case. You will be able to send it later, in one week.
WAPPUSH <url> <text>
The system will send the answer to the sender by the Wap Push method.
Example: "WAPPUSH http://www.address.com/services/link service description".

4. Sending of the response message.

You can send the answer in one week with libwebtopay function, if you do not deliver it immediately through OK <text>:

<?php

// Incduding libwebtopay library
require_once('libwebtopay/WebToPay.php');

try {
    // Validating data of processed payment.
    WebToPay::smsAnswer(array(
            // Unique message number in our system. You got it by message.
            'id'            => 0,

            // Responsive message
            'msg'           => 'Thank you for sending',

            // Generated project password from paysera.com system.
            'sign_password' => 'secret',

            // Path to file to which all requests will be logged
            // If you plan to use this feature, make sure that log file
            // is not accessible from outside.
            //'log'           => 'webtopay.log',
        ));
}
catch (Exception $e) {
    echo get_class($e).': '.$e->getMessage();
}

When a user successfully transfers money and that money reaches your account, Paysera requests your indicated address callbackurl and transfers all required information about the performed payment.

To integrate the system for macro payments we recommend to use our prepared open source library - libwebtopay . The library allows to check and generate signatures, parse parameters and create requests.

For libwebtopay to work successfully, file libwebtopay/WebToPay.php from archives is enough. Other files are meant for tests, examples and explanations. You can download libwebtopay/WebToPay.php file 1.2 version here:

Attention: libwebtopay is suitable to use with both MicroPayments and MacroPayments.

Parameter callbackurl is the address of the script on your website, which informs Paysera system about the request on the successful payment. The answer is generated in the following way:

1. Create a folder.

Create a folder named libwebtopay. It will contain all files related to the payment integration.

2. Download libwebtopay library.

Download WebToPay.php file to the created folder libwebtopay.

3. Create a callback.php file.

Create a file named callback.php in the folder libwebtopay. The content of this file has to be:

<?php
require_once('WebToPay.php');

try {
    $response = WebToPay::checkResponse($_GET, array(
        'projectid' => 123,
        'sign_password' => 'secret',
    ));

    //@todo: check if $response['projectid'] matches your project ID
    //@todo: check if SMS with ID $response['id'] was not already confirmed in your system

    echo 'OK Thank you for sending';
}
catch (Exception $e) {
    echo get_class($e).': '.$e->getMessage();
}

After checking $_GET data, if everything is correct, it is necessary to return the answer. An example is shown above (echo 'OK';). Possible variants of answers:

OK <text>
The text indicated after the keyword OK will be sent back as a responsive message.
Example: "OK Thank you for sending" (the responsive message will be: "Thank you for sending").
NOSMS
The sender will not receive any answer in this case. You will be able to send it later, in one week.
WAPPUSH <url> <text>
The system will send the answer to the sender by the Wap Push method.
Example: "WAPPUSH http://www.address.com/services/link service description".

4. Sending of the responsive message.

You can send the answer in one week with libwebtopay function, if you do not deliver it immediately through OK <text>:

<?php

// Incduding libwebtopay library
require_once('WebToPay.php');

try {
    // Validating data of processed payment.
    WebToPay::smsAnswer(array(
        // Unique message number in our system. You got it by message.
        'id'            => 0,

        // Responsive message
        'msg'           => 'Thank you for sending',

        // Generated project password from paysera.com system.
        'sign_password' => 'secret',
    ));
}
catch (Exception $e) {
    echo get_class($e).': '.$e->getMessage();
}

Structure of the payment notification

Paysera sends the answer to your specified callbackurl. 3 additional GET parameters are added to the callbackurl:

  • data - encoded parameters from Paysera system. Same data coding algorythm is used as in generating a request for macro payments. To parse the parameters, 3 actions must be performed:
    1. Change the symbols "-" to "+", "_" to "/";
    2. Decode the string, using base64 encoding;
    3. Retrieve the array of parameters from the decoded string, which is an URL-encoded parameter string.
    Example in PHP language:
    $params = array();
    parse_str(base64_decode(strtr($_GET['data'], array('-' => '+', '_' => '/'))), $params);
    //use $params
  • ss1 - sign of data parameter, without using private-public key scheme. Sign algorithm:
    ss1 = md5(data + password)
  • ss2 - sign of data parameter, using RSA private-public key scheme with SHA-1 hashing function. Public Paysera key, which should be used to verify the signature, can be found at https://www.paysera.com/download/public.key

When you get the callback, you must check at least one signature before confirming the order. If there is a possibility, always (also) check the higher security ss2 signature.

Encoded parameters

Parameter Description
to A short number the message was sent to.
sms Content of the SMS message with keyword and subkeyword (up to 160 symbols).
from Mobile number the message was received from.
operator Name of the mobile operator ("Bitė", "TELE2", "Omnitel", "Orange", "LMT" and etc).
amount Price of the message in cents. For example, 100 (1 lt), 500 (5 lt) and etc.
currency Payment currency (USD, EUR) you want the client to pay in. If the selected currency cannot be accepted by a specific payment method, the system will convert it automatically to the acceptable currency, according to the currency rate of the day. Payamount and paycurrency answers will be sent to your website.
country Double-figure country code. (LT, EE, LV, UA, RU and etc)
id Unique message number in our system.
test The parameter, which allows to test the connection. The payment is not executed, but the result is returned immediately, as if the payment has been made. To test, it is necessary to activate the mode for a particular project by logging in and selecting: "Manage projects" -> "Payment gateway" (for a specific project) -> "Allow test payments" (check).
key Keyword
projectid Unique project number. Only activated projects can accept payments.
version A version number of Paysera system specification (API).