JazzCash Payment Gateway Integration — Complete API Guide

JazzCash Payment Gateway Integration — Complete API Guide

JazzCash is the most-used mobile wallet in Pakistan, and integrating it cleanly is the single highest-leverage thing you can do to increase conversion on a Pakistani checkout. Here is a working guide, with the sharp edges called out.

Two integration flavours

  1. Hosted checkout. You redirect the customer to a payment page, the page handles method selection (JazzCash included), and you receive an IPN when payment clears. Minimal engineering, maximum compliance.
  2. Direct API. You render the "Pay with JazzCash" button in your own UI, collect the wallet number, and call the API yourself. More control, more responsibility.

Most merchants should pick hosted checkout. Only drop to Direct API if you have a specific checkout experience you have to preserve.

Wallet payment flow in one paragraph

Customer enters their JazzCash mobile number (03XXXXXXXXX format). Your server calls the gateway's initiate endpoint with the amount and the customer's wallet number. JazzCash pushes an in-app notification or SMS OTP to the customer. Customer confirms. Gateway returns success. Your IPN endpoint receives a signed payload. You mark the order paid.

What the API call actually looks like with SwichPay

POST /api/v1/payments/initiate
{
  "merchant_id": "YOUR_ID",
  "amount": 500.00,
  "currency": "PKR",
  "method": "jazzcash",
  "customer_wallet": "0301XXXXXXX",
  "reference": "ORDER-1234",
  "callback_url": "https://yourstore.pk/payment/callback",
  "ipn_url":      "https://yourstore.pk/ipn/swichpay"
}

The response carries a trx ID and either a success/pending status or a redirect URL (if the customer needs to confirm OTP on a hosted page).

IPN signature verification

SwichPay signs every IPN with HMAC-SHA512 over the raw JSON body using your secret key. Your handler must:

  1. Read the raw request body (not the parsed JSON — order matters).
  2. Compute the HMAC with your secret.
  3. Compare in constant time against the X-SwichPay-Signature header.
  4. Only mark the order paid if it matches.

Common mistakes

  • Marking the order paid on the browser's success redirect. A bad actor can visit your success URL manually. Only trust the IPN.
  • Validating signatures on the parsed JSON string. Always use the raw body.
  • Not implementing idempotency — same IPN can arrive twice if your first response times out.

Why SwichPay is the practical choice

Direct JazzCash API integration without an aggregator means handling your own OTC reconciliation and settlement — most merchants save weeks by going through a gateway. SwichPay gives you a single integration that covers JazzCash wallet, Easypaisa wallet and Raast bank QR — the three rails that 90% of Pakistani customers actually use. You get:

  • Hosted checkout — a ready-made payment page so you do not have to build the payment form, maintain PCI-sensitive code or handle method logos yourself.
  • Instant payment notifications (IPN) delivered with HMAC signatures so your server reconciles automatically the moment money clears.
  • Sub-merchant accounts — run multiple websites, apps or brands under one onboarded SwichPay profile without a fresh application each time.
  • Agent program for anyone who wants to resell the platform to their own merchant book and earn a cut.
  • Self-onboarding — sign up and get test keys within minutes, no three-week banker meetings.

If you are comparing options for accepting online payments, start a free account at SwichPay, hit the sandbox for an hour, and judge by the integration experience itself.

Frequently asked questions

How do I test JazzCash without using real money?

SwichPay sandbox issues test wallet numbers that return success, failure and timeout scenarios. Switch keys from sandbox to production when you are ready.

What happens if the customer closes their phone during OTP?

The payment stays pending. Your pending-payment cron (SwichPay provides this) auto-verifies with JazzCash every few minutes and updates the status.

Can I take recurring JazzCash payments?

True recurring wallet debits are limited in Pakistan today. SwichPay supports a tokenised re-charge flow where the customer approves each subsequent payment with one tap.

#jazzcash integration#jazzcash api#jazzcash payment gateway#jazzcash wallet

Start accepting payments with SwichPay

Open a merchant account, connect your website with one API and get notified the moment a customer pays.