簡體   English   中英

在集成 Razorpay 支付網關期間沒有支付?

[英]During Integrating Razorpay Payment Gateway Payment is not happening?

這是顯示 I/chromium 的錯誤消息:[INFO:CONSOLE(1)]“Uncaught TypeError: window.getDeviceDetails is not a function”,來源: https://api.razorpay.com/v1/checkout/public ?version=1.5.16&library=checkoutjs&platform=android (1)

在這方面幫助我

嘗試運行此代碼:

 @override
  void initState() {
    super.initState();
    _razorpay = Razorpay();
    _razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
    _razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
    _razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);
  }

  @override
  void dispose() {
    super.dispose();
    _razorpay.clear();
  }

  void openCheckout() async {
    var options = {
      'key': 'rzp_test_1DP5mmOlF5G5ag',
      'amount': 2000,
      'name': 'Acme Corp.',
      'description': 'Fine T-Shirt',
      'prefill': {'contact': '8888888888', 'email': 'test@razorpay.com'},
      'external': {
        'wallets': ['paytm']
      }
    };

    try {
      _razorpay.open(options);
    } catch (e) {
      debugPrint(e);
    }
  }

  void _handlePaymentSuccess(PaymentSuccessResponse response) {
    Fluttertoast.showToast(
        msg: "SUCCESS: " + response.paymentId, timeInSecForIos: 4);
  }

  void _handlePaymentError(PaymentFailureResponse response) {
    Fluttertoast.showToast(
        msg: "ERROR: " + response.code.toString() + " - " + response.message,
        timeInSecForIos: 4);
  }

  void _handleExternalWallet(ExternalWalletResponse response) {
    Fluttertoast.showToast(
        msg: "EXTERNAL_WALLET: " + response.walletName, timeInSecForIos: 4);
  }

當您提供的資金格式不正確時,會發生上述錯誤。 RazorPay 只接受派斯的錢,因此如果您以十進制格式(即雙精度)或任何小於 100 的值提供錢,那么它將引發該錯誤。 因此,如果您有任何十進制值,請嘗試將其轉換為 integer paise。 我還附上了一個小代碼以供參考。

 RegExp regex = RegExp(r"([.]*0)(?!.*\d)");
 double money = double.parse(widget.totalMoney);
    double tMoney = money*100;
    String stringMoney = tMoney.toString().replaceAll(regex, '');
    int totalMoney = int.parse(stringMoney);

正則表達式將從 stringMoney 中刪除小數點后的零。 或者直接將其轉換為字符串也會這樣做。

希望這會有所幫助:)

這可能是密鑰 ID 和密鑰秘密不匹配的問題。 嘗試仔細檢查代碼是否具有一致的 Key ID 和 Key Secret。 特別是在您從測試賬戶切換到真實賬戶的情況下。

請重新檢查您的 API 密鑰是否有效。 這是由於您的 API 密鑰或密碼中有錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM