Home / Documentation / REST API v1.2

Developer API & Integration Reference

Complete engineering documentation for accepting online payments via JazzCash, Easypaisa, and Raast Instant QR, with automated IBFT disbursements and signed webhooks.

Base: https://mail.gofluxpay.com (Copy)
TLS 1.3 · HMAC-SHA256

Introduction & Dual Environments

Flux provides completely isolated Sandbox and Live environments to ensure risk-free development, testing, and production scaling.

DUAL ENV

The Flux Payment Platform provides unified rails for customer checkout and instant disbursements across Pakistan. All endpoints are secured over TLS 1.3 and require authenticated cryptographic credentials.

SANDBOX Test Environment (flx_test_*)

Simulate customer payments and payout executions without debiting real PKR funds. Pre-configured test numbers auto-approve to let you build end-to-end integration tests in minutes.

LIVE Production Rails (flx_live_*)

Direct clearing with State Bank of Pakistan Raast QR, 1LINK 1BILL, JazzCash and Easypaisa. Activated once your merchant business KYC review is approved.

Authentication & Scoped API Keys

Flux enforces strict separation of duties between Payment Collection (Payin) and Fund Withdrawals (Payouts).

SECURITY
1. Payin Collection Key (flx_live_* / flx_test_*)

Authorized exclusively for creating customer checkout sessions and polling transaction status (/api/v1/payments/*). This key cannot disburse funds.

Authorization: Bearer flx_live_xxxxxxxxxxxxxxxx
2. Disbursement Payout Key (flx_xak_* / flx_disb_*)

Authorized exclusively for bank title fetches and real-time fund withdrawals (/api/v1/payouts/*). Pass via header X-API-KEY or Bearer.

X-API-KEY: flx_xak_xxxxxxxxxxxxxxxx
Merchant Identity Enforcement: Always supply your public account identifier merchant_id (MID e.g. mrc_...) in API request payloads. Flux verifies server-side MID cryptographic ownership on every transaction.

Idempotency & Replay Defense

Network dropouts and timeouts can happen in distributed checkout. Pass a unique transaction reference in the Idempotency-Key header with every payment creation or disbursement request. If an identical request is received within 24 hours, Flux safely returns the original response without double charging the customer or duplicating bank debits.

Idempotency-Key: ORD-99281-UUID4-TOKEN

Hosted Checkout Experience (JazzCash · Easypaisa · Raast)

A unified, zero-redirect-friction checkout experience that lets buyers pay via digital wallet push or instant dynamic QR.

CHECKOUT FLOW

When you initialize a payment, Flux returns a secure checkout_url valid for 10 minutes. Redirect the customer to this URL. The hosted checkout provides:

  • JazzCash Mobile Account: Instant push notification or OTP sent to customer mobile device for 1-tap PIN approval.
  • Easypaisa Mobile Wallet: In-app push clearing with sub-second approval webhook.
  • Raast Dynamic QR (ISO 20022): Scannable directly through all major Pakistani banking apps (Meezan, HBL, Nayapay, SadaPay, MCB, Allied, Bank Alfalah).
  • Live 3-Second Return Transition: Instant receipt generation followed by an automated countdown returning the buyer to your return_url.
POST

Create Hosted Checkout Session

Initializes a customer checkout session and returns a secure hosted checkout URL.

POST https://mail.gofluxpay.com/api/v1/payments/create
curl -X POST https://mail.gofluxpay.com/api/v1/payments/create \
  -H "Authorization: Bearer flx_live_sample_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ORDER-1001-A" \
  -d '{
    "merchant_id": "mrc_sample_mid",
    "amount": 2500.00,
    "order_id": "ORDER-1001",
    "payer_email": "customer@example.com",
    "customer_name": "Tariq Khan",
    "return_url": "https://merchant.example/payment-result",
    "webhook_url": "https://merchant.example/webhooks/flux"
  }'

Request Body Parameters

Field Type Status Description
amount decimal Required Amount in PKR formatted with up to 2 decimal places. Min: 1.00. Example: 2500.00.
order_id string Required Your unique internal merchant order reference, invoice number, or cart token.
merchant_id string Required Your public merchant MID identifier (e.g., mrc_live_...).
return_url url Required The web URL where the customer is redirected once the payment completes, fails, or expires.
payer_email string Optional Customer email address for automated receipts and status notifications.
customer_name string Optional Customer full legal name to pre-fill on the hosted checkout sheet.
webhook_url url Optional Custom webhook destination URL for this specific transaction, overriding default account URL.

200 OK JSON Response

200 OK · application/json
{
  "success": true,
  "payment": {
    "payment_id": "flx_pay_8a1bc490",
    "order_id": "ORDER-1001",
    "status": "pending",
    "amount": "2500.00",
    "currency": "PKR",
    "expires_at": "2026-11-01 22:15:00",
    "checkout_url": "https://mail.gofluxpay.com/checkout/flx_pay_8a1bc490?token=sec_token_94812"
  }
}
GET

Payment Status Inquiry

Inquires the current authoritative server status of a customer checkout session.

GET https://mail.gofluxpay.com/api/v1/payments/status?payment_id=flx_pay_8a1bc490
200 OK · Verified Completed Response
{
  "success": true,
  "payment": {
    "payment_id": "flx_pay_8a1bc490",
    "order_id": "ORDER-1001",
    "status": "completed",
    "amount": "2500.00",
    "fee": "95.00",
    "method": "jazzcash",
    "payer_mobile": "0300****567",
    "paid_at": "2026-11-01 22:12:30"
  }
}
GET

Supported Banks & Digital Wallets

Fetches the active catalog of all supported Pakistani commercial banks, microfinance institutions, and digital wallets.

GET https://mail.gofluxpay.com/api/v1/payouts/banks

Account Title Verification (Name Fetch)

Verifies the legal account holder title with 1LINK or the target wallet provider prior to dispatching funds to prevent misdirected payouts.

POST https://mail.gofluxpay.com/api/v1/payouts/title-fetch
200 OK · Account Title Result
{
  "success": true,
  "data": {
    "account_title": "MUHAMMAD USMAN",
    "account_number": "0102030405060708",
    "bank_name": "Meezan Bank Limited"
  }
}

Execute Instant Payout

Distributes merchant float balance directly to a verified Pakistani bank account or digital wallet. Requires a dedicated Disbursement Key (flx_xak_*) passed via the X-API-KEY header.

POST https://mail.gofluxpay.com/api/v1/payouts/create
cURL · Instant Bank/Wallet Payout
curl -X POST https://mail.gofluxpay.com/api/v1/payouts/create \
  -H "X-API-KEY: flx_xak_your_payout_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: PO-REQ-1793704262" \
  -d '{
    "merchant_id": "mrc_your_merchant_mid",
    "amount": 5000.00,
    "account_number": "03001234567",
    "beneficiary_name": "Tariq Khan",
    "bank_name": "JazzCash",
    "type": "wallet"
  }'

Payout Status Inquiry

GET https://mail.gofluxpay.com/api/v1/payouts/status?payout_id=flx_po_78a1bc&merchant_id=mrc_your_merchant_mid
200 OK · Payout Status
{
  "success": true,
  "payout": {
    "payout_id": "flx_po_78a1bc",
    "status": "completed",
    "amount": "5000.00",
    "fee": "15.00",
    "bank_name": "JazzCash",
    "account_number": "0300****567",
    "beneficiary_name": "Tariq Khan",
    "reference_number": "FT263051928014",
    "completed_at": "2026-11-01 22:30:15"
  }
}
HMAC-SHA256

Cryptographically Signed Webhooks

Flux delivers real-time notifications via HTTP POST with an HMAC-SHA256 signature in the X-Flux-Signature header.

Supported Event Notifications: payment.completed · payment.failed · payment.expired · payout.completed · payout.failed · settlement.released

PHP Webhook Verification

PHP (hash_hmac)
<?php
$secret = 'flx_sec_live_9a2b8e4f1c';
$rawPayload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_FLUX_SIGNATURE'] ?? '';

$expectedSignature = hash_hmac('sha256', $rawPayload, $secret);

if (!hash_equals($expectedSignature, $signature)) {
    http_response_code(401);
    exit('Signature verification failed');
}

$event = json_decode($rawPayload, true);
if ($event['event'] === 'payment.completed') {
    $orderId = $event['data']['order_id'];
    $amount  = $event['data']['amount'];
    // Fulfill order in your internal database
}

http_response_code(200);
echo json_encode(['received' => true]);

Node.js Webhook Verification

Node.js (crypto.createHmac)
const crypto = require('crypto');

app.post('/webhooks/flux', (req, res) => {
  const secret = 'flx_sec_live_9a2b8e4f1c';
  const rawBody = req.rawBody || JSON.stringify(req.body);
  const signature = req.headers['x-flux-signature'];

  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');

  if (signature !== expectedSignature) {
    return res.status(401).send('Signature verification failed');
  }

  const event = req.body;
  if (event.event === 'payment.completed') {
    const { order_id, amount } = event.data;
    // Mark order as paid
  }

  res.status(200).json({ received: true });
});

Standardized Error Envelopes

Every non-2xx API response returns a uniform machine-readable JSON envelope with standard HTTP status codes.

JSON ERROR
Error Code HTTP Status Remediation & Description
unauthorized 401 Missing or invalid Bearer API key. Verify that key matches environment (flx_live_* vs flx_test_*).
invalid_amount 400 Payment amount must be greater than zero and formatted with 2 decimals (e.g. 1500.00).
insufficient_balance 422 Disbursement payout amount exceeds your available float balance. Top up float in Control Center.
idempotency_conflict 409 The Idempotency-Key was already used within 24 hours with different payload parameters.
rate_limit_exceeded 429 Request volume exceeded your configured rate threshold. Retry with exponential backoff.

WordPress & WooCommerce Plugin Guide

Official ready-to-use payment gateway plugin for WooCommerce stores in Pakistan.

PLUGIN

Accept JazzCash, Easypaisa, and Raast QR directly on your WooCommerce checkout page in under 5 minutes:

  1. Download Plugin: Download flux-pay-woocommerce.zip from your Merchant Dashboard.
  2. Upload & Activate: Go to WP Admin > Plugins > Add New > Upload Plugin and click Activate Plugin.
  3. Configure API Keys: Navigate to WooCommerce > Settings > Payments > Flux Gateway. Enter your Merchant Public ID (MID) and Production API Key.
  4. Configure Webhooks: Copy your auto-generated webhook callback URL into your Flux Webhooks Desk.

Shopify App & Custom Gateway Guide

Connect Flux Hosted Checkout to your Shopify store using the custom checkout app bridge.

APP

For Shopify merchants in Pakistan, Flux provides seamless off-site checkout redirect with automated order fulfillment callbacks:

  1. Install Custom Gateway: Add Flux Payments as a custom payment provider in your Shopify Partner Dashboard.
  2. API Credentials Handshake: Provide your Production API Key and Merchant Public ID in the Shopify app settings.
  3. Test Simulated Checkout: Perform a test checkout using Sandbox mode before switching to live payments.
START WITH FLUX

Your next payment.
A better experience.

Create your account, submit your business for review, and connect the payment methods your customers already know.

Hosted checkout Three local methods One workspace