Last active
May 9, 2021 07:15
-
-
Save piyushgarg-dev/0120722c459474891c515bd635e4522d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buyButton.addEventListener('click', async (event) => { | |
const response = await fetch('/order', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ amount: 500 }) // Rs.500 | |
}); | |
const responseJson = await response.json(); | |
const { order } = responseJson; | |
const razorPayOptions = { | |
key: '<YOUR_KEY_ID_HERE>', | |
amount: 500, | |
currency: 'INR', | |
name: `Buy Shirt`, | |
description: `Paying for testing`, | |
order_id: order.id, | |
handler: function (response) { // handler function when payment is successfull | |
const razorpayPaymentId = response['razorpay_payment_id']; | |
const razorpayOrderId = response['razorpay_order_id']; | |
const razorpaySignature = response['razorpay_signature']; | |
console.log('Payment successfull'); | |
}, | |
}; | |
const razorpayInstance = new Razorpay(razorPayOptions); | |
razorpayInstance.open(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment