payu-intrepos / payumoney-new-sample-app

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

Some error occured #2

Closed MNGsulochana closed 6 years ago

MNGsulochana commented 7 years ago

device-2017-08-09-122100 device-2017-08-09-122142 device-2017-08-09-122204

Hi I am trying this code (gradle dependency)for the payment transaction with the production environment (live credentials)but its showing toast like "some error occured" so I tried with sandbox environment also for that also its showing the same will you help me out

I am attaching the screen shots also

MNGsulochana commented 7 years ago

hi is there any process and update on this issue

Shvet commented 7 years ago

Same problem after contacting customer support, If anyone has solved this problem please share!

A86S commented 7 years ago

same issue occurred, please let me know if any one have solved this issue.

Shvet commented 7 years ago

@A86S It will be solved by selecting "PRODUCTION" and putting your right credential and if you just want to check your code as for error then use "SANDBOX" option with payumoney's given credential.

This problem occurs due to wrong credential for wrong environment as suggested by customer care, they have given SANDBOX credential which is not to be changed and can be used for code checking or SDK implementation.

For real time transaction or PRODUCTION, you need to use your given key, salt and MID as it is suggested.

A86S commented 7 years ago

Hi @Shvet i have already using the production environment with correct keys and salt but still getting this error.

mayur19 commented 6 years ago

The error is because of wrong hash generation. You must need hash generator script on your server. I hope you are generating hash from server. In case, if you don't have hash generator script get it from here Just replace your salt key on that file. Also remove switch case from code you have right now and add following code. Then set merchantHash to mPaymentParams. You can refer the question below for proper request and response handling using volley.

jsonObject = new JSONObject(response); 
merchantHash = jsonObject.getString("result");

And for reference go through this stackoverflow answer. Please read all comments in answer. You can also refer code from question. Note: Hash generator algorithm is tested. Send all respective details properly. If possible, do not post any user defined variables.

A86S commented 6 years ago

yes, it was due to wrong hash key generation.

MNGsulochana commented 6 years ago

private void calculateServerSideHashPayment1() {

String url = "http://demo.oriondigi.com/" + "payumoney_service?token=" + token + "&txnid=" + txnId + "&amount=" + amount + "&firstname=" + firstName + "&email=" + email + "&phone=" + phone + "&productinfo=" + productName ;

Toast.makeText(this, "Please wait... Generating hash from server ... ", Toast.LENGTH_LONG).show();

StringRequest jsonobjectreq=new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {

        try {

    JSONObject jsonObject = new JSONObject(response);

            if(jsonObject.has("status"))
            {

                String status=jsonObject.optString("status");
                Log.d("ererorlistenr_status",status);
                if(status!=null)
        {

                    String hash=jsonObject.getString("result");
                    mPaymentParams.setMerchantHash(hash);

                    if (AppPreference.selectedTheme != -1) {

                        PayUmoneyFlowManager.startPayUMoneyFlow(mPaymentParams, MainActivity.this, AppPreference.selectedTheme, mAppPreference.isOverrideResultScreen());
                    } else {

                        PayUmoneyFlowManager.startPayUMoneyFlow(mPaymentParams, MainActivity.this, R.style.AppTheme_default, mAppPreference.isOverrideResultScreen());
                    }

                }
                else
                {

                    Toast.makeText(MainActivity.this, jsonObject.getString("result"), Toast.LENGTH_SHORT).show();

                }
            }

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

    }
},
        new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

                if (error instanceof NoConnectionError) {
                    Toast.makeText(MainActivity.this,
                            "please check internet connection",
                            Toast.LENGTH_SHORT).show();
                } else {

                    Log.d("ererorlistenr","erlistenr"+error.getMessage());
                    Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_SHORT).show();

                }

            }
        })
{
    @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        // return super.getParams();

        Map<String, String> params = new HashMap<String, String>();
        params.put(PayUmoneyConstants.KEY,mykey);
        params.put(PayUmoneyConstants.AMOUNT,amount+"");
        params.put(PayUmoneyConstants.TXNID,txnId);
        params.put(PayUmoneyConstants.EMAIL,userEmail);
        params.put(PayUmoneyConstants.PRODUCT_INFO,productName);
        params.put(PayUmoneyConstants.FIRSTNAME,firstName);
        params.put(PayUmoneyConstants.UDF1, udf1);
        params.put(PayUmoneyConstants.UDF2,udf2);
        params.put(PayUmoneyConstants.UDF3,udf3);
        params.put(PayUmoneyConstants.UDF4,udf4);
        params.put(PayUmoneyConstants.UDF5,udf5);

        return params;
    }
};
Volley.newRequestQueue(this).add(jsonobjectreq);

} this is the code i am using to get the hash from server , and my doubt is how its verifying hash key..is it correct or not