> For the complete documentation index, see [llms.txt](https://docs.finpay.id/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.finpay.id/api-reference/finpay-widget-bill-payment/generate-widget.md).

# Generate Widget

Generate a widget for merchants, refer to the Payment and Billing section for detailed information. Token from response is the header value for Auth Bearer to allow access to Product, Billing, and Payment API’s. Timeout for token is data from timeout field request.

#### URL Endpoint <a href="#url-endpoint" id="url-endpoint"></a>

| Environment | Method | URL                                            |
| ----------- | ------ | ---------------------------------------------- |
| Development | POST   | <https://devo.finnet.co.id/v1/widget/generate> |
| Production  | POST   | <https://live.finnet.co.id/v1/widget/generate> |

#### Generate Request <a href="#generate-request" id="generate-request"></a>

| No | Name              | Type                                                        | Mandatory | Min Length | Max Length | Description                                                                |
| -- | ----------------- | ----------------------------------------------------------- | --------- | ---------- | ---------- | -------------------------------------------------------------------------- |
| 1  | backUrl           | String                                                      | M         | 1          | 100        | URL                                                                        |
| 2  | trxId             | String                                                      | M         | 1          | 32         | Transaction Id                                                             |
| 3  | merchantId        | String                                                      | M         | 1          | 100        | Merchant Id                                                                |
| 4  | uniqKey           | String                                                      | M         | 1          | 32         | Unique Key by Merchant                                                     |
| 5  | returnUrl         | String                                                      | M         | 1          | 100        | URL                                                                        |
| 6  | timestamp         | String                                                      | M         | 1          | 19         | YYYY-MM-DD HH:mm:ss                                                        |
| 7  | productCodes      | Array                                                       | M         | 1          | 999        | [List Of Biller](/api-reference/appendix/enumeration/product-code-list.md) |
| 8  | terminal          | String                                                      | M         | 1          | 8          | Terminal Id                                                                |
| 9  | terminalName      | String                                                      | M         | 1          | 20         | Terminal Name                                                              |
| 10 | billInfo          | [Object](/api-reference/developer-tools/payload-example.md) | O         | 1          | 6          | Detail of Bill Info                                                        |
| 11 | isNotif           | Boolean                                                     | M         | 1          | 5          | True or False                                                              |
| 12 | timeout           | String                                                      | M         | 1          | 10         | Timeout in second                                                          |
| 13 | merchantSignature | String                                                      | M         | 1          | 100        | SHA256                                                                     |

**Sample Generate Request (with BillInfo)**

```
{
   "backUrl": "url",
   "trxId": "12315139062851",
   "username": "{{username}}",
   "uniqKey": "12457365867",
   "returnUrl": "url",
   "timestamp": "2024-05-30 00:21:12",
   "productCodes": [
       "080003"
   ],
   "terminal": "48511",
   "terminalName": "Loket Bidakara",
   "billInfo": {
       "billNumber": "8888800393834857",
       "amount": "0",
       "period": "01",
       "customerName": "customer name",
       "customerPhone": "1234567890",
       "customerEmail": "customer@gmail.com"
   },
   "isNotif": true,
   "timeout": "30",
   "merchantSignature": "9f64e59637dc36d5348dbb3cc600a1c2f07c68b513de083790abbf26f2eeee91",
 }
```

**Sample Generate Request (without BillInfo)**

```
{
   "backUrl": "https://testing.com/back",
   "trxId": "12315139062851",
   "username": "{{userName}}",
   "uniqKey": "12457365867",
   "returnUrl": "https://testing.com/return",
   "timestamp": "2024-07-19 14:15:20", // YYYY-MM-DD HH:mm:ss
   "productCodes": [
       "080003"
   ],
   "terminal": "Term0001",
   "terminalName": "Terminal Testing",
   "isNotif": true, 
   "timeout": "1800", 
   "merchantSignature": "55f70ab4b1ebaba89af351885f8a019db4713aaa498642f43f8f9ae1731430e7"
}
```

#### Generate Response <a href="#generate-response" id="generate-response"></a>

| No | Name         | Type                                                              | Mandatory | Min Length | Max Length | Description                                  |
| -- | ------------ | ----------------------------------------------------------------- | --------- | ---------- | ---------- | -------------------------------------------- |
| 1  | responseCode | [Enum](/api-reference/appendix/enumeration/response-code-list.md) | M         | 1          | 7          | Status Code for Generate Widget              |
| 2  | responseDesc | String                                                            | M         | 1          | 100        | Status Description for Generate Widget       |
| 3  | redirectURL  | String                                                            | M         | 1          | 100        | URL to Widget App with access token included |

**Sample Generate Response**

```
{
    "data": {
        "responseCode": "2000000",
        "responseDesc": "Success",
        "redirectURL": "http://localhost:3000/?token=60f7f579683f8ef6e22e4c0b755364c82a42218236c9dd5519d423590967df2a"
    },
    "pagination": [],
    "stat_code": "APP:SUCCESS",
    "stat_msg": "Success"
}
```


---

# 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.finpay.id/api-reference/finpay-widget-bill-payment/generate-widget.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.
