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 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 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 wallet logo URL:
onPressed: () {final walletLogo = await _razorpay.getWalletLogoUrl('paytm');}
Use this method for submitting the payment details:
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:
@overridevoid 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.
Is this integration guide useful?