【问题标题】:I'm using the Paytm all in one sdk in my flutter application. It's throwing PlatformException error我在我的颤振应用程序中将 Paytm 全部用于一个 sdk。它抛出 PlatformException 错误
【发布时间】:2021-07-27 10:03:13
【问题描述】:

在我的应用程序中,我在一个页面中调用 startTransaction() 插件方法,并将响应存储在 paytm 文档中。在收到响应时,我想将成功或失败的状态返回到上一页。所以在 init() 函数中,我调用了另一个异步方法来 startTransaction 并检查响应。

PlatformException (0, Unknown error, {response : { response of transaction})

class StartTransaction extends StatefulWidget {
  int orderId;
  double totalAmount;
  PaymentPayload paymentPayload;
  bool success;
  StartTransaction({this.orderId,this.totalAmount});
  @override
  _StartTransactionState createState() => _StartTransactionState();
}

class _StartTransactionState extends State<StartTransaction> {

@override
  void initState() {
    super.initState();
    initiateTransaction();
  }

  Future initiateTransaction() async {
    if(widget.success == null){
      widget.paymentPayload = await createPaymentGateway(
          widget.orderId,
          userBloc.userData.username,
        widget.totalAmount.toStringAsFixed(2),
          context);
      var pgResp = AllInOneSdk.startTransaction(
          widget.paymentPayload.mid,
          widget.orderId.toString(),
          widget.totalAmount.toStringAsFixed(2),
          widget.paymentPayload.txnToken,
          widget.paymentPayload.callbackUrl,
          true,
          false);
      pgResp.then((value) {
        print(value);
        setState(() {
          widget.success = value['RESPCODE'] == 01;
        });
      }).catchError((onError) {
        setState(() {
          widget.success = false;
        });
      });
    }
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: FutureBuilder(
            builder: (context, snapshot) {
              if(widget.success == true) {
                print('Payment successful');
                Navigator.pop(context,true);
              } else if(widget.success == false) {
                print('Payment unsuccessful');
                Navigator.pop(context,false);
              }
              return Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text('We are processing your transaction', style: TextStyle(fontSize: 36),),
                    CircularProgressIndicator(),
                  ],
                ),
              );
            }
        ),
      ),
    );
  }

  
}```

【问题讨论】:

    标签: flutter exception hybrid-mobile-app platform paytm


    【解决方案1】:

    您需要根据交易中使用的订单id和MID调用交易状态API。无需再次调用starttransaction方法

    【讨论】:

    • 在尝试对事务状态进行 API 调用时,我总是收到 501 系统错误。我该如何解决?
    • 请分享一个示例 curl 请求,checksumhash 不能正确生成
    【解决方案2】:

    您应该使用事务状态 API 通过服务器端请求验证事务响应。此 API 在请求和响应中需要校验和。您必须使用您的数据验证订单 ID 和金额。在所有情况下,该状态都应视为交易的最终状态。

    【讨论】:

    • 在尝试对事务状态进行 API 调用时,我总是收到 501 系统错误。我该如何解决?
    • 你可以连接paytm,他们会解决你的问题。
    【解决方案3】:

    这种情况下需要使用我们的静态回调url

    暂存环境:“https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=” 生产环境:“https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=

    【讨论】:

      猜你喜欢
      • 2020-03-15
      • 2022-01-09
      • 2020-02-03
      • 2019-10-16
      • 2021-03-26
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 2020-02-20
      相关资源
      最近更新 更多