1. Sync API
Freedom Pay
  • Overview
  • Gateway API
    • Overview
    • Sync API
      • Overview
      • Card data encryption
      • Payments
        • Overview
        • Pay by card
        • Pay by card: complete 3DS
        • Pay with Apple Pay
        • Pay with Google Pay
        • Pay by recurring profile
        • Create payment page
        • Create payment page with any amount
        • Capture payment (clearing)
        • Cancel payment
        • Refund payment
        • Get payment status
      • Payouts
        • Overview
        • Pay out to card
        • Pay out to IBAN
        • Get payout balance
        • Get payout status
      • Transfers
        • Overview
        • Transfer from card to card
        • Transfer from card to card: complete 3DS
        • Get exchange rates
        • Get transfer status
      • Saved cards
        • Overview
        • Save card
        • Save card: complete 3DS
        • List saved cards
        • Remove saved card
        • Pay by card token
        • Pay out to card token
        • Get payment status
    • Async API
      • Overview
      • Create
        • Create payment
        • Save card without a charge
      • Read
        • Get payment status
        • Get request result
      • Edit
        • Capture payment (clearing)
        • Cancel payment (reverse)
        • Refund payment
  • Merchant API
    • Overview
    • Payments
      • Overview
      • Checkout
      • Pay by saved card
        • Overview
        • Create payment
        • Confirm payment with CVC
        • Confirm payment without the client
      • Create payment
      • Create payment with a payment page template
      • Create payment in a payment frame
      • Create payment with any amount
      • Create recurring payment
      • Capture payment (clearing)
      • Cancel payment
      • Refund payment
      • Get payment status
    • Payouts
      • Overview
      • Create payout page
      • Pay out to saved card
      • Pay out to IBAN
      • Get payout status
      • Get payout balance
    • Saved cards
      • Get saved cards
      • Save card
      • Save card for payouts
      • Delete saved card
      • Save card without a charge
    • Mobile balance
      • Overview
      • Create mobile balance payment
      • Charge mobile balance
      • Get mobile balance payment status
      • Confirm payment with SMS code
      • Resend SMS code
    • Invoices
      • Overview
      • Recurring payments
        • Overview
        • Create recurring profile
        • Get recurring profile
        • Charge by recurring profile
        • Cancel recurring profile
        • Recurring profile notification
      • Tips
        • Overview
        • Create
      • Create invoice
      • Get invoice status
      • Get invoice details
      • Cancel invoice
      • Refund invoice
    • SDK
      • JS SDK
      • Merchant SDK
        • Android
        • iOS
        • Migration guide
    • CMS
      • Overview
      • Get Merchant ID and key
      • WordPress
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
        • Update
      • Tilda
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
      • InSales
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
      • Ecwid
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
      • Bitrix
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
      • PrestaShop
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
      • OpenCart
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
      • CS-Cart
        • Overview
        • Installation
        • Configuration
        • Test
        • Live payments
    • Installment
      • Overview
      • Status
        • Get application status
        • Application status notification
        • Change application status
      • Get partners
      • Create application
    • Callbacks
      • Overview
      • Result notify
      • Check request
      • Payout notify
      • Redirect back
  • Partner API
    • Overview
    • Rates
      • Overview
      • Rates
    • Products
      • Overview
      • Dictionaries
      • Add client with product
      • Client request status
      • Create terminal
      • Update terminal limits
      • Product request status
    • E-Money
      • Overview
      • Add
      • Owner identification
      • Info
      • Close
      • Block
      • Balance
      • Statement
      • Request Status
    • Device ID
      • Android SDK
      • iOS SDK
    • Implement SuperApp
      • Overview
      • Pay
      • Refund
      • Status
    • Account
      • Overview
      • Create payment
      • Payment status
      • Batch statuses
      • Statement
      • Statement status
      • Balance
      • Balance status
    • Invoices
      • Info
  1. Sync API

Overview

Introduction#

Gateway Sync API (API v3) processes a request and returns the result in the same response.
URL: {domain}/g2g/<method>, for example {domain}/g2g/payment.
HTTP method: POST only. GET requests are rejected with 405.
Every request and every response is signed: pg_salt + pg_sig (see below).

Request format#

The request body can be sent in any of these formats:
Content-TypeNested parameters (for example pg_receipt_positions)
application/jsonJSON array [{…}, {…}] or JSON object with keys "0", "1", …
application/x-www-form-urlencodedpg_receipt_positions[0][name]=value
multipart/form-datapg_receipt_positions[0][name]=value
XML in the pg_xml parameter (application/x-www-form-urlencoded)not supported: send only flat parameters
In JSON, pass all values as strings, for example "pg_amount": "100.50".
A JSON number is converted before the signature check (100.50 becomes 100.5), so a signature calculated from the original value does not match and the API returns 1100.
Exception: in status_v2, pass pg_payment_id as a number.
XML example (the pg_xml value):
<?xml version="1.0" encoding="utf-8"?>
<request>
  <pg_merchant_id>12345</pg_merchant_id>
  <pg_order_id>order_1001</pg_order_id>
  <pg_amount>100</pg_amount>
  <pg_salt>a1b2c3d4</pg_salt>
  <pg_sig>…</pg_sig>
</request>

Signature formation#

Check pg_sig of every response before using it.
Treat a response without pg_sig as an error: do not use it to confirm a payment, a payout or a transfer.
To build pg_sig, concatenate with the separator ;:
1.
The method name — the last segment of the URL path: payment, clearing, status_v2, p2p2nonreg and so on.
2.
The values of all request parameters except pg_sig, sorted by parameter name in alphabetical order. pg_salt (a random string of Latin letters and digits) takes part like any other parameter.
3.
The secret key of the merchant.
Calculate MD5 of the resulting string and pass it in pg_sig as 32 lowercase hexadecimal characters.
Any additional parameters sent in the request also take part in the signature.
Secret key. The merchant has two keys:
KeyMethods
Payment keyall methods except the ones below
Payout keyp2p2nonreg, to_iban, reg2reg, payout_status2, balance_status
Nested parameters (JSON and form formats): see «Example with nested parameters» below. Use the code below: it handles nesting.
Response signature is calculated by the same rules with the same method name and key: take all fields of <response> except pg_sig.

Example#

Request to {domain}/g2g/payment, secret key test_secret_key:
{
  "pg_merchant_id": "12345",
  "pg_order_id": "order_1001",
  "pg_amount": "100",
  "pg_currency": "KZT",
  "pg_description": "Order #1001",
  "pg_card_name": "IVAN IVANOV",
  "pg_card_pan": "4716047261941981",
  "pg_card_cvc": "123",
  "pg_card_month": "12",
  "pg_card_year": "30",
  "pg_user_phone": "77777777777",
  "pg_user_email": "user@example.com",
  "pg_salt": "a1b2c3d4",
  "pg_sig": "b7ccbf6b20dc8125c70aa4e21617a2c0"
}
String to sign (parameters sorted by name: pg_amount, pg_card_cvc, pg_card_month, pg_card_name, pg_card_pan, pg_card_year, pg_currency, pg_description, pg_merchant_id, pg_order_id, pg_salt, pg_user_email, pg_user_phone):
payment;100;123;12;IVAN IVANOV;4716047261941981;30;KZT;Order #1001;12345;order_1001;a1b2c3d4;user@example.com;77777777777;test_secret_key
pg_sig = MD5 of this string = b7ccbf6b20dc8125c70aa4e21617a2c0

Example with nested parameters#

Request to {domain}/g2g/payment with pg_receipt_positions = [{"count": "1", "name": "Book", "tax_type": "0", "price": "100"}] (card parameters are left out to keep the example short).
The nested values take the place of pg_receipt_positions in the sorted list, and are sorted by name among themselves: count, name, price, tax_type.
payment;100;KZT;Order #1001;12345;order_1001;1;Book;100;0;a1b2c3d4;test_secret_key
pg_sig = d3910f44a3a7e8695c702a17b0f71ef8

Python#

PHP#


Response format#

The response body is XML (Content-Type: text/xml) with the root element <response>.
pg_status — result of the request: ok or error. Some methods also return intermediate statuses; see the method description.
On error: pg_error_code (numeric code) and pg_error_description (text).
The response is signed with pg_salt and pg_sig by the same rules as the request: see «Signature formation».
pg_error_description is a text for people and may be in Russian: handle errors by pg_error_code.
Validation errors.
If a parameter is missing or has an invalid value, the API returns pg_status error with code 94031 (code 11005 for pg_amount).
The HTTP status is 200; the response is signed.
pg_error_description names the parameter.
Signature errors.
If pg_sig is missing or invalid, or pg_merchant_id is not found, the API returns code 1100.
These responses may come without pg_salt and pg_sig.
HTTP statuses.
HTTP statusBodyWhenWhat to do
200XML <response>Every API answer, including errors.Check pg_status; on error, see pg_error_code.
404text 404 page not foundThe method in the URL does not exist.Check the URL: {domain}/g2g/<method>.
405text 405 method not allowedThe HTTP method is not POST.Send the request with POST.
Any otherNot XML <response>The API did not return its answer: network, gateway or server failure.The result of the operation is unknown. Request the status by pg_order_id before sending the request again.
Status methods: Get payment status, Get payout status, Get transfer status.
For the full list of pg_error_code values, see Error codes.

Callbacks#

Payouts: the final result also comes to pg_post_link, see Payout notify.
Create payment page and Create payment page with any amount: the result comes to pg_result_url, see Result notify.
Other methods return the result in the response.
URLs, signature, retries and answers: see Callbacks Overview.
Previous
Overview
Next
Card data encryption