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

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 payload is not included in the header value.
Header (all fields are required):
FieldValue
algHS256
auth_idYour API user ID.
uriPath of the called URL, for example /v5/g2g/create.
methodPOST
paramsEmpty string "".
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 123456):
Header:
{"uri":"/v5/g2g/create","auth_id":"123456","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:
eyJ1cmkiOiIvdjUvZzJnL2NyZWF0ZSIsImF1dGhfaWQiOiIxMjM0NTYiLCJtZXRob2QiOiJQT1NUIiwicGFyYW1zIjoiIiwiYWxnIjoiSFMyNTYifQ..gn0QR9q7rs21dA7rdgaA5XB5ACsHF6nX7dgf0jY5hrI

Errors#

HTTPBodyWhen
200payment with status: error and errorThe operation was rejected by business rules or by the bank (create, reverse, refund).
400{"status": "error", "error": {...}}Clearing rejected by business rules.
400{"error": {"code": "9400", ...}}The body is not valid JSON.
401{"error": {"code": "9998", ...}}Invalid signature.
422{"error": {"code": "9403", ...}}Validation error: a required header or field is missing or invalid.
500{"error": {"code": "9999" or "10000", ...}}Internal error. Repeat the request later with the same X-Request-Id.
Error codes of each method are listed in its responses.
Previous
Get payment status
Next
Create payment