# API References (1.0)

## Authentication

To authenticate your account, you have to include your secret API key in the request which can be accessed in the Dashboard. You may generate your API Key via the Settings page on the Partner dashboard as described further [here](https://idrtgateway.gitbook.io/pintubusinessidrtgateway/dashboard-guide#obtaining-api-key).

## API References

### API Request

The URL to the API service can be accessed through the following links:

* **Sandbox :**  `https://sandbox.idrt-gateway.rupiahtoken.com/v1` &#x20;
* **Live :** `https://idrt-gateway.rupiahtoken.com/v1`&#x20;

### Purchase

#### Submit Purchase

Create IDRT Purchase is a process where your user can request to `purchase / deposit` IDRT via the virtual account (VA) bank transfer through this IDRT Fiat Gateway API. Once the user creates an IDRT purchase / deposit request, our system will feed the required information to process such transaction.

## /submit

<mark style="color:green;">`POST`</mark> `/v1/purchase/submit`

\
This endpoint allows you to create IDRT purchase request for your user.

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer {API\_KEY} |

#### Request Body

| Name     | Type   | Description                                      |
| -------- | ------ | ------------------------------------------------ |
| name     | string | Full Name                                        |
| user\_id | string | User ID of your user registered on your platform |
| amount   | number | IDRT amount                                      |
| bank     | string | PERMATA, MANDIRI, BRI                            |

{% tabs %}
{% tab title="200 IDRT purchase request has been processed. We will notify through callback URL." %}

```
{
    "purchase_id": "iv-9Fa4ED"
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "code": "PURCHASE_IN_PROGRESS"
}
```

{% endtab %}
{% endtabs %}

#### Cancel  Purchase

Cancel Purchase is a process where your user requests to cancel his/her purchase request that was created previously but has not been completed yet. A purchase request will be automatically cancelled within 24 hours. However, your user can cancel it manually by himself/herself in the case where he/she would like to create another purchase request. Your user cannot create two purchase requests at the same time. Accordingly, your user needs to complete his/her existing purchase request or cancel it to create another new purchase request.

## /cancel

<mark style="color:green;">`POST`</mark> `/v1/purchase/cancel`

This endpoint allows you to cancel IDRT purchase request for your user.

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer {API\_KEY} |

#### Request Body

| Name         | Type   | Description          |
| ------------ | ------ | -------------------- |
| amount       | number | IDRT Purchase amount |
| purchase\_id | string | Purchase ID          |

{% tabs %}
{% tab title="200 will add" %}

```
{
    "purchase_id": "iv-9Fa4ED"
}
```

{% endtab %}

{% tab title="400 " %}

```
{
 "code" : "PURCHASE_ID_NOT_FOUND"
}

```

{% endtab %}
{% endtabs %}

## /simulate-payment

<mark style="color:green;">`POST`</mark> `/v1/purchase/simulate-payment`

You can simulate payment of your purchase in sandbox mode.

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer {API\_KEY} |

#### Request Body

| Name         | Type   | Description          |
| ------------ | ------ | -------------------- |
| purchase\_id | string | Purchase ID          |
| amount       | number | IDRT Purchase Amount |

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

```
{
    "code": "COMPLETED"
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "code": "SIMULATE_PAYMENT_FAILED"
}
```

{% endtab %}
{% endtabs %}

## /detail

<mark style="color:blue;">`GET`</mark> `/v1/purchase/:id`

Get detail of  a purchase.\
\
All values for **`status`** field :\
\- `pending` purchase pending, waiting for bank virtual account creation by our system.\
\- `processed` bank virtual account has been created, waiting for payment by end-user.\
\- `failed` purchase failed, this is usually caused by the payment that was sent by the end-user past the due date or time limit")\
\- `success` purchase success or payment has been paid\
\- `canceled` purchase canceled

#### Query Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string | Purchase ID |

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

```
{
    "id": "iv-sjvUMQ",
    "user_id": "23142dssc2xy",
    "status": "processed",
    "bank_name": "PERMATA",
    "bank_account_name": "Sastra Nababan",
    "bank_account_number": "7050100993400703",
    "amount": 30000,
    "creation_date": "2020-11-27T09:52:17.451Z",
    "processing_date": "2020-11-27T09:52:18.415Z",
    "due_date": "2020-11-28T09:52:17.444Z"
}
```

{% endtab %}

{% tab title="201 " %}

```
{
    "id": "iv-cWbAwj",
    "user_id": "23142dssc123x",
    "status": "pending"
}
```

{% endtab %}

{% tab title="302 " %}

```
```

{% 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://idrtgateway.gitbook.io/pintubusinessidrtgateway/api-references-1.0.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.
