0

我正在将 payUMoney 集成到我的 Android 应用程序中。在两种环境(即测试和生产)中成功付款后,我只会得到paymentId 。我还需要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) {
        }
    }
}

PayUMoney 响应的 Logcat 快照

PayUMoney SDK-版本:版本名称“6.1.0”

4

1 回答 1

0

我也面临同样的问题,但经过一点研究,我发现我们需要使用不同的发票 api 分别生成发票。您可以在下面的 URL 中找到发票 API 的文档...

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

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

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  
)  

然后您可以在服务器端使用它生成发票或做任何您想做的事情。

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

于 2017-05-22T10:31:24.137 回答