首页 > 解决方案 > 在flutter/dart中完成UPI支付后如何得到响应

问题描述

有人可以帮我在 UPI 交易完成后如何获得回复。我在 Stack Overflow 中使用了这个帮助,但它不起作用:“https://stackoverflow.com/questions/48097332/how-can-we-get-response-from-an-app-which-was-launched-by -另一个应用程序”。

就我而言,当我合并它时,它会说 MissingPluginException(未找到实现方法)。

class _DisplayCartItemState extends State<DisplayCartItem> {
  static const platform = const MethodChannel('upi/tez');
  Uri uri;

  @override
  void initState() {
    super.initState();
    uri = Uri.parse('upi://pay?pa=*****@okhdfcbank&pn=Test App&tn=Payment Done through Foodie App&cu=INR&am=1');
  }

_startPaymentTransaction(BuildContext context) async {
        if (await canLaunch(uri.toString())) {
          try {
            final String result = await platform.invokeMethod('launchUpi', <String, dynamic>{"url": uri.toString()});
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
              content: Text(result),
            ));
            print(result);
          }catch(e){
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
              content: Text(e.toString()),
            ));
          }
        } else {
          ScaffoldMessenger.of(context).showSnackBar(SnackBar(
            content: Text("Could not launch the UPI App"),
          ));
        }
      }
}

谢谢

标签: flutterdart

解决方案


void _launchURL() async {
    String _url='upi://pay?pa=dinesh@dlanzer&pn=Dinesh&am=1&tn=Test Payment&cu=INR';
    var result = await launch(_url);
     debugPrint(result.toString());
     if (result ==true) {
       print("Done");
     } else if (result ==false){
       print("Fail");
     }
  }

试试这个代码

我使用url_launcher插件来打开 UPI 应用程序。

深层链接网址'upi://pay?pa=dinesh@dlanzer&pn=Dinesh&am=1&tn=Test Payment&cu=INR'

upi显示您手机中的 UPI 应用程序列表。

pay被重定向到支付页面。

pa您在此处提及 upi 地址(请注册企业 upi 帐户并在此处提及)。

am金额在这里输入。

tn只是通过按摩。

cu提及您要付款的货币


推荐阅读