- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在创建一个示例项目以通过用户获得付款,我成功地使用 pockets 进行了转账,但我收到的回复是不确定的。
txnId=undefined&responseCode=undefined&Status=undefined&txnRef=undefined
我准备的网址是:upi://pay?pn=john&tr=598&am=1&cu=INR&pa=9469731359@upi
使用这个示例代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Uri.Builder builder = new Uri.Builder();
builder.appendQueryParameter("pa" , "9469731359@upi")
.appendQueryParameter("pn", "john") //payee name.
.appendQueryParameter("tr", "5983") //transaction reference id.
// .appendQueryParameter("mc", "0000") //payee merchant code.
// .appendQueryParameter("tn", "transferring1rs") //transaction description.
.appendQueryParameter("am", "1") //amountPayable (hardcoded to make payment of Rupee 1)
.appendQueryParameter("cu", "INR"); //currency code.
String upiQueryString = "upi://pay" + builder.build().toString(); // virtual payment address of the payee.
Intent intent = new Intent();
intent.setData(Uri.parse(upiQueryString));
Intent chooser = Intent.createChooser(intent, "Choose respective UPI"); //Shows a list of UPI enabled PSP apps if more than one is available.
startActivityForResult(chooser, 1, null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
try {
if (intent != null) {
String pspResonse = intent.getStringExtra("response");
String[] pspResonseArray = pspResonse.split("&");
Map<String, String> map = new HashMap<>();
for (String param : pspResonseArray) {
String key = param.split("=")[0];
String value = param.split("=")[1];
map.put(key, value);
}
TextView txnStatus = (TextView)findViewById(R.id.editText10);
TextView txnId = (TextView)findViewById(R.id.editText11);
TextView txnRef = (TextView)findViewById(R.id.editText12);
TextView amount = (TextView)findViewById(R.id.editText13);
// hide layout 1
RelativeLayout layout1 = (RelativeLayout) findViewById(R.id.layout1);
RelativeLayout layout2 = (RelativeLayout) findViewById(R.id.layout2);
layout1.setVisibility(View.GONE);
layout2.setVisibility(View.VISIBLE);
txnStatus.setText(map.get("Status"));
txnId.setText(map.get("txnId"));
txnRef.setText(map.get("txnRef"));
amount.setText("1");
} else {
Toast.makeText(this, "Null intent received", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
请帮忙。提前致谢:)
最佳答案
您好,首先您使用的是 UPI intent 调用,而不是 upi sdk 集成
下面的代码可能对你有帮助
Uri uri = new Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", payeeVpaAddress)
.appendQueryParameter("pn", payeeName)
.appendQueryParameter("tr", transactionRefId)
.appendQueryParameter("tn", description)
.appendQueryParameter("am", amount should be with fixed to 00, ex. 10.00)
.appendQueryParameter("cu", "INR")
.build();
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
Intent chooser = Intent.createChooser(intent, "Pay with...");
startActivityForResult(chooser, <<requestCode>>, null);
在onActivityResult中添加下面的代码,先检查后面的结果是哪个request,可以用requestCode检查
if (requestCode == <<requestCode>>) {
if (data != null) {
Bundle bundle = data.getExtras();
String response = bundle.getString("response");
String responseValues[] = getKeyValueFromString(response, "&");
HashMap<String, String> keyValueOfResponse = new HashMap<>();
for(String responseValue: responseValues) {
String []keyValue = getKeyValueFromString(responseValue, "=");
if(keyValue!= null && keyValue.length > 1) {
keyValueOfResponse.put(keyValue[0], keyValue[1]);
}
}
String txnRef = keyValueOfResponse.get("txnRef");
String responseCode = keyValueOfResponse.get("responseCode");
String Status = keyValueOfResponse.get("Status");
String txnId = keyValueOfResponse.get("txnId");
}
}
下面只是辅助函数
private String[] getKeyValueFromString(String stringToSplit, String splitBy) {
if (stringToSplit == null) {
return null;
}
return stringToSplit.split(splitBy);
}
关于android - 如何解决来自 UPI sdk 的未定义响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43347017/
我正在尝试使用 upi://(深层链接 URL)在 Android 中集成 UPI 支付。我对成功的交易很满意,但我需要服务器端的交易详细信息,就像在支付后的 android Intent 返回结果中
我不知道问这个问题是否正确,我不知道在哪里问这个问题。 我正在开发一个应用程序,对于应用程序购买,我正在尝试实现 UPI 支付。我也有一些插件可以这样做,但是当我测试时,我的交易被拒绝了。我正在尝试通
我已将 razorpay 与 flutter 集成,一切正常。但它没有调用设备中存在的 upi 应用程序。如何做到这一点? 最佳答案 void _launchURL() async { Str
我有一个基于 WordPress 和 Woo-commerce 的购物网站,并安装了 UPI 支付插件。我还使用 Web View 为我的网站制作了 Android APP。 ****问题**** W
此链接无效: urlString = "upi://pay?pa=samplevpa@ybl&pn=Sample Name&am=1&cu=INR".addingPercentEncoding(wit
我正在尝试在网络上添加 upi 超链接。具有以下格式upi://pay?pa=myvpa@ybl&pn=abc%20pqr&tr=B1947&tn=Pay%20to%20abc%20pqr&am=1&
它类似于电子邮件 ID,但也可以从数字开始,并且末尾没有域名。 示例: rishi.21@axis shruti@PNB 98765__210@upi 最佳答案 理想情况下,@ 前后的字符数最少。因此
在我的 iOS 应用程序中,我需要接受用户的付款。我正在使用 UPI。我已遵循 UPI 提供的以下文档 http://www.npci.org.in/documents/UPI-Linking-Spe
关闭。这个问题需要 debugging details 。它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 Stack Overflow 的 on-topic。 4 个月前关闭。 Improv
我正在创建一个示例项目以通过用户获得付款,我成功地使用 pockets 进行了转账,但我收到的回复是不确定的。 txnId=undefined&responseCode=undefined&Statu
关闭。这个问题需要更多 focused .它目前不接受答案。 想要改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 4 年前。 Improve this q
这与印度的 UPI 支付系统有关。 我在 https://developers.google.com/pay/india/api/android/in-app-payments 使用示例代码启动 Go
我正在尝试通过 UPI 超链接(例如 )付款 upi://pay?pa=abc@upi&pn=payeeName&tr=1234&tn=Pay%20to%20payeeName&am=1&mam=1&
GPay 集成在 2 天前完全正常,但现在它在 gpay 应用程序中显示相同的错误。要求 gpay 付款的 Intent 不起作用。 我在几天前成功完成了交易。但现在它不起作用。任何帮助,将不胜感激!
UPI(统一支付接口(interface))是印度银行的支付接口(interface)。在 UPI 中,交易是链接。就像比特币交易是消息一样这些链接将传递到 UPI 支付应用程序,付款人必须登录该应用
我正在尝试创建一个商家应用程序,它将根据 NPCI 的指南生成一个 url。此 url 将作为 intent 共享,PSP 应用程序(任何已注册的银行应用程序)应该能够收听该 url 并被调用。 我已
我正在开发一个事件管理应用程序(使用 Flutter)。输入客人的 UPI ID/VPA 后,我希望向他的帐户发起请求,他可以通过相关的 UPI 应用程序从他的手机上批准来支付金额。 Google P
我已经使用 intent 从我的 android native 应用程序深度链接了 UPI 应用程序。我已经使用 BHIM、PhonePe、AXIS、UnionBank、Pockets 等各种 UPI
是否有使用 Android Deep Link 集成 UPI 支付网关的工作示例。我仔细阅读了 NPCI 规范并没有成功实现它。交易没有完成。 protected override void OnAc
我正在尝试深层链接到用户手机上安装的特定 UPI 应用程序,例如 Google Pay。例如,如果用户点击网络应用程序上的 Google 支付图标,他应该被直接重定向到安装在他手机上的 Google
我是一名优秀的程序员,十分优秀!