# Invoice checkout

#### Flowchart

<div drawio-diagram="63"><img src="https://documentation.onindonesia.id/uploads/images/drawio/2024-01/drawing-3-1706671729.png" alt=""/></div>

##### Source:  
[https://cahskuy.stoplight.io/docs/OND/3c78799259e69-payment-checkout](https://cahskuy.stoplight.io/docs/OND/3c78799259e69-payment-checkout)  


Reference:  
[Transaction Flowchart](https://documentation.onindonesia.id/books/getting-started/page/transaction-flowchart)

##### Endpoint

<table border="1" id="bkmrk-endpoint-method-auth" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 33.3333%;"></col><col style="width: 33.3333%;"></col><col style="width: 33.3333%;"></col></colgroup><tbody><tr><td>**Endpoint**</td><td>**Method**  
</td><td>**Authentication**</td></tr><tr><td><div><div>/payment-checkout</div></div></td><td>POST</td><td>Yes</td></tr></tbody></table>

##### Authentication

<table border="1" id="bkmrk-endpoint-method-serv" style="border-collapse: collapse; width: 100%; height: 59.757px;"><colgroup><col style="width: 29.5426%;"></col><col style="width: 27.3177%;"></col><col style="width: 21.508%;"></col><col style="width: 21.508%;"></col></colgroup><tbody><tr style="height: 29.8785px;"><td style="height: 29.8785px;">**Type**  
</td><td style="height: 29.8785px;">**Token source**  
</td><td style="height: 29.8785px;">**Server**  
</td><td>**Description**</td></tr><tr style="height: 29.8785px;"><td style="height: 29.8785px;">Bearer</td><td style="height: 29.8785px;">{{usapi}}/auth</td><td style="height: 29.8785px;">USAPI</td><td>Buyer's auth</td></tr></tbody></table>

##### Body request example

```json
{
    "total_amount": 40000,
    "service": "ONMARKET",
    "source": "XENDIT",
    "transaction": [
        {
            "amount": 10000,
            "freight_charge": 5000,
            "insurance_amount": 100,
            "commission_onmarket": 1000,
            "seller_username": "testing123",
            "invoice_onmarket": "INV/ONM/20240124-002B0001"
        },
        {
            "amount": 20000,
            "freight_charge": 5000,
            "insurance_amount": 100,
            "commission_onmarket": 1000,
            "seller_username": "testing12345",
            "invoice_onmarket": "INV/ONM/20240124-002B0002"
        }
    ]
}
```

<table border="1" id="bkmrk-properties-propertie" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 21.0136%;"></col><col style="width: 12.2373%;"></col><col style="width: 14.4609%;"></col><col style="width: 8.40681%;"></col><col style="width: 43.8813%;"></col></colgroup><tbody><tr><td>**Properties**  
</td><td>**Properties of**</td><td>**Data type**</td><td>**Required**</td><td>**Description**</td></tr><tr><td>total\_amount</td><td>  
</td><td>integer</td><td>yes</td><td>Total nominal amount for the invoice.</td></tr><tr><td>service</td><td>  
</td><td>string</td><td>yes</td><td>ONINDONESIA services.  
Possible values:

- ONDELIVERY means the source of the transaction comes from ondelivery.
- ONTICKET means the source of the transaction comes from onticket.
- ONMARKET means the source of the transaction comes from onmarket.

</td></tr><tr><td>source</td><td>  
</td><td>string</td><td>yes</td><td>A way that users pay for a product or service. Possible values: XENDIT, BALANCE, QRIS.</td></tr><tr><td>transaction</td><td> </td><td>array&lt;object&gt;</td><td>yes</td><td>List of transactions.</td></tr><tr><td>amount</td><td>transaction</td><td>integer</td><td>yes</td><td>Amount of transaction for each store (do not include freight charge and insurance as they'll put in other parameter).</td></tr><tr><td>freight\_charge</td><td>transaction</td><td>integer</td><td>yes</td><td>Amount of freight charge for each store.</td></tr><tr><td>insurance\_amount</td><td>transaction</td><td>integer</td><td>no</td><td>Amount of insurance for each store.</td></tr><tr><td>seller\_username</td><td>transaction</td><td>string</td><td>yes</td><td>Seller ONMARKET username</td></tr><tr><td>invoice\_onmarket</td><td>transaction</td><td>string</td><td>yes</td><td>Invoice ID generated by ONMARKET</td></tr><tr><td>commission\_onmarket</td><td>transaction</td><td>integer</td><td>yes</td><td>Commission amount charged to seller</td></tr></tbody></table>

<details id="bkmrk-result-example-body-"><summary>Response example</summary>

<p class="callout info">200 (OK)</p>

<p class="callout info">Example response for ONMARKET</p>

```json
{
    "payment_url": "https://checkout-staging.xendit.co/latest/65ba1b78f603539c068ef753",
    "invoice": "ONM0001N11V0000x",
    "xendit_invoice": "65ba1b78f603539c068ef753",
    "expired_at": "2024-01-31T12:05:44.155Z",
    "transaction": [
        {
            "invoice_onmarket": "INV/ONM/20240124-002B0001",
            "status": "PENDING"
        },
        {
            "invoice_onmarket": "INV/ONM/20240124-002B0002",
            "status": "PENDING"
        }
    ]
}
```

<table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 16.9448%;"></col><col style="width: 14.6341%;"></col><col style="width: 15.7895%;"></col><col style="width: 52.6316%;"></col></colgroup><tbody><tr><td>**Properties**  
</td><td>**Properties of**</td><td>**Data type**</td><td>**Description**</td></tr><tr><td>xendit\_invoice</td><td>  
</td><td>string</td><td>invoice ID generated by XENDIT and translated by USAPI</td></tr><tr><td>payment\_url</td><td>  
</td><td>string</td><td>Public URL for this invoice

</td></tr><tr><td>expired\_at</td><td>  
</td><td>timestampz</td><td>ISO date and time that the invoice expires.

</td></tr><tr><td>transaction</td><td>  
</td><td>array&lt;object&gt;</td><td>List of transactions

</td></tr><tr><td>invoice</td><td>transaction</td><td>string</td><td>Invoice ID generated by USAPI

</td></tr><tr><td>status</td><td>transaction</td><td>string</td><td>Status showing whether the invoice has been paid

Possible values:

- PENDING means the invoice has been successfully created but yet to be paid
- PAID means the invoice has been paid
- EXPIRED means the invoice expired before your customer paid

</td></tr></tbody></table>

<p class="callout info">Example for response ONMARKET with source QRIS</p>

```json
{
    "invoice": "ONM00001N14U00001",
    "xendit_invoice": "qr_7807d58a-3d60-4425-92f9-23d6717701f6",
    "qr_string": "00020101021226570011ID.DANA.WWW011893600915060486424802096048642480303UKE51440014ID.CO.QRIS.WWW0215ID20243148326170303UKE52048999530336054031005802ID5925PT OnIndonesia Sistem Tek6015Kota Jakarta Ut61051424062720115NT2YP2fE3fetkbx60490011ID.DANA.WWW0425MER2021071400774509608641050116304DE92",
    "amount": 100,
    "expired_at": "2024-04-30T05:00:52.643Z"
}
```

</details><details id="bkmrk-error-example-body-r"><summary>Error response</summary>

<p class="callout danger">400 Bad Request</p>

> Some parameters may contain invalid values or some parameters are not present.

```json
{
    "message": "Invalid JSON Format"
}
```

> Balance is not enough for doing transaction

```json
{
    "message": "Insufficient balance"
}
```

<p class="callout danger">401 Unauthorized</p>

> Authentication header is not valid or missing

```json
{
    "message": "Auth Error"
}
```

<p class="callout danger">500 Internal server error</p>

> Internal server error

```json
{
    "message": "Internal server error"
}
```

</details>