Java Razor Pay回调方法不会在后台调用
我已经在我的Android应用程序中实现了Razor支付网关。借记卡/信用卡一切正常 我面临UPI付款的问题。实际上,对于UPI支付,用户必须访问UPI应用程序进行支付。UPI的一切都很好,但唯一的问题是,如果支付成功,或者在我再次访问该应用之前,或者除非我再次访问该应用,否则不会调用回调方法 这对我来说是一个大问题,因为有时候如果用户通过UPI应用程序付费,而不再次打开应用程序,我很难在数据库中保存付款条目 每次调用成功回调方法时,我都在数据库中保存条目。当应用程序处于后台但未关闭时,如何调用成功方法 以下是代码片段: 要打开付款活动,请执行以下操作:Java Razor Pay回调方法不会在后台调用,java,android,callback,payment-gateway,razorpay,Java,Android,Callback,Payment Gateway,Razorpay,我已经在我的Android应用程序中实现了Razor支付网关。借记卡/信用卡一切正常 我面临UPI付款的问题。实际上,对于UPI支付,用户必须访问UPI应用程序进行支付。UPI的一切都很好,但唯一的问题是,如果支付成功,或者在我再次访问该应用之前,或者除非我再次访问该应用,否则不会调用回调方法 这对我来说是一个大问题,因为有时候如果用户通过UPI应用程序付费,而不再次打开应用程序,我很难在数据库中保存付款条目 每次调用成功回调方法时,我都在数据库中保存条目。当应用程序处于后台但未关闭时,如何调用
Intent intent = new Intent(context, PaymentActivity.class);
intent.putExtra("orderId", order_id);
intent.putExtra("totalAmount", String.valueOf(totalPrice));
intent.putExtra("email", email);
intent.putExtra("phoneNo", phone_number);
intent.putExtra("userId", user_id);
startActivityForResult(intent, 2);
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
要调用Razor pay活动:
final Activity activity = this;
price = Double.parseDouble(total_price);
double paisa_double = price * 100;
int paisa_int = (int) paisa_double;
final Checkout checkout = new Checkout();
checkout.setKeyID(getResources().getString(R.string.razor_pay_key));
try {
JSONObject options = new JSONObject();
options.put("name", "Razorpay Corp");
options.put("description", "Order No: " + order_id);
options.put("order_id", razor_id);
//You can omit the image option to fetch the image from dashboard
options.put("image", "https://s3.amazonaws.com/rzp-mobile/images/rzp.png");
options.put("currency", "INR");
options.put("amount", String.valueOf(paisa_int));
//options.put("amount", "100");
JSONObject preFill = new JSONObject();
preFill.put("email", email);
preFill.put("contact", phone_no);
options.put("prefill", preFill);
JSONObject notes = new JSONObject();
notes.put("notes", order_id);
options.put("notes", notes);
checkout.open(activity, options);
} catch (Exception e) {
Toast.makeText(activity, "Error in payment: " + e.getMessage(), Toast.LENGTH_SHORT)
.show();
e.printStackTrace();
}
以下是回调方法:
@Override
public void onPaymentSuccess(String razorpayPaymentID, PaymentData paymentData) {
try {
//Toast.makeText(this, "Payment Successful: " + razorpayPaymentID, Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.putExtra("razorpayPaymentID", razorpayPaymentID);
setResult(2, intent);
finish();
} catch (Exception e) {
Log.e(TAG, "Exception in onPaymentSuccess", e);
}
}
@Override
public void onPaymentError(int code, String response, PaymentData paymentData) {
try {
Toast.makeText(this, "Payment failed: " + code + " " + response, Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Log.e(TAG, "Exception in onPaymentError", e);
}
}
针对上述问题,在后端代码中使用Razor pay web挂钩 链接: