2

I am trying to initiate payment using UPI from Android IONIC(Javascript) App

I get following exception

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND dat=upi://pay?pa=recipient@hdfc&pn=recipient_name&am=102.00&tn=Test_Transaction }

01-10 21:58:32.334 E/PluginManager(29853): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1792)

01-10 21:58:32.334 E/PluginManager(29853): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)

I have 3 UPI enabled Apps on my device: BHIM and PhonePe from Yes bank and iMobile from ICICI

Here is piece of code

  window.plugins.webintent.startActivity({
      action: window.plugins.webintent.ACTION_VIEW,
      url: upiUrl
    },
    function()
    {
      console.log("After calling startActivity");
    },
    function() {
      console.log("Failed to open URL via Android Intent. URL: " + upiUrl)
    }
  );
David Wasser
  • 93,459
  • 16
  • 209
  • 274
Haresh Gujarathi
  • 269
  • 1
  • 4
  • 10

1 Answers1

0

You can create a custom plugin and use the Intent code. Below is the code I wrote for my Expense Sharing Cordova App. You can make it suitable for IONIC.

cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                if(Build.VERSION.SDK_INT<16){
                    callbackContext.error("This feature is available only for Android version Jelly Bean and higher");
                    return;
                }
                try {
                    JSONObject jo = data.getJSONObject(0);
                    String upi_vpa = jo.getString("upi_vpa");
                    String name = jo.getString("name");
                    String UPI = "upi://pay?pa="+upi_vpa+"&pn="+name+"&tn=#Repay-GCF&cu=INR";
                    Intent intent = new Intent();
                    intent.setAction(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(UPI));
                    Intent chooser = Intent.createChooser(intent, "Send Money with...");
                    cordova.getActivity().startActivityForResult(chooser, MainActivity.UPI_PAY_REQUEST, null);
                }catch (JSONException e){
                    e.printStackTrace();
                }
            }
        });
Sandeep Kumar
  • 1,193
  • 13
  • 14
  • Thanks Sandeep How about response from the UPI app. Will the UPI app say BHIM will return success failure as stated in the UPI deep linking document? – Haresh Gujarathi Jun 22 '17 at 18:52