PayUmoney payment fails eveytime

564 Views Asked by At

I am using following java code to start payment gateway

String hashKey = hashCal(MERCHANT_KEY + "|" + String.valueOf(System.currentTimeMillis()) + "|" + Double.parseDouble("1") + "|" + "productName" + "|" + FIRST_NAME + "|" + EMAIL + "|" + "" + "|" + "" + "|" + "" + "|" + "" + "|" + "" + "|" + salt);
PayUmoneySdkInitializer.PaymentParam.Builder builder = new PayUmoneySdkInitializer.PaymentParam.Builder();
        builder.setAmount(Double.parseDouble("1"))
                .setTxnId(String.valueOf(System.currentTimeMillis()))
                .setPhone(Constants.MOBILE)
                .setProductName("productName")
                .setFirstName(FIRST_NAME)
                .setEmail(EMAIL)
                .setsUrl(SURL)
                .setfUrl(FURL)
                .setUdf1("")
                .setUdf2("")
                .setUdf3("")
                .setUdf4("")
                .setUdf5("")
                .setIsDebug(DEBUG)
                .setKey(MERCHANT_KEY)
                .setMerchantId(MERCHANT_ID);
        final PayUmoneySdkInitializer.PaymentParam paymentParam = builder.build();
        paymentParam.setMerchantHash(hashKey);
        String url = Constants.MONEY_HASH;
        PayUmoneyFlowManager.startPayUMoneyFlow(paymentParam, this, R.style.AppTheme, true);

To calculate hash key in java only I am using following code:

public static String hashCal(String str) {
        byte[] hashseq = str.getBytes();
        StringBuilder hexString = new StringBuilder();
        try {
            MessageDigest algorithm = MessageDigest.getInstance("SHA-512");
            algorithm.reset();
            algorithm.update(hashseq);
            byte messageDigest[] = algorithm.digest();
            for (byte aMessageDigest : messageDigest) {
                String hex = Integer.toHexString(0xFF & aMessageDigest);
                if (hex.length() == 1) {
                    hexString.append("0");
                }
                hexString.append(hex);
            }
        } catch (NoSuchAlgorithmException ignored) {
        }
        return hexString.toString();
    }

Please let me know If i am doing some mistake in code or otherwise.

I am using payUmoney library:

implementation 'com.payumoney.sdkui:plug-n-play:1.2.0'

And I have recently created my payUmoney account for testing purpose only and haven't set up business profile, pan number and data. Does that can be the reason? But in documentation no such information is written to get starting as developer.

I got error toast Some error occured. but unable to find the reason of error. Comment If anyone can help with the issue.

Thanks in advance.

2

There are 2 best solutions below

0
On

Check this Link of payUmoney https://www.payumoney.com/faq-dev-support.html

in this link mention to point At the time of sending a Payment Request, I am being notified that “Some Error Occurred”. Why is this happening?

Hope this will help you.

0
On

This is not necessary that you should setup your account fully to use it services. PayUmoney integration provides test keys which can be used by developers for first development process and use test cards provided by payUmoney only to make test payments only.

MERCHANT_KEY = "rjQUPktU"
MERCHANT_ID = "4934580"

these are two test keys required for initial setup.