1. Merchant 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
    • 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
    • Saved cards
      • Get saved cards
      • Save card
      • Save card for payouts
      • Delete saved card
      • Save card without a charge
    • 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. Merchant API

Overview

FreedomPay is a universal payment acceptance tool for businesses.
Each documentation script includes all the queries that can be executed to implement the chosen script.
You should read the Overview topic before start.
Call your manager, if you have any questions.
Attention!
Connection doesn't require a PCI DSS certificate

Request format#

HTTP method: POST or GET. Use POST: with GET all parameters, including the signature, are passed in the URL.
The response is XML in any request format, see «Response format and errors» below.
The request can be sent in any of these formats:
FormatHow to pass nested parameters (for example pg_receipt_positions)
application/x-www-form-urlencodedpg_receipt_positions[0][name]=value
multipart/form-datapg_receipt_positions[0][name]=value
application/jsonJSON array [{…}, {…}]
GET, parameters in the query stringpg_receipt_positions[0][name]=value
XML in the pg_xml parameter (application/x-www-form-urlencoded)use another format for requests with nested 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 a signature error.
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_description>Order #1001</pg_description>
  <pg_salt>a1b2c3d4</pg_salt>
  <pg_sig>…</pg_sig>
</request>

Signature#

Every request and every successful response is signed with pg_salt and pg_sig.
Check pg_sig of a response before using it.
Treat a response without pg_sig as an error: do not use it to confirm a payment or a payout.
To build pg_sig, concatenate with the separator ;:
1.
The script name — the last segment of the URL path, exactly as in the request URL: init_payment.php for {domain}/init_payment.php, init_payment for {domain}/init_payment.
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, including your own parameters without the pg_ prefix, also take part in the signature.
A parameter added to the request after the signature is calculated makes the signature invalid: the API returns a signature error.
Secret key. The merchant has two keys:
KeyMethods
Payment keyall methods except the ones below, see Payments
Payout keyreg2nonreg, reg2reg, to_iban, payment_status2, balance_status, see Payouts
Nested parameters (for example pg_receipt_positions) 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 script name and key: take all fields of <response> except pg_sig.

Example#

Request to {domain}/init_payment.php, secret key test_secret_key:
String to sign (parameters sorted by name: pg_amount, pg_currency, pg_description, pg_merchant_id, pg_order_id, pg_salt):
init_payment.php;100;KZT;Order #1001;12345;order_1001;a1b2c3d4;test_secret_key
pg_sig = MD5 of this string = b9ad75871668ca040f80f5f6b530e6ed

Python#

PHP#


Test cards and mobile phones#

Use these cards for payments in test mode (pg_testing_mode = 1).
Expiry date for all cards: 12/30.

Cards for purchase#

— the operation succeeds, — the payment system declines it with error 99999.
Card number3DSPayment and card savingCaptureCancel before captureRefund
4716047261941981No
4916307416334310Yes
4939770956154989No
5367654276102126Yes
5555555555555599No
4400444400004444Yes
6224466455690681278No
623275279933273424No
62528733472390953No
Capture is needed only for a two-step payment (pg_auto_clearing = 0). A one-step payment is captured right away with any card from the table.
Cancel before capture: cancelling a two-step payment that is not captured yet. Cancelling a captured payment is a refund: see the Refund column.
No Visa or Mastercard card supports every operation. To test capture and refund, use 4716047261941981. To test cancel before capture, use 4939770956154989. UnionPay cards support every operation.

Cards that decline the payment#

The payment is declined with the error code from the table.
Card numberError code
533521594536770399999
4916109830832246100066
554839868170014810009
547510293585361311036
555555555555555711024
444444444444442210001
444444441111111110022
444444449999999910018
548445813148283210004
There is no test card for errors 11008, 9014 and 8889 (3DS failed) that the payment page accepts.

Cards for payout#

Card numberResult
4671593866478252Success.
6204500338419360939Success.
629656013969216940Success.
62861819783765929Success.
5325349472901311Declined with error 10000.
4556046085041740Declined with error 10001.
5543974702876045Declined with error 11052.
5507841999732294Status process first, then success.
4532676596620704Status process first, then declined with error 10000.

Mobile phones#

CodeDescriptionOTP code
Kcell+77017777777111111
Activ+77027777777111111
Tele2+77037777777111111
Altel+77047777777111111

Response format and errors#

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 other statuses; see the method description.
On error: pg_error_code (numeric code) and pg_error_description (text).
Errors without a signature.
These responses may come without pg_salt and pg_sig:
pg_error_codeWhenWhat to do
9998pg_sig is missing or invalid, or pg_merchant_id is not found.Check the merchant ID, the script name, the parameters, the order of values and the secret key.
1100pg_merchant_id is not passed.Pass pg_merchant_id.
94031A required parameter is missing or a parameter has an invalid value.Check the parameters against the method description.
Methods also have their own codes, for example 11005 for an invalid amount; see the method description.
Example:
<?xml version="1.0" encoding="utf-8"?>
<response>
  <pg_status>error</pg_status>
  <pg_error_code>9998</pg_error_code>
  <pg_error_description>Некорректная подпись запроса</pg_error_description>
</response>
HTTP statuses.
HTTP statusBodyWhenWhat to do
200XML <response>Every API answer, including errors.Check pg_status; on error, see pg_error_code.
403, 404Not XML <response>, for example an HTML pageThe URL is wrong or the request was blocked before reaching the API.Check the host and the path.
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 with Get payment status before sending the request again.
For the full list of pg_error_code values, see Error codes.

Support#

If you found an inaccuracy or need help, feel free to reach out! 👋
Email: support@freedompay.kz
Previous
Refund payment
Next
Overview