【问题标题】:How to Redirect Success or Failure Payment in Razorpay如何在 Razorpay 中重定向成功或失败付款
【发布时间】:2017-04-14 07:57:46
【问题描述】:

我是集成支付网关的新手。

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

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": "harshil@razorpay.com"
    },
    "notes": {
        "address": "Hello World"
    },
    "theme": {
        "color": "#F37254"
    }
};

【问题讨论】:

  • 如果事务失败,则不调用处理程序。如果失败,我如何调用处理程序?

标签: javascript php payment-gateway


【解决方案1】:

重定向用户的方法是更改​​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 的更多详细信息。

【讨论】:

  • 我们可以对其他部分采取任何行动吗?
  • @godwin 是的!您可以在else 块中进行any 操作!让您的创意源源不断!
  • 但是在else部分中无法访问razorpay选项变量之外的其他应用程序部分,它只允许重定向,所以我只有在重定向后才满足我的需要
  • 我真的对你没有任何建议;但是,如果是我,我会console.log(response) 然后从那里开始。我很高兴你实现了你的需求,即使只是在重定向之后。
  • 明白..会做同样的@WEBjuju
猜你喜欢
  • 2022-01-11
  • 2019-12-29
  • 2021-05-27
  • 2023-03-30
  • 2019-04-09
  • 1970-01-01
  • 2014-11-07
  • 2018-06-08
  • 2018-07-16
相关资源
最近更新 更多