PayUMoney - Android:成功付款后,只能从payUMoney SDK获得** paymentId **

时间:2017-05-02 12:38:51

标签: android-fragments android-activity payment-gateway payu payumoney

我在我的Android应用程序中集成了payUMoney。在两种环境中成功付款后,我只得 paymentId ,即Test&生产。我需要来自payUMoney的交易细节。我还联系了 payUMoney 技术团队,但未收到任何回复。

请参阅我在Logcat中打印的payUMoney响应所附的图片。

我尝试的内容如下所示。

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”

1 个答案:

答案 0 :(得分:0)

我也遇到了同样的问题,但经过一些研究后,我发现我们需要使用不同的发票api单独生成发票。您可以在发票api ...

的文档中找到以下URL

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

@MaulikDodia实际上你需要自己创建成功网址,然后payumoney将在你的成功网址中直接发送所有数据......

AuthenticationToken

然后,您可以在服务器端使用该发票生成发票或执行您想要的任何操作。

来源:我已经完成了所有代码并且它正在运行。希望它有所帮助......谢谢