1. Invoices
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
        POST
      • Get invoice status
        POST
      • Get invoice details
        POST
      • Cancel invoice
        POST
      • Refund invoice
        POST
    • 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. Invoices

Overview

Invoice API issues an invoice with a payment link: the client pays by the link in the Freedom SuperApp, with Bybit Pay or with Binance Pay.
Create an invoice: type sets how the client pays, the response contains the payment link url.
Follow the status with notifications to state_callback or with Get invoice status.
Sign every request with X-JWS-Signature: see «Signature».

Methods#

MethodWhat it does
Create invoiceCreates an invoice and returns the payment link.
Get invoice statusReturns the status of an invoice.
Get invoice detailsReturns the details of an invoice and its refunds.
Cancel invoiceCancels an unpaid invoice.
Refund invoiceRefunds a paid invoice fully or in parts.
Recurring payments are in development: the client confirms once, then you charge without the client. See Recurring payments.
Its methods use the headers, the signature and the errors described below.

Invoice statuses#

StatusMeaningFinal
newThe invoice is created and waits for the payment.No
processThe payment is in progress.No
successThe invoice is paid. Refunds do not change the status.Yes
errorThe payment failed.Yes
canceledThe invoice is cancelled with Cancel invoice.Yes
incompleteThe invoice expired: it was not paid before expires_at.Yes
The transitions between statuses: see Get invoice status.

Request headers#

HeaderRequiredValue
Content-TypeYesapplication/json.
X-JWS-SignatureYesRequest signature: see «Signature».
X-Request-IdYesRequest ID, UUID. Use a new value for every request.
X-DatetimeNoRequest date and time in UTC, format YYYY-MM-DDThh:mm:ssZ.

Response headers#

HeaderValue
X-Request-IdEquals X-Request-Id from the request.
X-Request-Statussuccess for HTTP 200 and 201, error for 400 and 500. Not returned for 401 and 422. It describes the request, not the invoice: check status in the body.
X-DatetimeResponse date and time, RFC 3339.

Errors#

HTTPBodyWhenWhat to do
200, 201Result of the methodThe request is processed.Check the status in the body.
400status = error, error_description; error_code for most errorsThe request is valid, but the operation is not possible, for example the invoice is not found or already paid.See «Errors» of the method.
401error_code = 9998The signature is invalid.Check the signature: see «Signature».
422error_code = 9403X-JWS-Signature is missing.Pass the signature.
500status = error, error_descriptionA field is missing or invalid: error_description names it. Also an internal error.Fix the request. If it is valid, repeat it later with a new X-Request-Id.

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/merchant/invoice/status.
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/merchant/invoice/status","auth_id":"12345","method":"POST","params":"","alg":"HS256"}
Body (sent exactly as shown, in one line):
{"id":"019d0652-4e2f-7f54-a179-007c80c48cef"}
X-JWS-Signature:
eyJ1cmkiOiIvdjUvbWVyY2hhbnQvaW52b2ljZS9zdGF0dXMiLCJhdXRoX2lkIjoiMTIzNDUiLCJtZXRob2QiOiJQT1NUIiwicGFyYW1zIjoiIiwiYWxnIjoiSFMyNTYifQ..Ntzsw75bc7exHPJSa3vEafIhyp6YsjpGULF98McbAFk

Python#

The code below produces the X-JWS-Signature of the example above.
verify_jws checks the signature of a notification: see «Notifications».

PHP#

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

Notifications#

If state_callback is passed in Create invoice, Freedom Pay sends a POST request to it when the invoice is paid, refunded, fails, is cancelled or expires.
The request body:
FieldTypeDescription
idstringInvoice ID.
external_idstringInvoice ID in the merchant system.
statusstringInvoice status: see Get invoice status. After a refund, the status stays success.
refund_idstring or nullID of the latest refund, or null if there are no refunds.
error_codenullReserved.
error_descriptionnullReserved.
{
    "id": "019d0652-4e2f-7f54-a179-007c80c48cef",
    "external_id": "order_1001",
    "status": "success",
    "refund_id": null,
    "error_code": null,
    "error_description": null
}
The request headers: Content-Type: application/json, X-Request-Id, X-Datetime and X-JWS-Signature.
X-JWS-Signature is built as in «Signature», with your API user ID and secret key; uri is the path of your state_callback URL.
Check the signature before you process the notification: verify_jws / verifyJws from «Signature», with the raw request body.
Answer with HTTP 2xx within 30 seconds.
Otherwise the notification is sent again: up to 3 attempts, 30 seconds apart.
The same notification can arrive more than once: process it by id and status. If in doubt, check the status with Get invoice status.
Previous
Resend SMS code
Next
Overview