Rules for the formation of a request for payment

Required URLs for work depending on the model chosen:
To call the LiqPay API you need to pass the data and signature (Server-Server) parameters via the POST method or redirect the client (Client-Server) using the POST method, where:
data - json string with APIs parameters encoded by the function base64, base64_encode( json_string ),
signature - is the unique signature of each request base64_encode( sha1( private_key + data + private_key) ),
base64_encode - returns a string encoded by the base64,
sha1 - the hash is returned as a binary string of 20 characters.
Forming data and signature, example:
To connect the receiving of payment via LiqPay, forming json string with parameters api call, wherein:
Parameter Required Type Description
version Required Number Version of the API. For example: 3
public_key Required String Public_key - the identifier of the created company. For example: i00000000
private_key Required String Private key of the created company (not available to anyone except your developer). For example: a4825234f4bae72a0be04eafe9e8e2bada209255
action Required String Transaction type. Possible values: pay - payment, hold - amount of hold on sender's account, subscribe - regular payment, paydonate - donation, auth - card preauth
amount Required Number Payment amount. For example: 5, 7.34
currency Required String Payment currency. Possible values: USD, EUR, RUB, UAH, BYN, KZT. Additional currencies can be added by company's request.
description Required String Payment description.
order_id Required String Unique purchase ID in your shop. Maximum length is 255 symbols.
More parameters in the documentation
Example of creating json_string:
json_string = {"public_key":"i00000000","version":"3","action":"pay","amount":"3","currency":"UAH","description":"test","order_id":"000001"}
Example of coding json_string function base64_encode, the company receives data:
data = eyJwdWJsaWNfa2V5IjoiaTAwMDAwMDAwIiwidmVyc2lvbiI6IjMiLCJhY3Rpb24iOiJwYXkiLCJhbW91bnQiOiIzIiwiY3VycmVuY3kiOiJVQUgiLCJkZXNjcmlwdGlvbiI6InRlc3QiLCJvcmRlcl9pZCI6IjAwMDAwMSJ9
An example formation of signature, the company forms the string sign_string by concatenating private_key + data + private_key:
sign_string = a4825234f4bae72a0be04eafe9e8e2bada209255eyJwdWJsaWNfa2V5IjoiaTAwMDAwMDAwIiwidmVyc2lvbiI6IjMiLCJhY3Rpb24iOiJwYXkiLCJhbW91bnQiOiIzIiwiY3VycmVuY3kiOiJVQUgiLCJkZXNjcmlwdGlvbiI6InRlc3QiLCJvcmRlcl9pZCI6IjAwMDAwMSJ9a4825234f4bae72a0be04eafe9e8e2bada209255
After applying the functions base64_encode( sha1( sign_string) ) we get the string:
signature = wR+UZDC4jjeL/qUOvIsofIWpZh8=
Example of sending a request to LiqPay:
1. To redirect the client to the LiqPay payment page (Client - Server), you need to generate an HTML form:
<form method="POST" action="" accept-charset="utf-8">
 <input type="hidden" name="data" value="eyJwdWJsaWNfa2V5IjoiaTAwMDAwMDAwIiwidmVyc2lvbiI6IjMiLCJhY3Rpb24iOiJwYXkiLCJhbW91bnQiOiIzIiwiY3VycmVuY3kiOiJVQUgiLCJkZXNjcmlwdGlvbiI6InRlc3QiLCJvcmRlcl9pZCI6IjAwMDAwMSJ9"/>
 <input type="hidden" name="signature" value="wR+UZDC4jjeL/qUOvIsofIWpZh8="/>
 <input type="image" src="//"/>
2. For interaction (Server - Server), the received data and signature must be sent to the url
curl --silent -XPOST --data-urlencode
data="eyJwdWJsaWNfa2V5IjoiaTAwMDAwMDAwIiwidmVyc2lvbiI6IjMiLCJhY3Rpb24iOiJwYXkiLCJhbW91bnQiOiIzIiwiY3VycmVuY3kiOiJVQUgiLCJkZXNjcmlwdGlvbiI6InRlc3QiLCJvcmRlcl9pZCI6IjAwMDAwMSJ9" --data-urlencode
3. The status of the operation will be sent to server_url.
4. Successful completion of payment.