Integrating the JazzCash payment gateway is a well-trodden path, but the details decide whether your checkout is reliable or quietly loses orders. The two main routes are hosted checkout and the Direct API, and they suit different kinds of projects. Hosted checkout hands the payment step to a secure SwichPay page, while the Direct API keeps the whole flow inside your own website or app. This guide explains both flows step by step, shows how payment confirmation works in each, and helps you choose the right one for your project.
Before You Write Any Code
Every integration starts in the merchant dashboard, not in your editor. Register as a SwichPay merchant, complete KYC verification, and collect your API keys. Keep your secret key on the server only: it is used to sign requests and verify notifications, and it must never appear in front-end code, in a mobile app bundle, or in a public repository. A personal NTN is mandatory for a main merchant account, so make sure verification is complete before you plan a launch date.
Also decide where payment confirmations will land. Both integration routes report the final result to your server, and your server needs a notification URL ready to receive and verify those messages. Plan this endpoint early, because it is the part of the integration that determines whether orders are marked paid correctly.
Hosted Checkout Flow, Step by Step
Hosted checkout is the simpler route. Your website creates a payment and sends the customer to a secure SwichPay checkout page to complete it.
- Create the payment: your server sends the order amount, currency, and a unique order reference to SwichPay and receives a checkout URL in return.
- Redirect the customer: the customer is sent to the hosted checkout page, where they select JazzCash and approve the payment from their wallet.
- Receive the result: SwichPay sends a signed IPN to your notification URL with the payment status, and the customer is returned to your website.
- Verify and fulfil: your server verifies the IPN signature, matches the amount and reference to the order, and only then marks the order as paid.
Hosted checkout suits stores and services that want to launch quickly without building payment screens. The payment step runs on SwichPay’s secure page, so your site never handles wallet credentials, and the integration work is mostly the create-payment call and the notification handler.
Direct API Flow, Step by Step
The Direct API keeps the customer on your own pages. Your front end collects the payment choice, your server talks to SwichPay, and your interface shows the result.
- Create the payment: your server calls the API with the order details and receives the payment instructions for the JazzCash flow.
- Present the payment step: your website or app shows the customer how to approve the payment with their JazzCash wallet.
- Wait for confirmation: the customer approves in their wallet, and SwichPay sends a signed IPN to your notification URL.
- Verify and fulfil: as with hosted checkout, verify the HMAC-SHA256 signature, check the amount and reference, and then release the order.
The API route needs more work, but it gives you complete control over the experience, which matters for custom checkouts, mobile apps, and subscription flows. Full request and response details are in the SwichPay API documentation, and the broader integration picture is covered in our payment gateway API integration guide for Pakistan.
Hosted Checkout vs Direct API: How to Choose
- Choose hosted checkout when you want to launch fast, have no dedicated payment screens, or prefer the payment step to run on a secure gateway page.
- Choose the Direct API when you need the checkout inside your own design, are building a mobile app, or need fine control over subscription and booking flows.
- Either way, verify every IPN signature before trusting a payment, and never release an order based on a browser redirect alone.
Whichever route you pick, test the full journey before launch: a successful payment, a failed payment, and a customer who abandons the payment halfway. Each case should leave the order in the correct state, with no paid order that was never actually paid for.
Frequently Asked Questions
Which is easier to integrate: hosted checkout or the Direct API?
Hosted checkout is easier. You only build the payment creation call and the notification handler, while SwichPay hosts the payment page. The Direct API needs more work but gives you full control of the experience.
How do I confirm a JazzCash payment is real?
Verify the IPN that SwichPay sends to your server. Each notification carries an HMAC-SHA256 signature: recompute it with your secret key, and only trust the payment if the signatures match and the amount matches your order.
Can I switch from hosted checkout to the API later?
Yes. Both routes use the same merchant account and API keys, so you can start with hosted checkout and move to the Direct API when your checkout needs more control.
Start accepting payments with SwichPay
Open a merchant account, connect your website with one API and get notified the moment a customer pays.
