0

I'm integrating payUMoney in my Android application. I'm getting only paymentId after successful payment in both environment i.e Test & Production. I need Transaction Details as well from payUMoney. I have also contacted payUMoney technical team but not getting any response.

See image attached for payUMoney response which I have printed in Logcat.

What I have tried is like below.

public void makePayment() {
    String phone = "8882434664";
    String productName = "product_name";
    String firstName = "piyush";
    String txnId = "0nf7" + System.currentTimeMillis();
    String email = "piyush.jain@payu.in";
    String sUrl = AppConstant.BASE_URL + "/mob-payment/success";
    String fUrl = AppConstant.BASE_URL + "/mob-payment/failure";
    String udf1 = "";
    String udf2 = "";
    String udf3 = "";
    String udf4 = "";
    String udf5 = "";
    boolean isDebug = true;
    String key = "dRQuiA";
    String merchantId = "4928174";

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

    builder.setAmount(1.0)
            .setTnxId(txnId)
            .setPhone(phone)
            .setProductName(productName)
            .setFirstName(firstName)
            .setEmail(email)
            .setsUrl(sUrl)
            .setfUrl(fUrl)
            .setUdf1(udf1)
            .setUdf2(udf2)
            .setUdf3(udf3)
            .setUdf4(udf4)
            .setUdf5(udf5)
            .setIsDebug(isDebug)
            .setKey(key)
            .setMerchantId(merchantId);

    PayUmoneySdkInitilizer.PaymentParam paymentParam = builder.build();
    calculateServerSideHashAndInitiatePayment(paymentParam);
}

private void calculateServerSideHashAndInitiatePayment(final PayUmoneySdkInitilizer.PaymentParam paymentParam) {

    String url = "https://test.payumoney.com/payment/op/calculateHashForTest";

    StringRequest jsonObjectRequest = 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(SdkConstants.STATUS)) {
                    String status = jsonObject.optString(SdkConstants.STATUS);
                    if (status != null || status.equals("1")) {
                        String hash = jsonObject.getString(SdkConstants.RESULT);
                        paymentParam.setMerchantHash(hash);
                        PayUmoneySdkInitilizer.startPaymentActivityForResult(ActivityConfirmOrder.this, paymentParam);
                    } else {
                        Toast.makeText(ActivityConfirmOrder.this,
                                jsonObject.getString(SdkConstants.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(ActivityConfirmOrder.this,
                        ActivityConfirmOrder.this.getString(R.string.connect_to_internet),
                        Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(ActivityConfirmOrder.this,
                        error.getMessage(),
                        Toast.LENGTH_SHORT).show();
            }
        }
    }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            return paymentParam.getParams();
        }
    };
    Volley.newRequestQueue(this).add(jsonObjectRequest);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PayUmoneySdkInitilizer.PAYU_SDK_PAYMENT_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {

            StringBuilder str = new StringBuilder();
            Bundle bundle = data.getExtras();
            if (bundle != null) {
                Set<String> keys = bundle.keySet();
                Iterator<String> it = keys.iterator();
                while (it.hasNext()) {
                    String key = it.next();
                    str.append(key);
                    str.append(":");
                    str.append(bundle.get(key));
                    str.append("\n\r");
                }
                Log.e("res: ", str.toString());
            }

        } else if (resultCode == RESULT_CANCELED) {
        } else if (resultCode == PayUmoneySdkInitilizer.RESULT_FAILED) {
            if (data != null) {
                if (data.getStringExtra(SdkConstants.RESULT).equals("cancel")) {
                } else {
                }
            }
        } else if (resultCode == PayUmoneySdkInitilizer.RESULT_BACK) {
        }
    }
}

Logcat Snapshot of PayUMoney Response

PayUMoney SDK-Version: versionName "6.1.0"

Maulik Dodia
  • 1,629
  • 2
  • 21
  • 48

1 Answers1

0

I was also facing the same problem, but after little bit of research, I have found that we need to generate invoice separately using different invoice api. You can find the bellow URL for the documentation for invoice api...

https://www.payumoney.com/dev-guide/products/invoicing.html

@MaulikDodia Actually you need to create success url on your own, then the payumoney will send all the data directly like this in your success url...

Array
(
    [mihpayid] => 40399371551*******  
    [mode] => DC  
    [status] => success  
    [unmappedstatus] => captured  
    [key] => d****A  
    [txnid] => INV0****0531  
    [amount] => 1000.0  
    [addedon] => 2017-05-31 13:16:12  
    [productinfo] => ****  
    [firstname] => ****  
    [lastname] =>   
    [address1] =>   
    [address2] =>   
    [city] => null  
    [state] =>   
    [country] => null  
    [zipcode] =>       
    [email] => ***@test.xxx  
    [phone] =>   
    [udf1] =>   
    [udf2] =>   
    [udf3] =>   
    [udf4] =>   
    [udf5] =>   
    [udf6] =>   
    [udf7] =>   
    [udf8] =>   
    [udf9] =>   
    [udf10] =>   
    [hash] => ***************  
    [field1] => 715140****61  
    [field2] => 99***9  
    [field3] => 8523310*****511  
    [field4] => -1  
    [field5] =>   
    [field6] =>   
    [field7] =>   
    [field8] =>   
    [field9] => SUCCESS  
    [PG_TYPE] => HDFCPG  
    [encryptedPaymentId] => DB****EB8****02A****9FE4C****CB3  
    [bank_ref_num] => 8****016137****  
    [bankcode] => MAST  
    [error] => E000  
    [error_Message] => No Error  
    [name_on_card] => payu  
    [cardnum] => 512345XXXXXXXX46  
    [cardhash] => This field is no longer supported in postback params.  
    [amount_split] => {"PAYU":"1000.0"}  
    [payuMoneyId] => 1******0  
    [discount] => 0.00  
    [net_amount_debit] => 1000  
)  

Then you can generate invoice using that on the server side or do whatever you want.

Source: I have done all the code and it is working. Hope it helps... thanks

Sayan Mukherjee
  • 352
  • 2
  • 21
  • That means I need to call **INVOICE API** with **paymentId** and from that I will get all other details like Customer Card Name, Transaction Id ect. etc....Is that what you meant?@Sayan Mukherjee – Maulik Dodia May 22 '17 at 12:04
  • Yes, to generate invoice like details, you need to use this api, dont forget to mark this ans useful – Sayan Mukherjee May 23 '17 at 11:22
  • I need to check whether you solution is working or not, than after I will accept your answer here. Thanks for information.@SayanMukherjee – Maulik Dodia May 23 '17 at 13:56
  • Can you provide your code link? We were about to work with PayUMoney, but for some reason we are now working with PayUBiz. If you have some sample code which you have integrated than give link. I will try and accept your answer as **RIGHT** answer.@SayanMukherjee – Maulik Dodia May 31 '17 at 11:18
  • If you want to integrate payUBiz with your app, then it is a good choice, you can get all the response in your app itself. Here is the sample, click the link and fork/clone it. Don't forget to mark my answer as right. Happy to help. https://github.com/msayanece/PaymentGatewayApp P.S: If you want payUmoney sample code, let me know, I will post the link here – Sayan Mukherjee Jun 01 '17 at 05:53
  • I had integrated PayUBiz successfully in one of our project. I need your PayUMoney code link.@SayanMukherjee – Maulik Dodia Jun 01 '17 at 06:47