1. Sync API
Freedom Pay
  • Overview
  • Gateway API
    • Overview
    • Sync API
      • Overview
      • Card data encryption
      • Purchase
        • Overview
        • Pay by card
        • Pay by card: complete 3DS
        • Pay by recurring profile
        • Create payment page
        • Create payment page with any amount
        • Capture payment (clearing)
        • Cancel payment
        • Refund payment
        • Get payment status
      • Payout
        • Overview
        • Card
        • IBAN
        • Balance
        • Status
      • Transfer
        • Overview
        • Card
        • 3DSecure
        • Rates
        • Status
      • Card
        • Overview
        • Add
        • 3DSecure
        • List
        • Remove
        • Get payment status
      • Token
        • Overview
        • Token Pay
        • Apple Pay
        • Google Pay
        • Token Payout
        • Get payment status
    • Async API
      • Overview
      • Create
        • Create payment
      • Read
        • Get payment status
        • Get request result
      • Edit
        • Capture payment (clearing)
        • Cancel payment (reverse)
        • Refund payment
  • Merchant API
    • Overview
    • Purchase
      • Overview
      • Checkout
      • Card token
        • Overview
        • Tokenize card
        • Delete token
        • Card token list
        • Create payment (with CVC)
        • Confirm payment (with CVC)
        • Create payment
        • Confirm payment
      • Create payment
      • Any amount
      • Reccuring payment
      • Cancel payment
      • Clearing
      • Refund payment
      • Status
    • Payout
      • Overview
      • Card token
        • Tokenize card
        • Delete token
        • Card token list
        • Create payment
      • Create payment
      • IBAN
      • Balance status
      • Status
    • Mobile balance
      • Overview
      • Init
      • Pay
      • Approve
      • Resend code
      • Status
    • Invoice
      • Overview
      • Recurring profile
        • Overview
        • Create
        • Cancel
        • Info
        • Notify
      • Tips
        • Overview
        • Create
      • Create
      • Execute
      • Info
      • Refund
      • Status
      • Cancel
    • SDK
      • JS SDK
      • Merchant SDK
        • Google Pay
        • Android
        • IOS
    • 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
    • Installment
      • Overview
      • Status
        • Application Status
        • Application Callback Status
        • Application Change Status
      • Get partners
      • Create application
    • Redirect back
      POST
    • Result notify
      POST
    • Payout notify
      POST
    • Check request
      POST
  • Partner API
    • 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>

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. Check the signature before using the response.
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, the API returns code 1100.
If pg_merchant_id is not found, the API returns code 1101.
These responses may come without pg_salt and pg_sig.

Signature formation#

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) are expanded: each nested value takes part in the signature in the position of its parent parameter, nested values are ordered the same way. 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

Python#

PHP#

For the full list of pg_error_code values, see Error codes.
Previous
Overview
Next
Card data encryption