payu-intrepos / payumoney-new-sample-app

New Sample App For PayUmoney and PnP SKD integration
40 stars 37 forks source link

Must be invoked from the main thread. #41

Closed bhautik-mworldwebtech closed 4 years ago

bhautik-mworldwebtech commented 4 years ago

private void launchPayUMoneyFlow() {

    PayUmoneyConfig payUmoneyConfig = PayUmoneyConfig.getInstance();

    //Use this to set your custom text on result screen button
    payUmoneyConfig.setDoneButtonText("Done");

    //Use this to set your custom title for the activity
    payUmoneyConfig.setPayUmoneyActivityTitle("Mworld");

    payUmoneyConfig.disableExitConfirmation(false);

    PayUmoneySdkInitializer.PaymentParam.Builder builder = new PayUmoneySdkInitializer.PaymentParam.Builder();

    double amount = 0;

    try {
        amount = Double.parseDouble("15");

    } catch (Exception e) {
        e.printStackTrace();
    }

    String txnId = System.currentTimeMillis() + "_TEST";
    //String txnId = "TXNID720431525261327973";
    String phone = "8866116254";
    String productName = "Product A";
    String firstName = "Bhautik Patel";
    String email = "bhautik236@gmail.com";
    String udf1 = "";
    String udf2 = "";
    String udf3 = "";
    String udf4 = "";
    String udf5 = "";
    String udf6 = "";
    String udf7 = "";
    String udf8 = "";
    String udf9 = "";
    String udf10 = "";

    AppEnvironment appEnvironment = ((MyApp) getApplication()).getAppEnvironment();
    builder.setAmount(String.valueOf(amount))
            .setTxnId(txnId)
            .setPhone(phone)
            .setProductName(productName)
            .setFirstName(firstName)
            .setEmail(email)
            .setsUrl(appEnvironment.surl())
            .setfUrl(appEnvironment.furl())
            .setUdf1(udf1)
            .setUdf2(udf2)
            .setUdf3(udf3)
            .setUdf4(udf4)
            .setUdf5(udf5)
            .setUdf6(udf6)
            .setUdf7(udf7)
            .setUdf8(udf8)
            .setUdf9(udf9)
            .setUdf10(udf10)
            .setIsDebug(appEnvironment.debug())
            .setKey(appEnvironment.merchant_Key())
            .setMerchantId(appEnvironment.merchant_ID());

    try {
        mPaymentParams = builder.build();

        /*
         * Hash should always be generated from your server side.
         * */
        //    generateHashFromServer(mPaymentParams);

        /*            *//**
         * Do not use below code when going live
         * Below code is provided to generate hash from sdk.
         * It is recommended to generate hash from server side only.
         * */
        mPaymentParams = calculateServerSideHashAndInitiatePayment1(mPaymentParams);

        if (AppPreference.selectedTheme != -1) {
            PayUmoneyFlowManager.startPayUMoneyFlow(mPaymentParams,thisCon, AppPreference.selectedTheme, true);
        } else {
            PayUmoneyFlowManager.startPayUMoneyFlow(mPaymentParams,thisCon, R.style.AppTheme_default, true);
        }

    } catch (Exception e) {
        // some exception occurred
        Log.e("OrderSummery" , "My Error :- "+e.getMessage());
    }
}
Rahul-Hooda commented 4 years ago

Closing this thread due to no activity.

Moumit commented 4 years ago

Any clue how to resolve this issue .. i am facing the same in react native