尝试使用深层链接为我的 Android 应用程序连接 UPI 付款,但每次都在最后一步失败。
UPI 支付调用的代码片段如下:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
URI_URL = getUPIString("xxx@upi", "xxx xxx", "test_101", "Test Transaction", "10", "INR");
//Creating an intent for the UPI APP
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(URI_URL));
Intent chooser = Intent.createChooser(intent, "Pay the MSME by");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
startActivityForResult(chooser, 1, null);
}
}
});
要使用此函数构建 UPI 字符串:
private String getUPIString(String payeeAddress, String payeeName, String trxnRefId,
String trxnNote, String payeeAmount, String currencyCode) {
String UPI = "upi://pay?pa=" + payeeAddress + "&pn=" + payeeName
+ "&tr=" + trxnRefId
+ "&tn=" + trxnNote + "&am=" + payeeAmount + "&cu=" + currencyCode;
return UPI.replace(" ", "+");
}
失败的可能原因是什么?欢迎任何建议或帮助。