1. Async 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. Async API

Overview

Introduction#

Gateway Async API (API v5) processes payments asynchronously: a request is accepted at once, the result is available later via a status request.
All requests: method POST, body application/json.
Each request is signed with X-JWS-Signature (see below).

URLs and methods#

The API has three URLs. The operation is selected by the X-Action header.
URLX-ActionMethod
{domain}/v5/g2g/creategateway.payment.createCreate payment
{domain}/v5/g2g/creategateway.card.zero_createSave card without a charge
{domain}/v5/g2g/readgateway.payment.statusGet payment status
{domain}/v5/g2g/readgateway.request.statusGet request result
{domain}/v5/g2g/editgateway.payment.clearingCapture payment (clearing)
{domain}/v5/g2g/editgateway.payment.reverseCancel payment (reverse)
{domain}/v5/g2g/editgateway.payment.refundRefund payment
If X-Action is missing or is not supported by the URL, the request is rejected: HTTP 422, code 9403.

Request headers#

HeaderRequiredDescription
Content-TypeyesAlways application/json.
X-ActionyesInvoked method, see the table above.
X-Request-IdyesUnique request ID (UUID). Use a new value for every new operation.
X-JWS-SignatureyesRequest signature.
AcceptnoThe response is always JSON.

Response headers#

HeaderDescription
X-Request-IdEquals X-Request-Id from the request.
X-Request-Statussuccess — the request is processed, check the body; process — the result is not ready yet, the body is empty ({}), repeat the request later; error — the request is rejected.
X-DatetimeResponse date and time.

Asynchronous processing#

Create payment, clearing, reverse and refund return status process (or process_clearing) at once. Get the final status via Get payment status.
A response can be empty {} with X-Request-Status: process: the data is being prepared, repeat the request in a few seconds.
If a response is lost, get it via Get request result with the X-Request-Id of that request.
A repeated request with the same X-Request-Id does not repeat the operation: the current state is returned.

X-JWS-Signature#

The signature is a detached JWS (RFC 7515, appendix F): BASE64URL(header) + .. + BASE64URL(signature). The body is not included in the header value.
Header (all fields are required):
FieldValue
uriPath of the called URL, for example /v5/g2g/create.
auth_idYour API user ID, as a string.
methodPOST
paramsEmpty string "".
algHS256
Signature: HMAC-SHA256 with your secret key over BASE64URL(header) + "." + BASE64URL(body).
BASE64URL — base64url without = padding.
Sign exactly the bytes of the body you send. Any change after signing (formatting, spaces, key order) makes the signature invalid: 401, code 9998.
Example (secret key test_secret_key):
Header:
{"uri":"/v5/g2g/create","auth_id":"12345","method":"POST","params":"","alg":"HS256"}
Body (sent exactly as shown, in one line):
{"amount":100.5,"currency":"KZT","description":"Order #1001","order_id":"order_1001","auto_clearing":false,"from":{"type":"card","card":{"name":"IVAN IVANOV","pan":"4716047261941981","cvc":"123","year":30,"month":12}}}
X-JWS-Signature:
eyJ1cmkiOiIvdjUvZzJnL2NyZWF0ZSIsImF1dGhfaWQiOiIxMjM0NSIsIm1ldGhvZCI6IlBPU1QiLCJwYXJhbXMiOiIiLCJhbGciOiJIUzI1NiJ9..C2PZJhx6UFJt6v--RJEtEydbqUKFFIi6gC3U69SbmLc

Python#

The code below produces the X-JWS-Signature of the example above.

PHP#

The code below produces the same X-JWS-Signature.

Errors#

HTTPBodyWhenWhat to do
200payment with status: error and errorThe operation was rejected by business rules or by the bank (create, reverse, refund).See error.code in the method description.
400{"status": "error", "error": {...}}Clearing rejected by business rules.See error.code in Capture payment (clearing).
400{"error": {"code": "9400", ...}}The body is not valid JSON.Send a valid JSON body.
401{"error": {"code": "9998", ...}}Invalid signature.Check the signature: see «X-JWS-Signature».
422{"error": {"code": "9403", ...}}Validation error: a required header or field is missing or invalid.Check the headers and the fields against the method description.
500{"error": {"code": "9999" or "10000", ...}}Internal error.Repeat the request later with the same X-Request-Id.
Any other, or no answer—The API did not return its answer: network, gateway or server failure.The result is unknown. Get it with Get request result by the X-Request-Id of that request.
Error codes of each method are listed in its responses.
Previous
Get payment status
Next
Create payment