Razor Pay回调方法未在后台调用

问题描述 投票:0回答:1

我已经在Android应用程序中实现了Razor Pay付款网关。借记卡/信用卡一切正常。

我面临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);

致电剃须刀付款活动:

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);
        }
    }
java android callback payment-gateway razorpay
1个回答
0
投票

在上述问题的后端代码中使用Razor pay web hooks。

链接:https://razorpay.com/docs/webhooks/

© www.soinside.com 2019 - 2024. All rights reserved.