androidpayment-gatewaypayumoney

PayUMoney - Android: Getting some error occured response


I'm implementing PayUmoney payment gateway integration in android app.

When I'm running the payment mode in the app getting following error message.

 Some error occurred

Also the below exception

    java.lang.RuntimeException:
    Unable to start activity 
    ComponentInfo{com.XXX.XXX/com.payumoney.sdkui.
    ui.activities.PayUmoneyActivity}:
    java.lang.NullPointerException: 
    Attempt to invoke virtual method 'void 
    com.payumoney.core.PayUmoneySDK.addPayment
    (com.payumoney.core.listener.OnPaymentOptionReceivedListener, 
    java.lang.String)' 
    on a null object reference

Below are some link that I have tried yet

  1. PayuMoney Integration in Android : Some error occured! Try again

  2. Hash param is missing in payU payment gateway android integration

  3. https://github.com/payu-intrepos/payumoney-new-sample-app/issues/8

  4. PayUMoney - Android: Only getting **paymentId** from payUMoney SDK after successful payment

  5. Payu payement error "Some error occurred, Try again!"

  6. How to integrate PayU money Gateway in Android?

Here is the code for make payment

   private void makePayment() {
           //Creating Transaction Id
           Random rand = new Random();
           String randomString = Integer.toString(rand.nextInt()) + 
           (System.currentTimeMillis() / 1000L);
           mTXNId = hashCal("SHA-256", randomString).substring(0, 20);



    double roundOffAmount = Math.round(payamount * 100.0) / 100.0;

    String productName = "Test";

    String udf1 = "";
    String udf2 = "";
    String udf3 = "";
    String udf4 = "";
    String udf5 = "";
    String udf6 = "";
    String udf7 = "";
    String udf8 = "";
    String udf9 = "";
    String udf10 = "";

    /**
     * Creating Hash Key
     */

    mHash = hashCal("SHA-512",
            mMerchantKey + "|" +
                    mTXNId + "|" +
                    String.valueOf(roundOffAmount) + "|" +
                    productName + "|" +
                    userEmail + "|" +
                    userName + "|" +
                    udf1 + "|" +
                    udf2 + "|" +
                    udf3 + "|" +
                    udf4 + "|" +
                    udf5 + "|" +
                    udf6 + "|" +
                    udf7 + "|" +
                    udf8 + "|" +
                    udf9 + "|" +
                    udf10 + "|" +
                    mSalt);

    /**
     * Final Action URL...
     */
    mAction = mBaseURL.concat("/_payment");

    PayUmoneySdkInitializer.PaymentParam.Builder builder = new
            PayUmoneySdkInitializer.PaymentParam.Builder();
    builder.setAmount(String.valueOf(roundOffAmount)) // Payment amount
            .setTxnId(mTXNId) // Transaction ID
            .setPhone("9874563210") // User Phone number
            .setProductName(productName) // Product Name or description
            .setFirstName(userName) // User First name
            .setEmail(userEmail) // User Email ID
            .setsUrl(mSuccessUrl) // Success URL (surl)
            .setfUrl(mFailedUrl) //Failure URL (furl)
            .setUdf1(udf1)
            .setUdf2(udf2)
            .setUdf3(udf3)
            .setUdf4(udf4)
            .setUdf5(udf5)
            .setUdf6(udf6)
            .setUdf7(udf7)
            .setUdf8(udf8)
            .setUdf9(udf9)
            .setUdf10(udf10)
            .setIsDebug(false) // Integration environment - true (Debug)/ 
                                false(Production)
            .setKey(mMerchantKey) // Merchant key
            .setMerchantId(mMerchantId);

    //declare paymentParam object
    PayUmoneySdkInitializer.PaymentParam paymentParam = null;
    try {
        paymentParam = builder.build();
    } catch (Exception e) {
        e.printStackTrace();
    }

 //set the hash
   paymentParam.setMerchantHash(mHash);


    // Invoke the following function to open the checkout page.
     PayUmoneyFlowManager.startPayUMoneyFlow(paymentParam, 
     PaymentMethodAddressActivity.this, R.style.PaymentAppTheme, true);
}

I don't know what's wrong with my code.

Please help me to solved this problem.


Solution

  • I have replaced this line

     builder.setAmount(String.valueOf(roundOffAmount))   
    

    with

     builder.setAmount(roundOffAmount)
    

    Now every thing's works fine as I expected.