All articles

Bangladesh Payment gateway

bKash Payment Gateway Flutter Integration: Secure Checkout for bKash, Nagad, Rocket & More in Your App

2 December 20266 min read

bKash Payment Gateway Flutter Integration: Secure Checkout for bKash, Nagad, Rocket & More in Your App

If you are building a mobile app with Flutter and searching for bKash payment gateway Flutter integration, you are probably facing the same question every Bangladeshi app team hits sooner or later: how do you let users pay with bKash inside a cross-platform app without putting secret keys on the phone or trusting a payment status that can be faked? This guide walks through the right architecture, the Flutter packages you will typically use, the security checks that matter, and how to add Nagad, Rocket, Upay, Cellfin and internet banking through one integration with KarentPay.

How a bKash Payment Gateway Works in a Flutter App

The most important rule is simple: your Flutter app should never talk to the payment gateway with secret credentials. A compiled APK or IPA can be decompiled, so anything inside it should be treated as public. Instead, a payment in a Flutter app follows a client–server pattern:

  1. The app asks your backend to start a payment. It sends only the order or cart ID, never the final price as the source of truth.
  2. Your backend creates the payment. Your server (Laravel, Node.js, Django, Firebase Cloud Functions or similar) calculates the amount, calls the gateway with your secret keys, and receives a payment ID and a hosted checkout URL.
  3. The app opens the checkout. Flutter shows the hosted bKash (or multi-wallet) page in a WebView or the system browser, where the customer enters their wallet number, OTP and PIN.
  4. The customer returns to the app. The gateway redirects to your callback URL, which your app detects.
  5. Your backend verifies the payment. The server queries the gateway, checks the status, amount and order ID, and only then marks the order paid. The app simply asks the backend, "Is order #1234 paid?"

Flutter Packages You Will Typically Use

You do not need a special "bKash SDK" to build a clean checkout. Most Flutter payment flows are built from well-known, general-purpose packages:

  • http or dio – to call your own backend's /checkout and /order-status endpoints.
  • webview_flutter – to load the hosted checkout inside the app and watch navigation events for your callback URL.
  • url_launcher – an alternative that opens the checkout in the device browser or an in-app browser tab.
  • app_links (or a similar deep-link package) – to bring the user back into the app after paying in an external browser.
  • flutter_secure_storage – for the user's session token to your backend (not for gateway secrets, which stay on the server).

WebView or external browser?

A WebView keeps users inside your app and lets you intercept the callback URL with a navigation delegate, which feels seamless. An external browser or custom tab can feel more trustworthy to some users and avoids certain WebView quirks, but you need deep links to return to the app. Many teams start with a WebView and fall back to the browser if a wallet page does not render correctly. Whichever you pick, test on real Android and iOS devices, including low-end phones on mobile data.

Step-by-Step: bKash Checkout Flow in Flutter

  1. Create the order screen. Show items and total, but let the server recalculate the total.
  2. Call your backend. On "Pay with bKash", send a POST to your server with the order ID. Show a loading indicator and disable the button to prevent double taps.
  3. Open the checkout URL. Push a WebView screen with the URL your backend returns.
  4. Intercept the callback. In the WebView's navigation handler, when the URL starts with your callback domain, close the WebView instead of loading the page.
  5. Poll your backend for the final status. Call /order-status a few times with short delays; your server performs the real verification with the gateway.
  6. Show the result. Display success, failure or "pending" with a clear retry option. Never show "Payment successful" based only on the callback URL.

Exact endpoint names, request fields and callback parameters depend on the gateway. Always follow the provider's official documentation; for KarentPay, the developer documentation is at karentpay.com/documentations.

Security Checklist for Flutter Payment Integration

  • No API keys in Dart code – not in constants, not in .env files bundled with the app.
  • Server-side amount – the backend decides the price; the app only references the order.
  • Server-side verification – check status, amount, currency (BDT) and order ID before fulfilling.
  • Idempotent fulfilment – a callback or webhook may arrive twice; only update orders that are still pending.
  • HTTPS only – both for your API and for callback URLs.
  • Handle app kills – if the user closes the app mid-payment, re-check pending orders when the app resumes.
  • Mask logs – never log wallet numbers, OTPs or PINs in crash reports or analytics.

Beyond bKash: One Integration for Every Wallet

Users in Bangladesh do not all pay the same way. If your Flutter app supports only bKash, customers who prefer Nagad, Rocket or their bank's internet banking may abandon checkout. Building and maintaining a separate integration for each wallet means more token handling, more callback logic and more reconciliation work for a small mobile team.

KarentPay is a Bangladeshi payment gateway designed to solve exactly this:

  • bKash, Nagad, Rocket, Upay, Cellfin, internet banking and multiple banks through one integration
  • A developer API that fits naturally behind any Flutter backend
  • Auto and manual transfer options, so you can choose how payments are confirmed
  • SSL-secured payment processing
  • A WooCommerce plugin (search "KarentPay" on WordPress.org) if your Flutter app shares a WordPress store backend

Your Flutter code stays the same: one "Pay" button, one WebView, one status check. The customer chooses their preferred wallet on the hosted page.

Frequently Asked Questions

Is there an official bKash Flutter SDK?

Most Flutter integrations do not need one. The standard approach is a hosted checkout opened in a WebView or browser, with your backend creating and verifying the payment through the gateway's API.

Can I call the bKash payment gateway API directly from Flutter?

You should not. Calling the gateway directly from the app would require embedding secret credentials in the app, which can be extracted. Always route payment creation and verification through your own server.

How do I add a payment gateway to a Flutter app in Bangladesh?

Choose a gateway, build two backend endpoints (create payment and check status), open the returned checkout URL in a WebView, detect the callback, and confirm the result from your server. With a multi-wallet gateway like KarentPay, the same flow covers bKash, Nagad, Rocket and banks.

Does this work for Flutter web too?

Yes, the same server-driven flow works; on the web you redirect the browser to the checkout URL instead of using a WebView.

Start Accepting Payments in Your Flutter App

A secure bKash payment gateway Flutter integration is mostly about architecture: keep secrets on the server, verify every payment, and give users the wallet they prefer. Ready to add bKash, Nagad, Rocket, Upay, Cellfin and internet banking to your app with one integration? Create your KarentPay merchant account at karentpay.com and read the developer docs to get started.






More guides and news

Payments in Bangladesh, explained for businesses.

All articles