PayUMoney-Android:出现一些错误响应

时间:2019-01-25 07:07:40

标签: android payment-gateway payumoney

我正在Android应用程序中实现PayUmoney付款网关集成。

当我在应用程序中运行付款方式时,出现以下错误消息。

 Some error occurred

还有以下例外情况

    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

下面是我尝试过的一些链接

  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?

以下是付款代码

   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);
}

我不知道我的代码有什么问题。

请帮助我解决此问题。

1 个答案:

答案 0 :(得分:0)

我替换了这一行

 builder.setAmount(String.valueOf(roundOffAmount))   

 builder.setAmount(roundOffAmount)

现在一切都按我的预期工作正常。