How to avoid csrf from payment gateway; I am having problems with razorpay payment processing

Viewed 56

This is my checkout code

<button id="chechout">checkoout</button>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
    document.getElementById("chechout").onclick = function(e) {
        var options = {
            "key": "<%= key %>",
            "currency": "INR",
            "name": "widebus",
            "description": "widebus Transaction",
            "image": "/favicon.ico",
            "order_id": "<%=order.id%>",
            "callback_url": "/is-order-complete",
            "theme": {
                "color": "#0EB9F2"
            }
        };
        var rzp1 = new Razorpay(options);
        rzp1.open();
        e.preventDefault();
    }
</script>

I have initialised csrf protection to my project so it is hard to get through with this. I get this error

ForbiddenError: invalid csrf token at csrf (/Users/midlaj/Desktop/web/node_modules/csurf/index.js:112:19)

the code isn't reaching my callback route which is /is-order-complete

where I check the payment like this

instance.payments.fetch(req.body.razorpay_payment_id).then((payment_docs) => {
0 Answers
Related