Razorpay, Payment Error: Error in opening checkout

I am encountering an issue with the Razorpay Flutter integration where the Razorpay payment window opens and closes within a second during the second transaction attempt. Initially, the integration was working correctly, but subsequent transactions are failing with this behavior.

Terminal:

Payment Error: Error in opening checkout

I/flutter (13709): Payment Error: {reason: payment_error, metadata: {}, code: BAD_REQUEST_ERROR, contact: +919000090000, description: Error in opening checkout, step: payment_authentication, source: customer, email: [email protected]}  
W/ContentCatcher(13709): Failed to notify a WebView

E/com.razorpay.checkout(13709): Webview JS Error: Uncaught TypeError: CheckoutBridge.sendAnalyticsData is not a function

I/chromium(13709): [INFO:CONSOLE(1)] "Uncaught TypeError: CheckoutBridge.sendAnalyticsData is not a function", source: https://api.razorpay.com/v1/checkout/public?version=1.6.39&library=checkoutjs&platform=android&customer_id=CID1717393257417&session_token=3C2730A481106A990650F5CC724578BD4B01A14F808D62E6BCD93EDB50683C7AD789CD1F252FAC15C9886E59C6377254C66FA1B679920E275D5456E0F28EC2FE551431A7E4BE4B5FD5DCF1ED1B4797BC545327B2C64DE9A256ACA3A4F8BC8AC110C0F50394179365D31E75733F4B82FB9260053D820DBC5993118627FE49AB4D98CC5260CF34DEF3BDF23E9769DAA01EA84C29&country_code=IN&traffic_env=canary (1)

E/com.razorpay.checkout(13709): Webview JS Error: Uncaught (in promise) #<Object>
Future<void> initiatePayment() async {
  try {
    orderID = await generateOrderId("rzp_live_njtuvWcruSxxxx", "Kn3yyNEj99hss0J7VJvpxxxx", int.parse(amount));
    print("Order ID inside initiate payment: $orderID");
    
    var options = {
      'key': 'rzp_live_njtuvWcruSxxxx', // Your Razorpay Key ID
      'amount': int.parse(amount), // Amount in the smallest currency sub-unit
      'name': userName,
      'currency' : "INR",
      'order_id': orderID,
      'customer_id': customerID,
      'description': 'Pursue',
      'timeout': 180, // in seconds
      'prefill': {
        'contact': '9009009009',
        'email': userEmail,
      },
      'external': {
        'wallets': ['paytm']
      },
    };

    // Clear previous transaction data
    razorpay.clear();
    razorpay = Razorpay();
    razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
    razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
    razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);
    razorpay.open(options);
  } catch (e) {
    debugPrint("Error: ${e.toString()}");
    Fluttertoast.showToast(msg: "Error initiating payment");
  }
}

  Future<String> generateOrderId(String key, String secret, int amount) async {
    var authn = 'Basic ${base64Encode(utf8.encode('$key:$secret'))}';

    var headers = {
      'content-type': 'application/json',
      'Authorization': authn,
    };

    var data =
        '{ "amount": $amount, "currency": "INR" }';
    var url = Uri.parse('https://api.razorpay.com/v1/orders');
    var res = await http.post(url, headers: headers, body: data);
    if (res.statusCode != 200) {
      throw Exception('http.post error: statusCode= ${res.statusCode}');
    }
    print('ORDER ID response => ${res.body}');
    print(json.decode(res.body)['id'].toString());
    return json.decode(res.body)['id'].toString();
  }

I’ve tried the following things:

  1. Validate Amount
  2. Correct Key and Order ID
  3. Mandatory Fields:
    Ensure all mandatory fields are included in the options. For Razorpay, the mandatory fields typically include:
    key
    amount
    name
    order_id
    prefill (with contact and email)
  4. Prefill Details:
    Ensure the contact and email fields in the prefill section are correctly formatted.
  5. Error Handling and Logging:
    Add detailed logging to capture more context about the error.

New contributor

Avanish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật