如何在Razorpay中重定向成功或失败付款

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

我是新的集成支付网关。

如何在Razorpay成功或失败付款后重定向URL。我想要Js Code。我的事物处理函数可以使用该重定向。如何使用它们

var options = {
    "key": "rzp_test_aIfnpuWEudWnID",
    "amount": "35000", // 2000 paise = INR 20
    "name": "Vanakkam Chennai",
    "description": "I Run.. Becasue .. I Care",
    "image": "http://vanakkamchennai.com/images/about/chennai_2017.jpg",
    "callback_url": 'https://www.google.com',
    "handler": function (response){

            alert(response.razorpay_payment_id);


    },
    "prefill": {
        "name": "Harshil Mathur",
        "email": "[email protected]"
    },
    "notes": {
        "address": "Hello World"
    },
    "theme": {
        "color": "#F37254"
    }
};
javascript php payment-gateway
1个回答
6
投票

重定向用户的方法是更改​​location.href的值。删除alert(response.razorpay_payment_id);并根据是否定义了付款ID重定向用户:

// alert(response.razorpay_payment_id);
if (typeof response.razorpay_payment_id == 'undefined' ||  response.razorpay_payment_id < 1) {
  redirect_url = '/you-owe-money.html';
} else {
  redirect_url = '/thnx-you-paid.html';
}
location.href = redirect_url;

我的例子网址很幽默;用你的实际网址替换它们。此外,您可以阅读有关location.href and location redirection here的更多详细信息。

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