我已经核实了Payumoney的帐户。当点击沙箱模式下的paynow按钮时,它会显示“发生了一些错误”。我使用了pnp SDK。
此代码用于onclick on paynow按钮。
payNowButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
userAddress = address_line1.get(0) + "," + address_line2.get(0) + "," + address_pincode.get(0)
+ "," + address_taluka + "," + address_district + "," + address_state;
if (payment_type.equals("online")) {
launchPayUMoneyFlow();
} else if (payment_type.equals("cod")) {
launchNormalFlow();
}
}
});
这是哈希计算函数
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();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result Code is -1 send from Payumoney activity
Log.d("MainActivity", "request code " + requestCode + " resultcode " + resultCode);
if (requestCode == PayUmoneyFlowManager.REQUEST_CODE_PAYMENT && resultCode == RESULT_OK && data !=
null) {
TransactionResponse transactionResponse = data.getParcelableExtra(PayUmoneyFlowManager
.INTENT_EXTRA_TRANSACTION_RESPONSE);
ResultModel resultModel = data.getParcelableExtra(PayUmoneyFlowManager.ARG_RESULT);
// Check which object is non-null
if (transactionResponse != null && transactionResponse.getPayuResponse() != null) {
if (transactionResponse.getTransactionStatus().equals(TransactionResponse.TransactionStatus.SUCCESSFUL)) {
//Success Transaction
} else {
//Failure Transaction
}
// Response from Payumoney
String payuResponse = transactionResponse.getPayuResponse();
// Response from SURl and FURL
String merchantResponse = transactionResponse.getTransactionDetails();
new AlertDialog.Builder(this)
.setCancelable(false)
.setMessage("Payu's Data : " + payuResponse + "\n\n\n Merchant's Data: " + merchantResponse)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
}).show();
} else if (resultModel != null && resultModel.getError() != null) {
Log.d(TAG, "Error response : " + resultModel.getError().getTransactionResponse());
} else {
Log.d(TAG, "Both objects are null!");
}
}
}
String txnId="";
private void launchPayUMoneyFlow() {
PayUmoneyConfig payUmoneyConfig = PayUmoneyConfig.getInstance();
//Use this to set your custom text on result screen button
payUmoneyConfig.setDoneButtonText("");
//Use this to set your custom title for the activity
payUmoneyConfig.setPayUmoneyActivityTitle("TEST GATEWAY");
PayUmoneySdkInitializer.PaymentParam.Builder builder = new PayUmoneySdkInitializer.PaymentParam.Builder();
try {
amount = Double.parseDouble(final_total);
} catch (Exception e) {
e.printStackTrace();
}
txnId = System.currentTimeMillis() + "";
String phone = userMobile;
String productName = product_name;
String firstName = userName;
String email = "mayurdusane1@gmail.com";
String udf1 = order_id;
String udf2 = billingInfo;
String udf3 = userAddress;
String udf4 = userUID;
String udf5 = request_time;
String udf6 = "";
String udf7 = "";
String udf8 = "";
String udf9 = "";
String udf10 = "";
AppEnvironment appEnvironment = AppEnvironment.SANDBOX;
builder.setAmount(amount)
.setTxnId(txnId)
.setPhone(phone)
.setProductName(productName)
.setFirstName(firstName)
.setEmail(email)
.setsUrl(appEnvironment.surl())
.setfUrl(appEnvironment.furl())
.setUdf1(udf1)
.setUdf2(udf2)
.setUdf3(udf3)
.setUdf4(udf4)
.setUdf5(udf5)
.setUdf6(udf6)
.setUdf7(udf7)
.setUdf8(udf8)
.setUdf9(udf9)
.setUdf10(udf10)
.setIsDebug(false)
.setKey("KEYHERE")
.setMerchantId("MERCHANTIDHERE");
try {
mPaymentParams = builder.build();
} catch (Exception e) {
// some exception occurred
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
payNowButton.setEnabled(true);
}
}
/**
* This method generates hash from server.
*
* @param paymentParam payments params used for hash generation
*/
public void generateHashFromServer(PayUmoneySdkInitializer.PaymentParam paymentParam) {
RequestQueue queue1 = Volley.newRequestQueue(this);
String url = "URL GOES HERE"; // Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONArray dataArray;
JSONObject jsonObject;
String merchantHash="";
try {
jsonObject = new JSONObject(response);
//dataArray = jsonObject.getJSONArray(JSON_ARRAY);
//Toast.makeText(getApplicationContext(), "m" + jsonObject.getString("result"), Toast.LENGTH_SHORT).show();
merchantHash = jsonObject.getString("result");
} catch (JSONException e) {
e.printStackTrace();
}
//setting up response values to the fragment
if (merchantHash.isEmpty() || merchantHash.equals("")) {
Toast.makeText(FinalCheckoutActivity.this, "Could not generate hash", Toast.LENGTH_SHORT).show();
} else {
mPaymentParams.setMerchantHash(merchantHash);
//Toast.makeText(FinalCheckoutActivity.this, "m:"+mPaymentParams.getParams(), Toast.LENGTH_SHORT).show();
//Log.e(TAG, "onPostExecute: "+mPaymentParams.getParams() );
PayUmoneyFlowManager.startPayUMoneyFlow(mPaymentParams, FinalCheckoutActivity.this, -1, false);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplication(), "Error:" + error, Toast.LENGTH_LONG).show();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put(PayUmoneyConstants.KEY,"KEYHERE" );
params.put(PayUmoneyConstants.AMOUNT,amount+"" );
params.put(PayUmoneyConstants.TXNID,txnId);
params.put(PayUmoneyConstants.EMAIL,userEmail);
params.put(PayUmoneyConstants.PRODUCT_INFO,product_name);
params.put(PayUmoneyConstants.FIRSTNAME,userName);
params.put(PayUmoneyConstants.UDF1,order_id );
params.put(PayUmoneyConstants.UDF2,billingInfo );
params.put(PayUmoneyConstants.UDF3,userAddress);
params.put(PayUmoneyConstants.UDF4,userUID);
params.put(PayUmoneyConstants.UDF5,request_time);
return params;
}
};
queue1.add(stringRequest);
}
执行流程:
在执行PayumOneyFlowManager.startPayumOneyFlow()之后,它会显示“发生了一些错误”。
<?php
$key=$_POST["key"];
$salt="SALTHERE";
$txnId=$_POST["txnid"];
$amount=$_POST["amount"];
$productName=$_POST["productInfo"];
$firstName=$_POST["firstName"];
$email=$_POST["email"];
$udf1=$_POST["udf1"];
$udf2=$_POST["udf2"];
$udf3=$_POST["udf3"];
$udf4=$_POST["udf4"];
$udf5=$_POST["udf5"];
$payhash_str = $key . '|' . checkNull($txnId) . '|' .checkNull($amount) . '|' .checkNull($productName) . '|' . checkNull($firstName) . '|' . checkNull($email) . '|' . checkNull($udf1) . '|' . checkNull($udf2) . '|' . checkNull($udf3) . '|' . checkNull($udf4) . '|' . checkNull($udf5) . '|||||||'. $salt;
function checkNull($value) {
if ($value == null) {
return '';
} else {
return $value;
}
}
$hash = strtolower(hash('sha512', $payhash_str));
$arr['result'] = $hash;
$arr['status']=0;
$arr['errorCode']=null;
$arr['responseCode']=null;
$output=$arr;
echo json_encode($output);
?>
注意:哈希生成脚本从PayUMoney技术团队获得。我提到了几乎所有关于stackoverflow和GitHub的问题。仍然得到这个错误。我提到的消息来源很少。
PayU SDK应该用正确的错误消息替换这个“发生了一些错误”。
这个问题是因为您的散列与PayUserVer不匹配。
而它是不匹配的,因为。
. checkNull($udf5) . '||||||'. $salt
登录后,它生成了一个哈希值,但仍然给出错误“Some problem currened!try tain”。
我试图将payUMoney集成到Node.js中,但我得到一个错误,作为 这里显示缺少参数furl,但我提供了这一点。我的代码如下:
我正在我的Android应用程序中集成payUMoney。在测试和生产两个环境中都成功支付后,我只得到paymentId。我需要交易细节以及从Payumoney。我也联系了payUMoney的技术团队,但没有得到任何回应。 请看附上的图片为payUMoney响应,我已经打印在logcat。 我所尝试的如下所示。
遇到未捕获的异常类型:PayPal \ Exception \ PayPalConnectionException 消息:访问https://API . sandbox . paypal . com/v1/payments/payment/PAYID-l 6 lqrca 096350664 r 714145g时得到Http响应代码401。 文件名:/home/mastai 9/public _ h
我正在使用php集成的payumoney支付网关。现在我已经差不多做了,但只想在成功或失败后的响应自定义参数,当我从payumoney网站的付款过程返回。 因此,如果有人对此有想法,那么它将非常感谢。
我计划将Razorpay支付网关集成到我的客户网站中,该网站已在WordPress中开发,其中的场景如下。 用户将填写他的需求查询表。 然后根据客户的要求,业主将回复成本和一些代码给客户(通过移动/电子邮件通信)。 客户将在网站的支付页面提交表单(姓名,金额,代码为备注和电子邮件ID),该表单将重定向到支付网关页面。 在WordPress网站上,该插件(Razorpay Quick Payment