Earn with Paysera Do you create a libraries?


We will pay from 100 to 200 EUR for an accurate and working programming code. If you’d like to cooperate in the future and receive orders for maintenance of a specific system version, the code and your contact data will be published for open use.

Contact us via email to support@paysera.com

You can integrate Paysera system into your website by downloading our open source software library libwebtopay. The library can be used to check all the necessary security parameters of transferred and received data.

  • WebToPay for PHP (from GitHub).
    $ git clone https://github.com/paysera/lib-webtopay
  • WebToPay for .NET (from GitHub).
    $ git clone https://github.com/evp/webtopay-lib-dotnet

In the archive, select file libwebtopay/WebToPay.php. Other files are intended as tests, examples and explanations. The latest and the only version of libwebtopay/WebToPay.php file can be downloaded at: WebToPay.php.

Paysera system can also be integrated to your system using open code libraries made by third party:

  • Omnipay 2.x - payment processing library for PHP (from GitHub).
    $ git clone https://github.com/povils/omnipay-paysera.git
  • Omnipay 3.x - payment processing library for PHP (from GitHub).
    $ git clone https://github.com/semyonchetvertnyh/omnipay-paysera.git
Info libwebtopay can be used for both micro- and macro-services. You will simply have to call two methods, one of which prepares data for transfer, and the other one verifies the received response about the execution of a payment.

Below you will find a working example. Locations where your Paysera access data has to be entered are marked with comments.

1. Create a folder.

Create a folder, name it libwebtopay. Here, all the files related to payment integration will be stored.

2. Download libwebtopay library.

Download WebToPay.php file to the libwebtopay folder created.

3. Create a file that directs users to Paysera website.

In the libwebtopay folder, CREATE redirect.phpfile. The content of this file could be as follows:

<?php

require_once('WebToPay.php');

function get_self_url() {
    $s = substr(strtolower($_SERVER['SERVER_PROTOCOL']), 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'));

    if (count($_SERVER['HTTPS']) > 0) {
        $s .= ($_SERVER['HTTPS'] === 'on') ? 's' : '';
    }

    $s .= '://' . $_SERVER['HTTP_HOST'];

    if (count($_SERVER['SERVER_PORT']) > 0 && $_SERVER['SERVER_PORT'] !== '80') {
        $s .= ':' . $_SERVER['SERVER_PORT'];
    }

    $s .= dirname($_SERVER['SCRIPT_NAME']);

    return $s;
}

try {
    $self_url = get_self_url();

    $request = WebToPay::redirectToPayment([
        'projectid' => 0,
        'sign_password' => 'd41d8cd98f00b204e9800998ecf8427e',
        'orderid' => 0,
        'amount' => 1000,
        'currency' => 'EUR',
        'country' => 'LT',
        'accepturl' => $self_url . '/accept.php',
        'cancelurl' => $self_url . '/cancel.php',
        'callbackurl' => $self_url . '/callback.php',
        'test' => 0,
    ]);
} catch (WebToPayException $e) {
    // handle exception
}

Instead of WebToPay::redirectToPayment method, you can use WebToPay::buildRequest, which accepts the same parameters and returns the data array necessary for the transfer.

4. Create accept.php

In the libwebtopay folder, creat accept.php file. The contents of the file have to be as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title></title>
</head>
<body>
    Thank you for buying.
</body>
</html>

5. Create cancel.php

In the libwebtopay folder, CREATE cancel.php file. The contents of the file have to be as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title></title>
</head>
<body>
    Payment canceled.
</body>
</html>

6. Processing of payments.

In the libwebtopay folder, create callback.php file. The contents of the file have to be as follows:

<?php

require_once('WebToPay.php');

try {
    $response = WebToPay::checkResponse($_GET, [
        'projectid' => 0,
        'sign_password' => 'd41d8cd98f00b204e9800998ecf8427e',
    ]);

    if ($response['test'] !== '0') {
        throw new Exception('Testing, real payment was not made');
    }

    if ($response['type'] !== 'macro') {
        throw new Exception('Only macro payment callbacks are accepted');
    }

    $orderId = $response['orderid'];
    $amount = $response['amount'];
    $currency = $response['currency'];
    //@todo: check, if order with $orderId is already approved (callback can be repeated several times)
    //@todo: check, if order amount and currency matches $amount and $currency
    //@todo: confirm order

    echo 'OK';
} catch(Exception $e) {
    echo get_class($e) . ':' . $e->getMessage();
}
Info The transferred parameters are returned by WebToPay::checkResponse or WebToPay::validateAndParseData. The data itself is encrypted. Therefore, it usually cannot be taken from GET parameters.
Info In case of success, callback script must return the response beginning with or equal to “OK”.

Request parameters

Parameter
Length
Required
Description
projectid
11
Yes
Unique project number. Only activated projects can accept payments.
orderid
40
Yes
Order number from your system.
accepturl
255
Yes
Full address (URL), to which the client is directed after a successful payment.
cancelurl
255
Yes
Full address (URL), to which the client is directed after he clicks the link to return to the shop.
callbackurl
255
Yes
Full address (URL), to which a seller will get information about performed payment.

Script must return text "OK". Only then our system will register, that information about the payment has been received.

If there is no answer "OK", the message will be sent 4 times (when we get it, after an hour, after three hours and after 24 hours).
version
9
Yes
The version number of Paysera system specification (API).
lang
3
No
It is possible to indicate the user language (ISO 639-2/B: LIT, RUS, ENG, etc.). If Paysera does not support the selected language, the system will automatically choose a language according to the IP address or ENG language by default.
amount
11
No
Amount in cents the client has to pay.
currency
3
No
Payment currency (i.e USD, EUR, etc.) 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.
payment
20
No
Payment type. If provided, the payment will be made by the method specified (for example by using the specified bank). If not specified, the payer will be immediately provided with the payment types to choose from. You can get payment types in real time by using WebToPay library.
country
2
No
Payer's country (LT, EE, LV, GB, PL, DE). All possible types of payment in that country are immediately indicated to the payer, after selecting a country.
paytext
255*
No
Payment purpose visible when making the payment. If not specified, default text is used:
Payment for goods and services (for nb. [order_nr]) ([site_name]).

If you specify the payment purpose, it is necessary to include the following variables, which will be replaced with the appropriate values in the final purpose text:

[order_nr] - payment number.
[site_name] or [owner_name] - website address or company name.
p_firstname
255
No
Payer's name. Requested in the majority of payment methods. Necessary for certain payment methods.
p_lastname
255
No
Payer's surname. Requested in the majority of payment methods. Necessary for certain payment methods.
p_email
255
No
Payer's email address is necessary. If the email address is not received, the client will be requested to enter it. Paysera system will inform the payer about the payment status by this address.
p_street
255
No
Payer's address, to which goods will be sent (e.g.: Mėnulio g. 7 - 7). Necessary for certain payment methods.
p_city
255
No
Payer's city, to which goods will be sent (e.g.: Vilnius). Necessary for certain payment methods.
p_state
255
No
Payer's state code (necessary, when buying in USA). Necessary for certain payment methods.
p_zip
20
No
Payer's postal code. Lithuanian postal codes can be found here . Necessary for certain payment methods.
p_countrycode
20
No
Payer's country code. The list with country codes can be found here . Necessary for certain payment methods.
test
1
No
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: "Projects and Activities" -> "My projects" -> "Project settings" -> "Payment collection service settings" -> "Allow test payments" (check).
only_payments
0
No
Show only those payment methods that are separated by commas.
disallow_payments
0
No
Hide payment methods separated by comma.
time_limit
19
No
The parameter indicating the final date for payment; the date is given in “yyyy-mm-dd HH:MM:SS” format. The minimum value is 15 minutes from the current moment; the maximum value is 3 days. Note: works only with certain payment methods.
personcode
255
No
This parameter can be used for user authentication. If the user’s identification number is transferred, together with callback Paysera will return personcodestatus parameter, which will indicate whether the personal code corresponds to the transferred one.
developerid
11
No
In case you are labeled as a developer in our system, you have to transfer this parameter in your installed project (projects). The value of the parameter - your unique user number.
buyer_consent
1
No

Can be set to 0 or 1. If it is set to 1, the payer can skip the additional step where he needs to accept consent using PIS payment. If this parameter is used, additional text is required to be added to your page:

Buyer consent text in other languages provided below the table**

* Final length may vary depending on payment type specification

** Buyer consent text:

Callback

For more information on callbacks - see the chapter Callback .