> For the complete documentation index, see [llms.txt](https://docs.ippopay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ippopay.com/javascript-integration.md).

# Javascript Integration

## Configuration

Initialize your object by passing your order id and public key:

> Get Order Id from Create order api from next step

```javascript
<script type="text/javascript" src="https://js.ippopay.com/scripts/ippopay.v1.js"></script>
<script type="text/javascript">
var order_id;
var options = {
    "order_id" : order_id, //Get order_id params value from Create Order from next step
    "public_key" : "pk_live_xxxxxxxxx"
}
var ipay = new Ippopay(options);
```

You can get your Public and Secret key from the api [dashboard](https://app.ippopay.com/settings/api).

## Create Order

Create order from Server side using below API and get the Order id. [Click here](https://docs.ippopay.com/server-side-integrations/rest-api#create-order) to know how to create a order.

## Open the payment view

Use the below code to open the payment view for the customers to pay.

```javascript
ipay.open();
```

## Close the payment view

Use the below code to close the payment view.

```javascript
ipay.close();
```

## Response Handlers

For Success and Error handlers use the below handler function for payment response

```javascript
ippopayHandler(response, function (e) {
    if(e.data.status == 'success'){
        console.log(e.data)
    }
    if(e.data.status == 'failure'){
        console.log(e.data)
    }
});

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ippopay.com/javascript-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
