首页 > 解决方案 > Cashfree 支付网关集成在 react native 和 laravel 中(orderAmount 是必需的错误)

问题描述

我正在将 CashFree 支付网关集成到 react 本机应用程序(Android)中。我正在关注此文档https://docs.cashfree.com/docs/react-native-2-0-sdk#web-checkout。在实施时,我得到了回应

{"type":"CashFreeResponse","txMsg":"orderAmount not provided","txStatus":"FAILED"}

但是我正在传递所有需要进行付款的参数。

  const handlePayment = response => {
    console.log('amount', total);
    var mode = 'TEST';
    var map = {
      "appId": response.credentials.app_id,
      "orderId": response.credentials.order_id,
      "orderCurrency": 'INR',
      "orderAmount": 150, //parseInt(response.data.price)
      "customerPhone": response.user.mobile,
      "customerEmail": response.user.email,
      "tokenData": response.payment_info.cftoken,
      "orderNote": 'Subscription Payment',
      "notifyUrl": '',
      "customerName": response.user.name,
    };
    console.log('data', map);
    RNPgReactNativeSDK.startPaymentWEB(map, mode, result => {
      console.log(result);
      var obj = JSON.parse(result, function (key, value) {
        console.log(key + '::' + value);
        // Do something with the result
      });
    });
  };

标签: reactjslaravelreact-native

解决方案


根据他们网站上提到的文档,您需要输入订单金额作为字符串。

  const handlePayment = response => {
    console.log('amount', total);
    var mode = 'TEST';
    var map = {
      "appId": response.credentials.app_id,
      "orderId": response.credentials.order_id,
      "orderCurrency": 'INR',
      "orderAmount": '150',
      "customerPhone": response.user.mobile,
      "customerEmail": response.user.email,
      "tokenData": response.payment_info.cftoken,
      "orderNote": 'Subscription Payment',
      "notifyUrl": '',
      "customerName": response.user.name,
    };
    console.log('data', map);
    RNPgReactNativeSDK.startPaymentWEB(map, mode, result => {
      console.log(result);
      var obj = JSON.parse(result, function (key, value) {
        console.log(key + '::' + value);
        // Do something with the result
      });
    });
  };

推荐阅读