如何使用 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;
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)