Help for getting Activity Starter Result

I have used Activity Starter for UPI (Payment Apps) and its working well but problem is i’m not getting result.
I have used these BlocksSolutions%20-%20Copy%20-%20Copy

I Have Found this Activity Result Method for UPI -> https://youtu.be/gIr_G6MG0pI?t=236 can anyone Please help me how to implement this in Kodular.

1 Like

This is the Java code how can we implement this in Kodular

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case UPI_PAYMENT:
            if ((RESULT_OK == resultCode) || (resultCode == 11)) {
                if (data != null) {
                    String trxt = data.getStringExtra("response");
                    Log.d("UPI", "onActivityResult: " + trxt);
                    ArrayList<String> dataList = new ArrayList<>();
                    dataList.add(trxt);
                    upiPaymentDataOperation(dataList);
                } else {
                    Log.d("UPI", "onActivityResult: " + "Return data is null");
                    ArrayList<String> dataList = new ArrayList<>();
                    dataList.add("nothing");
                    upiPaymentDataOperation(dataList);
                }
            } else {
                Log.d("UPI", "onActivityResult: " + "Return data is null"); //when user simply back without payment
                ArrayList<String> dataList = new ArrayList<>();
                dataList.add("nothing");
                upiPaymentDataOperation(dataList);
            }
            break;
    }
}

private void upiPaymentDataOperation(ArrayList<String> data) {
    if (isConnectionAvailable(MainActivity.this)) {
        String str = data.get(0);
        Log.d("UPIPAY", "upiPaymentDataOperation: "+str);
        String paymentCancel = "";
        if(str == null) str = "discard";
        String status = "";
        String approvalRefNo = "";
        String response[] = str.split("&");
        for (int i = 0; i < response.length; i++) {
            String equalStr[] = response[i].split("=");
            if(equalStr.length >= 2) {
                if (equalStr[0].toLowerCase().equals("Status".toLowerCase())) {
                    status = equalStr[1].toLowerCase();
                }
                else if (equalStr[0].toLowerCase().equals("ApprovalRefNo".toLowerCase()) || equalStr[0].toLowerCase().equals("txnRef".toLowerCase())) {
                    approvalRefNo = equalStr[1];
                }
            }
            else {
                paymentCancel = "Payment cancelled by user.";
            }
        }

        if (status.equals("success")) {
            //Code to handle successful transaction here.
            Toast.makeText(MainActivity.this, "Transaction successful.", Toast.LENGTH_SHORT).show();
            Log.d("UPI", "responseStr: "+approvalRefNo);
        }
        else if("Payment cancelled by user.".equals(paymentCancel)) {
            Toast.makeText(MainActivity.this, "Payment cancelled by user.", Toast.LENGTH_SHORT).show();
        }
        else {
            Toast.makeText(MainActivity.this, "Transaction failed.Please try again", Toast.LENGTH_SHORT).show();
        }
    } else {
        Toast.makeText(MainActivity.this, "Internet connection is not available. Please check and try again", Toast.LENGTH_SHORT).show();
    }
}

Whole Code on GitHub : Android-payment-using-UPI/MainActivity.java at master · Pro-Grammerr/Android-payment-using-UPI · GitHub

why are you setting result name as result uri? i think result uri used after getting result? try result uri instead of result ( i dont know much about that but with acitivity starter i have used result uri to get results) try it maybe works for you also

1 Like

Just paste code in Kodular IDE and click on compile button :wink:

Means I want to change blocks of After Activity?

this depends on the app you are starting and if that app does not give something back, there is not much you can do…

as it already has been said, this does not make sense
Unbenannt

you might want to check all the properties of the activity starter in the AfterActivity event, to see if there is something reasonable to use

Taifun

Normally Every UPI App Gives Transaction Result

because this method is widely used. so there is no problem with Result.

there is problem with our blocks

I have tried Activity.Result, Activity.Name also

and for After Activity i have also tried Activity.Result, Activity.Name insted of Get.Result - for getting result but not working

all the properties
Taifun

okk I am trying.

is there any clue? - Help for getting Activity Starter Result

I have tried these all properties but all propertied giving Empty Result
Excluding (Activity.Action & Data.URI) these 2 properties returning the same value which we provided.

Removed ResultURI Blocks
03

Here is test blocks i used
02

I have tested all properties With separate label for every value. Because There is Daily Limit for UPI Transactions from Bank. Daily 10 Transactions allowed by banks. so I Have tested this all properties in Single Transaction

Please suggest anything i will try. and i’am also trying

it seems to be, you have to write your own extension based on the snippet you posted earlier
Taifun