Skip to main content

Encryption

Two Omniware APIs offer an encrypted variant where the request body is AES-256-encrypted before posting:

APIAlgorithmNotes
Encrypted Payment RequestAES-256-CBCRandom 16-byte IV, base64-encoded with the ciphertext.
Register MerchantAES-256-ECBNo IV. ECB is acceptable here only because every request body has unique content (PAN, contact details).

In both cases the api_key stays in plaintext alongside the encrypted blob so Omniware knows which encryption key to use to decrypt.

AES-256-CBC (Payment Request)

The plaintext is a JSON-serialised version of the normal Payment Request parameters (see Encrypted Payment Request for the exact shape).

function encryptData(string $plain_data, string $encryption_key): array
{
$iv = openssl_random_pseudo_bytes(16);
$encrypted = openssl_encrypt(
$plain_data,
'AES-256-CBC',
$encryption_key,
OPENSSL_RAW_DATA,
$iv
);
return [base64_encode($encrypted), base64_encode($iv)];
}

function decryptData(string $encrypted_data, string $decryption_key, string $iv): string
{
return openssl_decrypt(
base64_decode($encrypted_data),
'AES-256-CBC',
$decryption_key,
OPENSSL_RAW_DATA,
base64_decode($iv)
);
}

The post body has three fields: api_key, encrypted_data, and iv. The response on return_url follows the same shape — decrypt encrypted_data with your decryption_key and the iv Omniware returns.

AES-256-ECB (Register Merchant)

Used only for the Register Merchant endpoint. ECB requires no IV but has a known weakness for repeated plaintext blocks — it is acceptable here because merchant registration payloads always contain unique identifying fields.

function encryptECB(string $plain, string $key): string {
return base64_encode(openssl_encrypt($plain, 'AES-256-ECB', $key, OPENSSL_RAW_DATA));
}

Key handling rules

warning
  • encryption_key and decryption_key are server-side secrets. Never embed in browser JS, mobile binaries, or public repos.
  • Treat the random IV as ciphertext, not a secret — but never reuse an IV across two CBC requests with the same key.
  • Rotate keys via your Omniware relationship manager if you suspect compromise.