Skip to content
Mobile FlutterRazorpayTutorial

How to Integrate Razorpay in a Flutter App (2026 Guide)

A comprehensive, step-by-step technical guide to integrating the Razorpay SDK into your Flutter application, handling webhooks, and managing payment states.

DevXAI

TEAM DEVXAI

18 September 2026
· Share
Razorpay Flutter Integration Code snippet

Integrating Razorpay in Flutter

Accepting payments on mobile can be complex, but the razorpay_flutter package makes it relatively straightforward. In this guide, we'll walk through a robust implementation of Razorpay in a Flutter app.

Step 1: Install the Dependency

First, add the official package to your pubspec.yaml:

dependencies:
  razorpay_flutter: ^1.3.6

Step 2: Initialize the Razorpay Instance

You need to create an instance of Razorpay and attach event listeners for Success, Error, and External Wallet selections. It is best to do this in your initState.

late Razorpay _razorpay;

@override
void initState() {
  super.initState();
  _razorpay = Razorpay();
  _razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
  _razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
  _razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);
}

Step 3: Creating an Order (Backend)

Crucial Rule: Never generate the Razorpay Order ID on the client side. Your backend (Node.js, Supabase, Python, etc.) must call the Razorpay API to generate an order_id and return it to the Flutter app. This ensures the payment amount cannot be tampered with.

Step 4: Launching the Checkout

Once you have the order_id from your backend, you can launch the checkout UI.

var options = {
  'key': 'rzp_live_YOUR_KEY_HERE',
  'amount': 50000, // in paise
  'name': 'Acme Corp.',
  'order_id': 'order_IluGWxBm9U8zJ8',
  'prefill': {
    'contact': '9876543210',
    'email': 'user@example.com'
  }
};

try {
  _razorpay.open(options);
} catch (e) {
  print(e);
}

Step 5: Verifying the Signature

When _handlePaymentSuccess fires, it only means the client thinks the payment succeeded. You must send the payment_id and signature back to your server to cryptographically verify the transaction using your Razorpay Secret Key.

At DevXAI, we build secure, end-to-end payment flows for enterprise applications. If you're building a fintech or high-volume transactional app, ensuring your webhook architecture is resilient is just as important as the Flutter UI.

Topics

FlutterRazorpayTutorial
DevXAI

TEAM DEVXAI

Written and published by the engineering, product design, and AI systems team at DevXAI Technologies.

Found this useful?

Share it with your network.

Continue Reading

View All Articles