微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 UPI Deep Link 在 IONIC 4 中仅打开某些 UPI 应用程序

如何解决如何使用 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 举报,一经查实,本站将立刻删除。