flutterdartpayment-gatewayordersrazorpay

How to use Razorpay Orders API in Flutter?


I'm implementing a payment gateway in my flutter application. So Razorpay recommends me to use Orders API. But I don't get any ways to implement Orders API.

I had referred the below documentation. It contains examples for java, PHP, etc. But nothing found for Flutter / Dart.

https://razorpay.com/docs/payment-gateway/orders/integration/#example

Thanks in advance.


Solution

  • Thankfully, Razorpay has Flutter package which you can use. The following code snippet might help :

    import 'package:razorpay_flutter/razorpay_flutter.dart';
    
    _razorpay = Razorpay();
    
    var options = {
          'key': '<YOUR_KEY_ID>',
          'amount': 100, //in the smallest currency sub-unit.
          'name': 'Acme Corp.',
          'order_id': 'order_EMBFqjDHEEn80l', // Generate order_id using Orders API
          'description': 'Fine T-Shirt',
          'prefill': {
            'contact': '9123456789',
            'email': 'gaurav.kumar@example.com'
          }
        };
    
    _razorpay.open(options);
    

    Please go through this page for further details. And this YouTube video will help as well.