API ReferenceIntegrationsKnowledge Base

Razorpay Flutter Plugin for Android and iOS

The Razorpay Flutter plugin acts as a wrapper around our native Android and iOS SDKs.

Refer to our Standard Android SDK and Standard iOS SDK documentation for more information on these SDKs.

We recommend you read our Payment Flow document before proceeding with the integration.


  1. Download the plugin from Pub.dev.

  2. Add the below code to dependencies in your app's pubspec.yml

    Copyrazorpay_flutter: 1.1.0

    Minimum Version Requirement:

    • For Android, ensure that the minimum API level for your app is 19 or higher.
    • For iOS, ensure that the minimum deployment target for your app is iOS 10.0 or higher. Also, don't forget to enable bitcode for your project.
  3. Run flutter packages get in the root directory of your app.


Sample code to integrate can be found here.

Import package#

Use the below code to import the razorpay_flutter.dart file to your project.

Copyimport 'package:razorpay_flutter/razorpay_flutter.dart';

Create Razorpay instance#

Use the below code to create a Razorpay instance.

Copy_razorpay = Razorpay();

Attach Event Listeners#

The plugin uses event-based communication and emits events when payments fail or succeed.

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.

Copy_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 in the class as:

Copyvoid _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 is selected }

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

Copy_razorpay.clear(); // Removes all listeners

Setup Options#

Copyvar options = { 'key': '<YOUR_KEY_ID>', 'amount': 100, //in the smallest currency sub-unit. 'name': 'Acme Corp.', 'description': 'Fine T-Shirt', 'prefill': { 'contact': '9123456789', 'email': 'gaurav.kumar@example.com' } };

For a complete list of options for the checkout form, refer to our standard checkout documentation.

Open Checkout#

Use the below code to open the Razorpay checkout.



Documented below is the API package for the plugin.



Method (Open Checkout)#

The below method opens the checkout.

open(map<String, dynamic> options)

The options map has key as a required property. All other properties are optional. Refer to our standard checkout documentation for a complete list of options for the checkout form.

Method (Register Event Listeners)#

The below method registers event listeners for payment events.

on(String eventName, Function listener)

Method (Clear all 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 Code



There was a network error. For example, loss of internet connectivity.


An issue with options passed in Razorpay.open.


User cancelled the payment.


Device does not support TLS v1.1 or TLS v1.2.


An unknown error occurred.

Event Names#

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

Event Name



The payment was successful.


The payment was not successful.


An external wallet was selected.


Field Name

data type Description


string The ID for the payment.


string The order ID if the payment was for an order, otherwise null.


string The signature to be used for payment verification. Only valid for orders, otherwise null.


Field Name

data type Description


integer The error code.


string The error message.


Field Name

Data Type Description


string The name of the external wallet selected.

Generate API Key#

You have to generate separate API Keys for the test and live modes. No money is deducted from your account in test mode.

To generate API key:

  1. Log into your Dashboard.
  2. Select the mode for which you want to generate the API key from the menu ribbon.
  3. Navigate to Settings.
  4. Click API Keys.
  5. Click Generate Key to generate key for the selected mode.

The Key Id and Key secret appear in a pop-out window. You also have the option to download the Key Details.

Watch the short animation below for more information.

After generating the keys from the Dashboard, download and save them securely. If you do not remember your API Keys, you need to re-generate it from the Dashboard and replace it wherever required.