Razorpay Flutter

Flutter plugin for Razorpay SDK.

Getting Started

This flutter plugin is a wrapper around our Android and iOS SDKs.

The following documentation is only focused on the wrapper around our native Android and iOS SDKs. To know more about our SDKs and how to link them within the projects, refer to the following documentation:

Android: https://razorpay.com/docs/checkout/android/

iOS: https://razorpay.com/docs/ios/

To know more about Razorpay payment flow and steps involved, read up here: https://razorpay.com/docs/


This plugin is available on Pub: https://pub.dev/packages/razorpay_flutter

Add this to dependencies in your app's pubspec.yml

razorpay_flutter: 1.1.0

Note for Android: Make sure that the minimum API level for your app is 19 or higher.

Note for iOS: Make sure that the minimum deployment target for your app is iOS 10.0 or higher. Also, don't forget to enable bitcode for your project.

Run flutter packages get in the root directory of your app.


Sample code to integrate can be found in example/lib/main.dart.

Import package

import 'package:razorpay_flutter/razorpay_flutter.dart';

Create Razorpay instance

_razorpay = Razorpay();

Attach event listeners

The plugin uses event-based communication, and emits events when payment fails or succeeds.

The event names are exposed via the constants EVENT_PAYMENT_SUCCESS, EVENT_PAYMENT_ERROR and EVENT_EXTERNAL_WALLET from the Razorpay class.

Use the on(String event, Function handler) method on the Razorpay instance to attach event listeners.

_razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
_razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
_razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);

The handlers would be defined somewhere as

void _handlePaymentSuccess(PaymentSuccessResponse response) {
  // Do something when payment succeeds

void _handlePaymentError(PaymentFailureResponse response) {
  // Do something when payment fails

void _handleExternalWallet(ExternalWalletResponse response) {
  // Do something when an external wallet was selected

To clear event listeners, use the clear method on the Razorpay instance.

_razorpay.clear(); // Removes all listeners

Setup options

var options = {
  'key': '<YOUR_KEY_HERE>',
  'amount': 100,
  'name': 'Acme Corp.',
  'description': 'Fine T-Shirt',
  'prefill': {
    'contact': '8888888888',
    'email': 'test@razorpay.com'

A detailed list of options can be found here.

Open Checkout




open(map<String, dynamic> options)

Open Razorpay Checkout.

The options map has key as a required property. All other properties are optional. For a complete list of options, please see the Checkout documentation.

on(String eventName, Function listener)

Register event listeners for payment events.


Clear all event listeners.

Error Codes

The error codes have been exposed as integers by the Razorpay class.

The error code is available as the code field of the PaymentFailureResponse instance passed to the callback.

Error CodeDescription
NETWORK_ERRORThere was a network error, for example loss of internet connectivity
INVALID_OPTIONSAn issue with options passed in Razorpay.open
PAYMENT_CANCELLEDUser cancelled the payment
TLS_ERRORDevice does not support TLS v1.1 or TLS v1.2
UNKNOWN_ERRORAn unknown error occurred.

Event names

The event names have also been exposed as Strings by the Razorpay class.

Event NameDescription
EVENT_PAYMENT_SUCCESSThe payment was successful.
EVENT_PAYMENT_ERRORThe payment was not successful.
EVENT_EXTERNAL_WALLETAn external wallet was selected.


Field NameTypeDescription
paymentIdStringThe ID for the payment.
orderIdStringThe order ID if the payment was for an order, null otherwise.
signatureStringThe signature to be used for payment verification. (Only valid for orders, null otherwise)


Field NameTypeDescription
codeintThe error code.
messageStringThe error message.


Field NameTypeDescription
walletNameStringThe name of the external wallet selected.