Methods

Check the payment methods available for the Flutter plugin.


Documented below are the methods for the Flutter plugin.

Use this method for fetching the payment methods:

onPressed: () {
final paymentMethods = await _razorpay.getPaymentMethods();
}

Use this method for fetching those apps on the customer's phone which support UPI payments:

onPressed: () {
final supportedUpiApps = _razorpay.getAppsWhichSupportUpi();
}

Use this method to get the card network. This function expects the card number as a parameter and returns the card network eg: VISA, Mastercard, RuPay and so on:

onPressed: () {
final cardNetwork = _razorpay.getCardsNetwork("<card-number>");
}

Use this method to validate the card number. This function returns a boolean value that determines the card is valid or invalid:

onPressed: () {
final isValidCard = await _razorpay.isValidCardNumber('4111111111111111');
}

Use this method for fetching the bank logo URL. It needs bank code as a method parameter which is returned in the getPaymentMethod() call:

Use this method for changing the API keys:

onPressed: () {
_razorpay.changeApiKey(‘api-key’);
}

Use this method for fetching the card network length:

onPressed: () {
final length = await _razorpay.getCardNetworkLenght('VISA');
}

Use this method for fetching the subscription amount using the subscription_id:

onPressed: () {
final subAmount = await _razorpay.getSubscriptionAmount('sub_8tkmbhhROdiVSc');
}

Use this method for fetching the wallet logo URL:

Use this method for submitting the payment details:

onPressed: () {
var options = {
'key': key,
'amount': 100,
'currency': 'INR',
'email': 'gaurav.kumar@example.com',
'contact': '9900990099',
'method': 'netbanking',
'bank': 'hdfc'
};
_razorpay.submit(options);
}

Events are triggered from the SDK for handling success or error on payments, Register for these events in the initState() method in their flutter apps as given below:

@override
void initState() {
_razorpay = Razorpay();
_razorpay.initilizeSDK(key);
_razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
_razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
}
void _handlePaymentSuccess(Map<dynamic, dynamic> response) {
print('Payment Success Response : $response');
}
void _handlePaymentError(Map<dynamic, dynamic> response) {
print('Payment Error Response : $response');
}

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.

Is this integration guide useful?