ionic-framework - 如何使用 UPI Deep Link 在 IONIC 4 中仅打开部分 UPI 应用程序
问题描述
我正在使用 webintent 插件来显示已安装的 UPI 并在 IONIC 4 中使用该 UPI 进行交易。但我只想打开 PhonePe、BHIM 和 Paytm 以及 Google Pay 应用程序。如何隐藏其他 UPI 应用程序,如 CRED、AmazonPay、Whatsapp 等。下面是我的代码,请建议我。
payWithUPI() {
const packages = {
'paytm': 'net.one97.paytm',
'google': 'com.google.android.apps.nbu.paisa.user',
'bhim': 'in.org.npci.upiapp',
'phonepe': 'com.phonepe.app'
};
const tid = this.getRandomString();
const orderId = this.getRandomString();
const totalPrice = 1.00;
const UPI_ID = '9960777572@okbizaxis';
const UPI_NAME = 'Adhikar Patil';
const UPI_TXN_NOTE = 'TEST TXN';
let uri = `upi://pay?pa=${UPI_ID}&pn=${UPI_NAME}&tid=${tid}&am=${totalPrice}&cu=INR&tn=${UPI_TXN_NOTE}&tr=${orderId}`;
// uri = uri.replace(' ', '+');
(window as any).plugins.intentShim.startActivity(
{
action: this.webIntent.ACTION_VIEW,
url: uri,
requestCode: 1
}, intent => {
if (intent.extras.requestCode === 1 && intent.extras.resultCode === (window as any).plugins.intentShim.RESULT_OK && intent.extras.Status && (((intent.extras.Status as string).toLowerCase()) === ('success'))) {
alert("Payment Success");
}
else (intent.extras.requestCode === 1 && intent.extras.resultCode === (window as any).plugins.intentShim.RESULT_OK && intent.extras.Status && (((intent.extras.Status as string).toLowerCase()) === ('failed'))) {
alert("Payment Failed ") ;
}
}, err => {
alert('error ' + err);
});
}
getRandomString() {
const len = 10;
const arr = '1234567890asdfghjklqwertyuiopzxcvbnmASDFGHJKLQWERTYUIOPZXCVBNM';
let ans = '';
for (let i = len; i > 0; i--) {
ans += arr[Math.floor(Math.random() * arr.length)];
}
return ans;
}
解决方案
推荐阅读
- r - 当数据集中没有符合输入的观察值时,对闪亮的 selectizeInput 进行过滤并显示空白图
- sql-server - @Transaction(propagation = Propagation.REQUIRES_NEW) 在 MS SQL 存储过程中不可见
- javascript - 当我尝试读取文件时,从 API 中提取文件并通过管道传输会导致文件未找到错误
- java - 获取一个带有随机数的数组来比较数字
- javascript - 我可以使用 Chrome 扩展程序更改“无互联网连接”页面吗?
- python - 为什么 dask 不并行化这个工作流程?
- angular - 如何在 Angular 组件上动态加载资产图像?
- reactjs - React Router v4 - 无法 console.log {match.params.id} 或另存为变量
- javascript - 如何使用函数对 JavaScript 对象中的属性施加条件
- c# - 使用 vb.net 水晶报表打印时出错?