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

Card data encryption

Description of the pg_encrypted_card parameter of POST /g2g/payment.
This parameter contains encrypted card data packaged in JWE format.
Encryption is performed using a hybrid approach:
card data (PAN, expiration date, CVV2, message creation timestamp) is encrypted using AES-256-GCM;
the generated symmetric key (CEK) is encrypted using RSA-OAEP-256 (SHA-256) with the partner’s public key.
The result is encoded in Base64URL and transmitted as a single encrypted container.

Encryption requirements#

CategoryParameterRequirementDescription
GeneralEncryption MethodUse Hybrid Encryption (Symmetric + Asymmetric)Combines symmetric encryption for payload protection with asymmetric encryption for secure key exchange.
Payload EncryptionAlgorithmUse AES-256-GCMProvides confidentiality and integrity via authenticated encryption.
Payload EncryptionContent Encryption Key (CEK)Must be 256 bits and generated using CSPRNGSymmetric key used for payload encryption.
Payload EncryptionInitialization Vector (IV)Must be 96 bits (12 bytes), generated using CSPRNG and must be unique per encryptionNonce required for AES-GCM to ensure security and prevent reuse attacks.
Payload EncryptionAuthentication TagMust be 128 bits and generated during AES-GCM encryptionEnsures integrity and authenticity of encrypted data.
Key EncryptionAlgorithmUse RSA-OAEP-256Asymmetric encryption of CEK using OAEP padding with SHA-256.
Key EncryptionPublic KeyUse recipient’s RSA public keyUsed to encrypt the CEK.
Key EncryptionRSA Key LengthMust be ≥ 2048 bitsEnsures sufficient cryptographic strength.
EncodingEncoding SchemeUse Base64URL (without padding)URL-safe encoding for binary data (header, encrypted key, IV, ciphertext, authentication tag).

Encryption process (for sending data)#

Step 1. Prepare payload#

{
  "pan": "1234567890123456",
  "expDate": "202802",
  "cvv2": "123",
  "timestamp": "20260318123045"
}

Step 2. Generate CEK#

Generate a random 256-bit key using CSPRNG.

Step 3. Generate IV#

Generate 12-byte IV using CSPRNG.
Must be unique per encryption.

Step 4. Prepare header#

{
  "alg": "RSA-OAEP-256",
  "enc": "A256GCM",
  "kid": "<key identifier>"
}

Step 5. Encrypt payload (AES-256-GCM)#

Inputs: CEK, IV, Payload.
Outputs: ciphertext and authentication tag.

Step 6. Encrypt CEK (RSA-OAEP-256)#

Encrypt CEK using recipient’s public key.
Output: encrypted_key.

Step 7. Encode components#

Base64URL encode: header, encrypted_key, IV, ciphertext, authentication tag.

Step 8. Build encrypted container#

After all components are generated, the encrypted container must be constructed according to JSON Web Encryption (JWE) RFC 7516 using Compact Serialization:
BASE64URL(Protected Header) .
BASE64URL(Encrypted Key) .
BASE64URL(IV) .
BASE64URL(Ciphertext) .
BASE64URL(Authentication Tag)
The serialization order is strictly defined by the JWE specification and must be preserved.
Example:
eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIiwia2lkIjoiNzYxYSJ9
.
OKOawDo13gRp2ojaHV7LFp...
.
48V1_ALb6US04U3b
.
5eym8TW_c8SuK0ltJ3rpYIzO...
.
XFBoMYUZodetZdvTiFvSkQ

Decryption process (for receiving data)#

Step 1. Split encrypted container#

The input parameter pg_encrypted_card must be a JWE Compact Serialization string compliant with JSON Web Encryption (JWE) RFC 7516.
Split into exactly 5 parts using the . (dot) separator:
<protected_header> .
<encrypted_key> .
<iv> .
<ciphertext> .
<authentication_tag>
Output components: after splitting, the following components are obtained:
ComponentDescription
Protected HeaderBase64URL-encoded JSON containing metadata about encryption algorithms and key identifier.
Encrypted KeyBase64URL-encoded CEK encrypted using RSA-OAEP-256.
Initialization Vector (IV)Base64URL-encoded 96-bit nonce used in AES-GCM.
CiphertextBase64URL-encoded encrypted payload.
Authentication TagBase64URL-encoded integrity/authentication tag generated by AES-GCM.

Step 2. Base64URL decode#

Each component must be decoded from Base64URL encoding to its original binary form:
protected_header → JSON (UTF-8);
encrypted_key → binary (RSA-encrypted CEK);
iv → binary (12 bytes);
ciphertext → binary;
authentication_tag → binary (16 bytes).

Step 3. Parse and validate protected header#

The protected header must be parsed as JSON:
{
  "alg": "RSA-OAEP-256",
  "enc": "A256GCM",
  "kid": "<key identifier>"
}
Extracted parameters:
FieldDescription
algKey encryption algorithm (RSA-OAEP-256).
encContent encryption algorithm (A256GCM).
kidKey identifier used to select the correct decryption key.
If validation fails, processing will be terminated.

Step 4. Decrypt CEK (Content Encryption Key)#

The encrypted_key must be decrypted using:
Algorithm: RSA-OAEP-256;
Hash function: SHA-256;
Key: recipient’s private RSA key (selected via kid).
Output: original CEK (256-bit AES key).

Step 5. Decrypt payload (AES-256-GCM)#

The payload will be decrypted using:
Algorithm: AES-256-GCM;
Inputs: CEK, IV, ciphertext, authentication_tag.
Output: decrypted payload (JSON).
If verification fails, the message will be rejected and will not be processed further.

Step 6. Parse decrypted payload#

The decrypted payload will be parsed as JSON:
{
  "pan": "1234567890123456",
  "expDate": "202802",
  "cvv2": "123",
  "timestamp": "YYYYMMDDHHMMSS"
}
Previous
Overview
Next
Overview