Razorpay Payment Gateway in Flutter

Updated 4 July 2023

Save

Hey! Folks 👨🏻‍💻 today we’ll integrate the RazorPay Payment Gateway in Flutter.

Before we get started I urge you to go and check out our Flutter App Development Company.

Let’s start the party.

Create a fresh project to integrate the Razorpay Payment Gateway in Flutter.

Prerequisites

Step 1.

Add Razorpay_flutter in pubspec.yaml file.

Step 2.

If you are using Proguard for your builds, you need to add the following lines to the Proguard files:

Note: If there is no proguard file in Android app level then create a new file in

the directory – android/app/proguard-rules.pro

Step 3.

Now run the command in the terminal – flutter pub get

Minimum Version Requirement

Step 4.

Create a Razorpay instance.

Attach event listener to listen to the changes at payment gateway sdk.

Creates handler for listeners.

Add this line after the payment gets successful and in dispose method.

razorpayOrderId you need to generate this orderId for payment.

you can generate test orderId in postman.

After the successful request, you’ll get this response.

Check the full Code for the Razorpay Payment gateway.

main.dart file

razorpay_payment_screen.dart

After the payment gets successful you can check the Razorpay dashboard.

NOTE: There is some issue in Razorpay SDK.

If you’re getting this issue “type ‘String’ is not a subtype of type ‘Map<dynamic, dynamic>?’ in type cast”

You need to add some code in their SDK.

in razorpay_flutter.dart file replace this code with existing code in PaymentFailureResponse function.

Before-

After- Line no – 140

That’s all for this Article 🎊 .

Conclusion

Razorpay Payment Gateway in Flutter in this blog we’ve learned how to integrate the razorpay into Flutter app.

Visit the link for Razorpay’s official documents.

Thanks for reading this blog. You can also check other blogs from here for more knowledge.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home