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

# Create payment Token

Let's see how to create a payment reference token

### Initialize Api

## Get Reference Token

<mark style="color:green;">`POST`</mark> `https://api.foloosi.com/aggregatorapi/web/initialize-setup`

#### Headers

| Name                                          | Type   | Description                              |
| --------------------------------------------- | ------ | ---------------------------------------- |
| secret\_key<mark style="color:red;">\*</mark> | String | Your Merchant Key get from Foloosi Panel |

#### Request Body

| Name                                                  | Type   | Description                    |
| ----------------------------------------------------- | ------ | ------------------------------ |
| currency<mark style="color:red;">\*</mark>            | String |                                |
| transaction\_amount<mark style="color:red;">\*</mark> | Double |                                |
| customer\_name                                        | String |                                |
| site\_return\_url                                     | String |                                |
| customer\_unique\_identifier                          | String |                                |
| billing\_country                                      | String |                                |
| billing\_postal\_code                                 | String |                                |
| billing\_state                                        | String |                                |
| customer\_city                                        | String |                                |
| customer\_address                                     | String |                                |
| customer\_mobile                                      | String |                                |
| customer\_email                                       | String |                                |
| description                                           | String | Product or order information   |
| optional1                                             | String | You can pass additional fields |
| optional2                                             | String | You can pass additional fields |
| optional3                                             | String | You can pass additional fields |
| partner\_unique\_reference                            | String | partner unique ID              |

{% tabs %}
{% tab title="200: OK Success Response" %}

```javascript
{
 "message": "Application setup successfully",
 "data": {
   "reference_token":
   "U0sjdGVzdF8kMnkkMTAkM21LRi0xZGliVDhldTV4NHlZSm9tZXZobnZxWTNEVnZmay1MdHNndTNFenNBTDU0clhWYkccVE4jRkxTQVBJNWM3Njk2ZDkwOWIzNxxSVCMkMnkkMTAkQXZ4ay9wdjlpTFlYLzRSZ2FjSkxpZWhHb2o0U0wvTFpZNXAyVjRGOVFycWNQZ2lHQ3VEZ08="
  }
 }
```

{% endtab %}

{% tab title="401: Unauthorized Invalid Header response" %}

```javascript
{
    "message": "Invalid secret key"
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid Api mode" %}

```javascript
{
    "message": "Invalid Integration settings! Kindly check both foloosi merchant application settings and your integration keys"
}
```

{% endtab %}

{% tab title="404: Not Found Invalid request type" %}

```javascript
{
    "message": "No routes found"
}
```

{% endtab %}
{% endtabs %}

### Api Specification

* Request call must be on **POST.**
* This Api will be used to confirm the feature you are about to Use.
* For **Hosting Payment** Method, You need to pass your callback URL in **site\_return*****\_*****url**.
* For **Saved Card Payment** Method, You need to pass your customer unique details like email,etc. to **customer\_unique\_identifier**.

#### Post Request Body

<table><thead><tr><th width="179">Request Body</th><th>Description</th><th data-hidden></th></tr></thead><tbody><tr><td>site_return_url</td><td><ol><li>If you are using hosting payment, this is mandatory.</li><li>Otherwise, this is an optional field.</li><li>It must be a String.</li><li>Get's the payment response after payment complete.</li><li><a href="/payment-methods/hosting-payment-method.md">click here</a> to learn about Hosting Payment Page.</li></ol></td><td></td></tr><tr><td>customer_unique_identifier</td><td><ol><li>This is mandatory when you are using saved card payment.</li><li>This data must be Unique like email id,customer id, etc.,</li></ol></td><td></td></tr><tr><td>partner_unique_reference</td><td><ol><li>This is mandatory when the tarnsaction is based on partner flow.</li></ol></td><td></td></tr></tbody></table>

### Support

Visit <https://www.foloosi.com> for support requests or email to <tech@foloosi.com>.

## Developed by

Foloosi Technologies Pvt Ltd.

## License

Copyrights (c) 2025 Foloosi
