0
votes

UPI (Unified Payment Interface) is a payment interface for Indian banks. In UPI transactions are links. Just like bitcoin transactions are messages Those links are passed to UPI payment apps and the payer has to login to the app and click the pay button.

Our app has to start an intent and pass link to the UPI payment app and after payer clicks the pay button we need to call onActivityResult. I dont know anything about android development in java. I use python kivy for android development. I want to know what should my onActivityResult should do.

Sample code : UPI App Deep linking using Intent - inconsistent and buggy behavior

I can use java code in python using pyjnius.

Some reference link: https://blog.deazzle.in/enable-upi-payments-in-your-app-without-the-need-to-integrate-with-a-bank-c911019f3b2d

2
Maybe have a look at the documentationOcelotcR
Should i assume that RESULT_OK will only be returned if payer clicks the pay button (zero knowledge about android development with java) if payer dont click pay button or just closes the app then RESULT_CANCELED will be returned???Prashant Singh

2 Answers

2
votes

you have not any need to do it manually. I have developed a library for it. Just have to do a simple process.

        final EasyUpiPayment easyUpiPayment = new EasyUpiPayment.Builder()
                .with(this)
                .setPayeeVpa("EXAMPLE@VPA")
                .setPayeeName("PAYEE_NAME")
                .setTransactionId("UNIQUE_TRANSACTION_ID")
                .setTransactionRefId("UNIQUE_TRANSACTION_REF_ID")
                .setDescription("DESCRIPTION_OR_SMALL_NOT")
                .setAmount("AMOUNT_IN_DECIMAL_XX.XX")
                .build();

        easyUpiPayment.startPayment();

For more info, you can visit below site. https://github.com/PatilShreyas/EasyUpiPayment-Android

1
votes

Activity A:

Intent start = new Intent(MainActivity.this, PurchaseActivity.class);
startActivityForResult(start, 1);

And add this result listener:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            //payment was successful
        }else if (resultCode == RESULT_CANCELED) {
            //payment was canceled
        }
    }
}

And Activity B: If payment was successful:

setResult(RESULT_OK, new Intent());
finish();

or if it was canceled:

setResult(RESULT_CANCELED, new Intent());
finish();