Reputation:
I am using razorpay in my django website. After any successful payment, it is redirecting to localhost/purchase, but I want to send it to my url. How to achieve that?
Upvotes: 3
Views: 3717
Reputation: 38
You can achieve in two ways
var options = { .... "handler": function (response){ alert(response.razorpay_payment_id); alert(response.razorpay_order_id); alert(response.razorpay_signature); window.location = "URL" }, ... };
*> var options = { ....
"callback_url":"https://eneqd3r9zrjok.x.pipedream.net/", .... };*
For More check this documentation [https://razorpay.com/docs/payments/server-integration/python/payment-gateway/build-integration/#code-to-add-pay-button][1]
Upvotes: 0
Reputation: 356
There two way to create the checkout form. Automatic and Manual. I always prefer Manual.U will have more control. The checkout javascript hands over the payment details to a javascript handler function (handler). You can then use the payment id, send it to your back-end & verify the payment as you wish and redirect to what page you want, mostly done by ajax call.
<button id="rzp-button1">Pay</button>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
var options = {
"key": "YOUR_KEY_ID",
"amount": "2000", // 2000 paise = INR 20
"name": "Merchant Name",
"description": "Purchase Description",
"image": "/your_logo.png",
"handler": function (response){
alert(response.razorpay_payment_id);
// do an ajax call to backend and capture and verify the payment then
//redirect to payment success page.
},
"prefill": {
"name": "Harshil Mathur",
"email": "[email protected]"
},
"notes": {
"address": "Hello World"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
document.getElementById('rzp-button1').onclick = function(e){
rzp1.open();
e.preventDefault();
}
</script>
source : Razorpay Docs
Upvotes: 3
Reputation: 404
Instead of using default value in form tag in form tag action="/purchase"
add your custom url in action like, action="http://{yoururl}"
hope this works for you.
Upvotes: 2
Reputation: 15
I just started using razorpay, And according to me, what you are asking is redirecting to a specific url after successful payment. You can add a webhook in razorpay, in which razorpay will send you the status and details of the payment, and after checking the status of the response in the given url in webhook, you can then redirect user wherever you want from your function. if this is what you were asking and still have a doubt, feel free to ask.
Upvotes: 0