flutter - 在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"),
));
}
}
}
谢谢
解决方案
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
提及您要付款的货币
推荐阅读
- python - 为什么 os.stat().st_size 为 dir 返回 0?
- javascript - 将 2d 文本剪辑到 3d 对象 WebGl
- amazon-web-services - 私有子网中具有公共 IP 的实例可以接收互联网流量吗?
- python - Python:试图抓取 Jumia 笔记本电脑网站
- cmake - CMake 为每个配置链接器标志设置
- javascript - 这是我的代码的问题还是 discord.js 的问题?
- xcode - 函数“yyback”的隐式声明在 C99 中无效
- python - 如何比较不同类型的两个值并从抓取的表数据中确定最大值
- node.js - 为什么 node -v 命令不能在 Windows 上使用 wsl2 Ubuntu 20.04
- python - 基于另一列生成新列