Integration with Razorpay
What You'll Need
Backbench account - Sign Up, the personal account will always remain free to use.
Razorpay account – sign up and generate your test credentials i.e key id and secret key (www.razorpay.com).
Prerequisites for the app
Sign In to Backbench account.
Select +, in the upper right corner to create a Bench. For example, say "bench_one" and select CREATE or hit Enter.
Frontend
Select +, in the upper right corner of file manager to create a html file . For example, say "razor.html" and select CREATE or hit Enter.
Copy and paste the code module from below.
Replace KEY-ID from Razorpay test dashboard.
Select save.
<html>
<form action="/razor" method="POST">
<!-- Note that the amount is in paise = 50 INR -->
<script
src="https://checkout.razorpay.com/v1/checkout.js"
data-key="KEY_ID"
data-amount="5000"
data-buttontext="Pay with Razorpay"
data-name="Merchant Name"
data-description="Purchase Description"
data-image="https://your-awesome-site.com/your_logo.jpg"
data-prefill.name="name"
data-prefill.email="support@razorpay.com"
data-theme.color="#F37254"
></script>
<input type="hidden" value="Hidden Element" name="hidden">
</form>
</html>
Backend
Select +, in the upper right corner to create a Module. For example, say "razorpay.js" and select CREATE or hit Enter.
Copy and paste the code module from below.
Replace API key from test dashboard.
Select save.
var request = require("request");
module.exports.endpoint = function(req, cb) {
request(
"https://API_KEY@api.razorpay.com/v1/payments/?count=5&skip=1",
function(error, response, body) {
if (error) {
console.log(error);
cb({
d: error.message
});
}
console.log("Response:", body);
cb(undefined, {
Response: response.body
});
}
);
};
Last updated