Custom Integration
This guide explains how to integrate the Paysera Checkout API with a custom implementation without using official libraries. Below you will find a detailed specification of the data that is sent and received.
If PHP (with the required version) is available on your server, we strongly recommend using the libwebtopay library to generate requests and process callbacks. It handles the encoding and signing steps described below for you.
Prerequisites​
Before you begin, ensure you have:
- Your
project_idandproject_passwordfrom Obtaining Credentials - Ability to make HTTP requests from your application
- Understanding of request signing and security
Payment Flow Overview​
- Create a signed payment request
- Redirect customer to Paysera payment page
- Customer completes payment
Understanding Request Structure​
Before implementing, it's important to understand how Paysera payment requests work. You send the data to https://www.paysera.com/pay/ using either the GET or POST method. There are always exactly two fields sent: data and sign.
Example URL:
https://www.paysera.com/pay/?data=YOUR_DATA_PARAMETER&sign=YOUR_SIGN_PARAMETER
Generating Request Fields (4 Steps)​
Step 1: Create URL-Encoded String​
Join all parameters into a URL-encoded string. For example:
// Input parameters
{
'param1': 'abc',
'param2': 'Some string with symbols %=&'
}
// Result after URL encoding
'param1=abc¶m2=Some+string+with+symbols+%25%3D%26'
In PHP, use http_build_query() function. In JavaScript, use URLSearchParams.
Step 2: Base64 Encode​
Encode the result string in base64 encoding:
// Input
'param1=abc¶m2=Some+string+with+symbols+%25%3D%26'
// After base64 encoding
'cGFyYW0xPWFiYyZwYXJhbTI9U29tZStzdHJpbmcrd2l0aCtzeW1ib2xzKyUyNSUzRCUyNg=='
In PHP, use base64_encode() function. In JavaScript, use Buffer.from().toString('base64').
Step 3: Make URL-Safe​
Replace "/" with "_" and "+" with "-" to make it URL-safe:
// Input
'MViDYlV7V0iHR2w2OkJjRFFpY11hizJDhk+EZjl/'
// After replacement
'MViDYlV7V0iHR2w2OkJjRFFpY11hizJDhk-EZjl_'
In PHP, use str_replace() or strtr() function.
Step 4: Generate Signature​
Create the sign parameter using MD5 hash:
sign = md5(data + password)
Where:
data- the encoded parameters from Step 3password- your project password