# Integration with Razorpay

## What You'll Need <a href="#what-youll-need" id="what-youll-need"></a>

Backbench account - [Sign Up](https://bench.backbench.io/signup), 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](http://www.razorpay.com)).

### Prerequisites for the app

1. Sign In to Backbench account.
2. Select +, in the upper right corner to create a Bench. For example, say "bench\_one" and select CREATE or hit Enter.

## Frontend <a href="#backend" id="backend"></a>

* 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.

```markup
<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 <a href="#backend" id="backend"></a>

* 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.

{% hint style="info" %}
The **API-KEY** here is a combination of Key ID and Key Secret. After generating the keys from the dashboard, you must download and save them securely. \
e.g. [https://\<key-id>:\<key-secret>@api.razorpay.com](https://%3Ckey-id%3E:%3Ckey-secret%3E@api.razorpay.com) )
{% endhint %}

{% tabs %}
{% tab title="NodeJS" %}

```javascript
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
            });
        }
    );
};
```

{% endtab %}

{% tab title="BBLANG" %}

```javascript
template:rhome()->{ 
    ' <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"
    data-amount="100"
    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> '
}

razor:rhandler(req)->{
    res = bb:http:get({
    url:"https://key:secrect@api.razorpay.com/v1/payments/?count=5&skip=1"
    })
    
    bb:log(res);
    return (res);
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://backbench.gitbook.io/backbench-docs/3rd-party-integrations/integration-with-razorpay.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
