# Use BayarGO with AI agents


> Give your coding agent the documentation and API contract it needs to build a BayarGO integration.

Canonical: https://docs.bayargo.id/agents

BayarGO documentation is available as focused Markdown, a complete documentation bundle, and an OpenAPI contract. Your agent can find the right guide without scraping the website or guessing how an endpoint works.

## Start here

### Point your agent to the index

Give the agent [`/llms.txt`](https://docs.bayargo.id/llms.txt). It lists the available guides and their machine-readable versions.

### Read only the relevant guide

For a payment integration, for example, the agent can open [`/llms.mdx/payments`](https://docs.bayargo.id/llms.mdx/payments) instead of loading the entire documentation set.

### Check the API contract

Before it writes code, have the agent validate methods, paths, authentication, and schemas against [`/openapi/core-api.yaml`](https://docs.bayargo.id/openapi/core-api.yaml).

## Give this to your agent

Tell the agent what you want to build, then copy this instruction with it. The documentation origin is filled from the current environment.

```text
Read https://docs.bayargo.id/llms.txt and use it to find only the BayarGO guides relevant to this task.

Before writing code, validate every endpoint, HTTP method, authentication requirement, and schema against https://docs.bayargo.id/openapi/core-api.yaml.

Do not invent endpoints, fields, status values, fees, or webhook events. Keep secret keys on the server and ask for explicit approval before any live payment, refund, cancellation, or configuration change.
```

## Machine-readable resources

- [`/llms.txt`](https://docs.bayargo.id/llms.txt) — Find the right guide.
- [`/llms.mdx/{document}`](https://docs.bayargo.id/llms.mdx/payments) — Read one guide as Markdown.
- [`/llms-full.txt`](https://docs.bayargo.id/llms-full.txt) — Load the complete documentation set.
- [`/openapi/core-api.yaml`](https://docs.bayargo.id/openapi/core-api.yaml) — Generate or validate API code.
- [`/.well-known/chiwa-docs.json`](https://docs.bayargo.id/.well-known/chiwa-docs.json) — Discover the machine-readable files.
- [`/agent-instructions.md`](https://docs.bayargo.id/agent-instructions.md) — Read agent-specific rules.

> **Keep credentials out of the conversation**
> Never paste API keys, OTPs, cookies, authorization headers, webhook secrets, or customer data into an agent prompt. Keep secrets on your server and load them through your deployment environment.

## Before an agent performs an action

Reading documentation and generating code do not require BayarGO credentials. Creating a live payment, issuing a refund, cancelling a transaction, or changing merchant configuration still requires the normal authentication flow and your explicit approval.

BayarGO currently publishes documentation for coding agents; it does not expose an MCP or A2A server for performing merchant actions.


---

# Authentication


> Authenticate API requests with a BayarGO secret key.

Canonical: https://docs.bayargo.id/authentication

Use a secret key on every API request.

## Header

```http
Authorization: Bearer sk_xxx
```

Clients that cannot set `Authorization` may send the same secret in `X-Secret-Key`.

> **Keep your API key secret**
> Do not send a secret key from a browser or mobile app.

## Requirements

| Requirement | Status |
| --- | --- |
| Merchant | `approved` |
| Payment method | `active` |
| Secret key | Not revoked |

## Security

| Area | Description |
| --- | --- |
| Storage | Store it on your server. |
| Logging | Mask secret key values. |
| Rotation | Revoke the old key after the new key is active. |
| IP allowlist | Restrict a key to server IPs or CIDR ranges such as `203.0.113.10` or `203.0.113.0/24`. |

## Example

```tsx
<ApiExample method="GET" path="/payments/f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001" />
```


---

# Error Codes


> Understand BayarGO API error responses and codes.

Canonical: https://docs.bayargo.id/errors

Failed requests return RFC 9457 problem details with the media type
`application/problem+json`. The stable `code` identifies the error; `detail` is
safe to show to the caller, and `request_id` is the correlation ID to include
when contacting support.

```json
{
  "type": "https://api.bayargo.id/problems/invalid_api_key",
  "title": "Unauthorized",
  "status": 401,
  "code": "invalid_api_key",
  "detail": "secret key is invalid or revoked",
  "request_id": "req_0123456789abcdef"
}
```

## Public API

| HTTP | Code | Description |
| --- | --- | --- |
| `400` | `invalid_json` | Body is not valid JSON. |
| `400` | `invalid_amount` | Amount is invalid. |
| `400` | `invalid_bulk_size` | Bulk item count is invalid. |
| `400` | `unsupported_payment_method` | Payment method is not supported. |
| `400` | `payment_create_failed` | Transaction could not be created. |
| `400` | `payment_cancel_failed` | Transaction could not be cancelled. |
| `400` | `payment_refund_failed` | Transaction could not be refunded. |
| `401` | `invalid_api_key` | Secret key is missing, invalid, or revoked. |
| `403` | `merchant_not_approved` | Merchant is not active. |
| `403` | `api_key_ip_not_allowed` | Request IP is not in the API key allowlist. |
| `404` | `not_found` | Resource was not found. |
| `429` | `rate_limited` | Rate limit exceeded. |
| `500` | `server_error` | Request could not be processed. |

## Rate Limit

The API applies rate limits to keep the service stable.
If a response includes `Retry-After`, wait at least that many seconds before retrying. Otherwise,
pause before retrying and use exponential backoff for repeated failures. For a retried create-
payment request, reuse its original `Idempotency-Key`.

## Retry

| Condition | Retry |
| --- | --- |
| Timeout | Yes, use the same request. |
| `500` | Yes, after a delay. |
| `400`, `401`, `403`, `404` | No. Fix the request or merchant status. |
| `429` | Yes, after waiting for the next rate-limit window. |


---

# Fees and Disbursement


> Understand transaction amounts, fees, refunds, and disbursement.

Canonical: https://docs.bayargo.id/fees-disbursement

## Amount Fields

| Field | Description |
| --- | --- |
| `amount` | Order amount from the merchant. |
| `fee_amount` | Payment fee. |
| `total_amount` | Amount the customer must pay. |
| `net_amount` | Amount recorded for the merchant. |

## Fee Example

| Fee payer | `amount` | `fee_amount` | `total_amount` | `net_amount` |
| --- | ---: | ---: | ---: | ---: |
| `buyer` | 100000 | 700 | 100700 | 100000 |
| `merchant` | 100000 | 700 | 100000 | 99300 |

## Refund Calculation

Provider refunds currently apply to GoPay transactions. The ShopeePay Partner SDK has no refund operation.

Refunds are sent to the provider for the customer-paid amount (`total_amount`).
The customer receives the full refund, while the merchant settlement balance is still reduced by `fee_amount` as the transaction service fee.

| Fee payer | Customer pays | Main refund amount | Notes |
| --- | --- | --- | --- |
| `buyer` | `amount + fee_amount` | `amount + fee_amount` | The customer-paid amount is refunded through the provider; `fee_amount` still reduces merchant settlement. |
| `merchant` | `amount` | `amount` | `fee_amount` remains the merchant's cost and reduces settlement. |

Possible refund statuses are `refund_processing`, `refund_failed`, and `refunded`.
Refunds with status `refund_processing` can be cancelled, returning the transaction to `paid`.
Refunds with status `refund_failed` or `refunded` cannot be cancelled.

## Disbursement

Fees and settlement policy are configured for each provider and channel pair in the admin catalog. A transaction captures its policy when created; settlement becomes available after the configured delay. The worker processes `automatic` policies, while `manual` policies require an admin action.

Disbursement is handled from the merchant dashboard after the settlement account is approved. The available bank catalog is controlled by the admin team; a disabled bank cannot be selected for a new settlement account.

Each bank can have its own fixed fee and percentage fee. The dashboard shows the fee and the amount the merchant will receive before the request is submitted. The optional global minimum payout is also shown there; when it is set to zero, any positive amount up to the available balance can be requested.


---

# BayarGO API Overview


> BayarGO integration overview for creating transactions, accepting payments, and tracking payment status.

Canonical: https://docs.bayargo.id/

BayarGO helps merchants create payment transactions, show payment instructions to customers, and track status changes through webhooks or the API.
Use this page as a quick map before opening the endpoint-level guides.

## What You Can Build

- [Accept QRIS payments](https://docs.bayargo.id/payments): Create transactions, show QRIS, and guide customers to complete payment.
  - [Use your own provider accounts](https://docs.bayargo.id/merchant-owned-payments): Subscribe to M2O, connect provider accounts, and create account-scoped payments.
  - [Track transaction status](https://docs.bayargo.id/payment-detail): Fetch the latest status by transaction UUID or reference ID.
  - [Refund transactions](https://docs.bayargo.id/payment-refund): Start a refund for paid transactions and follow the refund status.
  - [Automate notifications](https://docs.bayargo.id/webhooks): Receive events for paid, expired, failed, refund, and settled transactions.
  - [Manage fees and disbursement](https://docs.bayargo.id/fees-disbursement): Understand customer total, merchant net amount, refunds, and disbursement.
  - [Handle API errors](https://docs.bayargo.id/errors): Recognize error response formats and codes your app should handle.

## Before You Start

| Requirement | Description |
| --- | --- |
| Active merchant | The merchant application must be approved before its API key can create transactions. |
| API key | The secret key is available in the merchant dashboard and sent with the `Authorization` header. |
| Payment method | Make sure the payment method you want to use is enabled for the merchant. |
| Webhook URL | Recommended for automatic payment status updates from BayarGO. |

## API URL

Every endpoint example uses the following base URL.

`https://api.bayargo.id`

## Quick Start

The shortest path to create a QRIS transaction:

```tsx
<ApiExample
  method="POST"
  path="/payments"
  idempotencyKey="ORDER-1024"
  body={{
    amount: 150000,
    payment_method: "qris",
    merchant_reference_id: "ORDER-1024",
    customer: {
      name: "Nara",
      email: "nara@example.com"
    }
  }}
/>
```

The create payment response includes `payment.id`, `reference_id`, `status`, `qris_payload`, `qris_image_url`, and `expires_at`.
Show the QRIS to the customer, then fulfill the order after the status changes to `paid`.

For transactions processed through an account connected by the merchant, use the [merchant-owned payments guide](https://docs.bayargo.id/merchant-owned-payments). M2O requires an active plan and a connected account slot owned by the authenticated merchant.

## Integration Flow

| Step | Description |
| --- | --- |
| 1 | Store the API key on your server and never expose the secret key to the frontend. |
| 2 | Merchant creates a transaction with `POST /payments`. |
| 3 | BayarGO returns payment instructions such as a QRIS payload or QR image URL. |
| 4 | Customer pays using the payment instruction before `expires_at`. |
| 5 | BayarGO sends a webhook when status changes, for example `payment.paid` or `payment.expired`. |
| 6 | Merchant verifies the webhook, updates the order, and reconciles with the dashboard or transaction detail API. |

## Transaction Status

| Status | Description |
| --- | --- |
| `created` | Transaction was created. |
| `pending` | Waiting for payment. |
| `paid` | Customer has paid. |
| `expired` | Payment deadline has passed. |
| `settled` | Funds are in settlement and the transaction cannot be cancelled. |
| `failed` | Payment failed. |
| `cancelled` | Transaction was cancelled. |
| `refund_processing` | Refund is being processed. |
| `refund_failed` | Refund failed and needs retry or manual handling. |
| `refunded` | Refund succeeded. |

## Webhook or Polling

| Mechanism | Use When | Notes |
| --- | --- | --- |
| Webhook | Your system can receive requests from BayarGO. | This is the primary way to process status changes in real time. |
| Transaction detail polling | Your system cannot receive webhooks yet or needs a fallback check. | Use as a fallback and add delay between requests to avoid rate limits. |
| Dashboard | Operations teams need to inspect transactions manually. | Useful for investigation, support, and reconciliation. |

## Key Concepts

| Concept | Summary |
| --- | --- |
| `merchant_reference_id` | The order ID from the merchant system. Use a value that is easy to reconcile. |
| `reference_id` | BayarGO transaction ID that can be used to look up a payment. |
| `Idempotency-Key` | Prevents duplicate transaction creation when a create payment request is retried. |
| `total_amount` | The amount the customer must pay. It can differ from `amount` when the buyer pays the fee. |
| `net_amount` | The amount recorded for the merchant after fee rules are applied. |

## Continue From Here

- [Authentication](https://docs.bayargo.id/authentication): Send the API key and keep access secure.
  - [API Reference](https://docs.bayargo.id/): Payment, transaction detail, refund, and transaction list endpoints.
  - [Webhooks](https://docs.bayargo.id/webhooks): Transaction status events and signature headers.
  - [Errors](https://docs.bayargo.id/errors): Error response format and codes your app should handle.


---

# Merchant-Owned Payments


> Subscribe, connect your own provider account, and create isolated M2O payments.

Canonical: https://docs.bayargo.id/merchant-owned-payments

Merchant-owned payments (M2O) process a transaction through a provider account connected by the authenticated merchant. M2O transactions remain separate from platform account settlement and platform profit accounting.

All paths below are relative to the Core API base URL and require a merchant secret key in `Authorization: Bearer <merchant-secret-key>` or `X-Secret-Key`. The server derives the merchant identity from the key; do not send a merchant ID to these endpoints. Keep the key on a trusted server. Every account-slot request checks ownership. An active subscription and provider entitlement are required to create a slot, enable a slot, connect or reauthenticate an account, and create a payment. Listing owned slots and their history, disabling a slot, and disconnecting an owned account remain available if its subscription expires so the merchant can review history and manage existing credentials.

Set `Content-Type: application/json` for requests with a body. Every `POST` request on the public API requires an `Idempotency-Key` header containing 8–255 characters. Slot creation, subscription checkout, and M2O payment creation persist the key and return the original result when the same merchant repeats the same request. Reusing one of those keys for a different request returns `409 idempotency_conflict`. Other account-management `POST` actions also require the header, but their replay behavior is described with each operation; a required header alone does not mean that an operation stores a replay result.

## 1. List plans and provider access

Use the merchant API key to see active public plans and provider entitlements. Provider availability is data-driven; do not assume that every provider is supported for M2O. `connectable` means that an account authentication adapter is currently available.

`GET /m2o/plans`

`GET /m2o/providers`

```json
{
  "providers": [
    {
      "provider_code": "shopeepay",
      "display_name": "ShopeePay",
      "status": "active",
      "eligible": true,
      "connectable": true,
      "slot_limit": 2,
      "used_slots": 1,
      "remaining_slots": 1
    }
  ]
}
```

The response is `200 OK`. Each provider entry includes catalog status, whether it is eligible for the current subscription, whether account authentication is currently supported (`connectable`), and the subscription's slot limit, current usage, and remaining slots. Providers that cannot be used for M2O remain visible with `eligible: false`.

`GET /m2o/plans` returns `200 OK` with `plans`. Each plan contains `id`, `code`, `name`, `description`, `price`, `currency`, `duration_days`, `status`, `visibility`, `display_order`, `benefits`, `providers`, `created_at`, and `updated_at`. Each `providers` item contains `provider_code`, `display_name`, and `slot_limit`. Only active plans marked public are returned. `benefits` is plan-defined JSON; clients should render it as data and must not use it to infer provider entitlement.

## 2. Buy or renew a plan

Create a subscription order with an `Idempotency-Key`. The payment is created through the platform's existing QRIS checkout. The subscription becomes active only after the payment is confirmed. Plan name, price, duration, and provider limits are snapshotted when the order is created.

`POST /m2o/subscription-orders`

```json
{
  "plan_code": "merchant-standard",
  "provider": "gopay",
  "payment_method": "qris",
  "currency": "IDR",
  "customer": {
    "name": "Nara Store",
    "email": "billing@example.com"
  }
}
```

`POST /m2o/subscription-orders` returns `201 Created` with `order` and `payment`. `plan_code` may be an active public plan code or plan ID. `provider` and `payment_method` must be a supported combination; `currency` may be omitted to use the plan currency, and `customer` is optional. Replaying the same key with the same checkout request returns the original order and payment; reusing it with a different request returns `409 idempotency_conflict`. Only one unpaid subscription order may be open for a merchant. Pay the payment's `total_amount` before `expires_at`. A failed, expired, or cancelled payment does not grant provider slots.

The checkout response contains an order snapshot and the payment to complete:

```json
{
  "order": {
    "id": "a7c16e5a-8f67-4d4a-b2d8-842aa7f08b5c",
    "plan_id": "c3f2456a-bf53-4a32-a0be-bf0b4fd601d0",
    "payment_transaction_id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "status": "pending_payment",
    "plan_snapshot": {
      "entitlement_version": 1,
      "plan_id": "c3f2456a-bf53-4a32-a0be-bf0b4fd601d0",
      "code": "merchant-standard",
      "name": "Standard",
      "price": 150000,
      "currency": "IDR",
      "duration_days": 30,
      "benefits": [],
      "entitlements": { "bank_jago": 1, "gopay": 2 }
    },
    "created_at": "2026-11-22T14:00:00Z",
    "updated_at": "2026-11-22T14:00:00Z"
  },
  "payment": {
    "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "reference_id": "PAY-LXAMPLE",
    "merchant_reference_id": "",
    "payment_method_code": "qris",
    "provider": "gopay",
    "currency": "IDR",
    "amount": 150000,
    "fee_amount": 1050,
    "net_amount": 150000,
    "total_amount": 151050,
    "fee_payer": "buyer",
    "fee_fixed": 0,
    "fee_percent_bps": 70,
    "status": "pending",
    "customer": { "name": "Nara Store", "email": "billing@example.com" },
    "payment_url": "https://pay.example.test/PAY-LXAMPLE",
    "expires_at": "2026-11-22T14:30:00Z",
    "created_at": "2026-11-22T14:00:00Z",
    "updated_at": "2026-11-22T14:00:00Z"
  }
}
```

In this example, the payment fee fields reflect one illustrative merchant fee schedule; BayarGO calculates them from the merchant's active payment-method configuration. QRIS payload and image fields are also returned when supplied by the selected provider.

After payment, poll `GET /m2o/subscription-orders/{orderID}` or consume the `subscription_order.*` webhook events. The order exposes its current `status`, linked `payment_status`, `payment_transaction_id`, and `subscription_id` when available. A paid order may activate a term immediately or schedule it after the current term; use `GET /m2o/subscriptions` to read the authoritative entitlement dates and provider-slot snapshot. Payment creation itself does not grant access before the confirmed order transition.

`GET /m2o/subscription-orders/{orderID}`

`GET /m2o/subscriptions`

The order endpoint returns `200 OK` and an order belonging to the authenticated merchant. Its status is `pending_payment`, `paid`, `failed`, `expired`, or `cancelled`; `payment_status` reports the linked payment state when available. The subscriptions endpoint returns `200 OK` with active, scheduled, and historical terms. Each subscription includes `id`, `plan_code`, `plan_name`, `price`, `currency`, `duration_days`, `entitlement_version`, `provider_slots`, `status`, optional `starts_at`, `ends_at`, and `cancellation_requested_at`, and `created_at`. Plan edits do not change an existing order's snapshot.

```json
{
  "subscriptions": [
    {
      "id": "5f9a4709-f2de-4a2f-8962-372f33c63832",
      "plan_code": "merchant-standard",
      "plan_name": "Standard",
      "price": 150000,
      "currency": "IDR",
      "duration_days": 30,
      "entitlement_version": 1,
      "provider_slots": { "bank_jago": 1, "gopay": 2 },
      "status": "active",
      "starts_at": "2026-11-22T14:00:00Z",
      "ends_at": "2026-12-22T14:00:00Z",
      "created_at": "2026-11-22T14:00:00Z"
    }
  ]
}
```

Stop renewal for an active term at its period end with:

`POST /m2o/subscriptions/{subscriptionID}/cancel`

This returns `200 OK` with the updated subscription. The cancellation request is safe to repeat, leaves the current provider entitlement active until `ends_at`, does not refund the term, and does not cancel a separately purchased future term. An `Idempotency-Key` header is required by the public API boundary; the cancellation transition itself is safe to repeat.

## 3. Reserve and connect an account

Create a slot for a provider included in the active subscription. The slot code is the stable public identifier; internal provider slot numbers and credentials are never returned.

`POST /m2o/accounts`

```json
{
  "provider_code": "shopeepay"
}
```

The endpoint returns `201 Created` with a credential-free `account` containing `provider_code`, `slot_code`, `status`, `enabled`, `suspended`, `created_at`, and optional `connected_at` and `last_checked_at`. A newly reserved slot has `status: "disconnected"` and `enabled: true` until the provider connection is completed. `provider_code` must name an active provider that supports merchant-owned accounts and is included in the merchant's current subscription. The generated `slot_code` has the form `ACCT-` followed by ten characters; use this stable code for subsequent account requests and M2O payment creation. Replaying the same key and provider returns the original slot; reusing the key for another provider returns `409 idempotency_conflict`.

```json
{
  "account": {
    "provider_code": "shopeepay",
    "slot_code": "ACCT-4J8QK2M7TX",
    "status": "disconnected",
    "enabled": true,
    "suspended": false,
    "created_at": "2026-11-22T14:00:00Z"
  }
}
```

List the merchant's slots with:

`GET /m2o/accounts`

The response is `200 OK` with `accounts`. Each item includes `provider_code`, `slot_code`, `status`, `enabled`, `suspended`, and connection timestamps. It never includes provider passwords, session tokens, mailbox passwords, or account-number ciphertext.

Use the returned `account.slot_code` to connect an account. Check `connectable` before offering a provider connection flow. ShopeePay uses phone and password authentication:

`POST /m2o/accounts/{accountSlotCode}/connect`

```json
{
  "phone": "6281234567890",
  "password": "provider-account-password"
}
```

The ShopeePay endpoint returns `200 OK` with a safe `account` projection. Credentials are encrypted at rest and are not included in account responses or logs. GoPay uses a staged GoBiz and GoPay Merchant sign-in flow. First save the account credentials:

`POST /m2o/accounts/{accountSlotCode}/gopay/credentials`

```json
{
  "email": "owner@example.com",
  "password": "gobiz-account-password"
}
```

Ask GoPay which verification methods are available, then select one of the returned values. Do not assume that SMS is available or select a method that GoPay did not return.

`POST /m2o/accounts/{accountSlotCode}/gopay/otp/methods`

`POST /m2o/accounts/{accountSlotCode}/gopay/otp/request`

```json
{
  "method": "email",
  "selection_token": "short-lived-selection-token"
}
```

Submit the challenge token and the code received from GoPay:

`POST /m2o/accounts/{accountSlotCode}/gopay/otp/verify`

```json
{
  "token": "short-lived-challenge-token",
  "otp": "123456"
}
```

Use these endpoints to inspect GoPay session status and choose an outlet:

`GET /m2o/accounts/{accountSlotCode}/gopay`

`POST /m2o/accounts/{accountSlotCode}/gopay/outlet`

The OTP methods endpoint returns `200 OK` with `selection_token`, `methods`, and optional `default_method`. The OTP request endpoint returns `200 OK` with `challenge`, containing `otp_token`, `phone_number`, optional `verification_method`, `stage`, `otp_length`, and `delivery_target`, plus `expires_at`. Use the exact method returned by GoPay and the same selection token to request the challenge. Verify with that challenge's `otp_token` and the received code.

The status endpoint returns `200 OK` with `provider`; it is marked `Cache-Control: no-store`. The safe provider projection contains `provider`, `status`, `connected`, `reason`, and optional account details (`phone`, `email`, `merchant_name`, `selected_outlet`, `connected_at`, `last_checked_at`, and `outlets`). Each outlet contains `id`, `name`, `suspension_status`, and `gopay_status`. It does not expose session credentials. Outlet selection takes `{ "outlet_id": "outlet-id" }` and returns the updated `provider` state. Challenge and selection tokens are temporary authentication material; keep them private and never log them. These provider operations resolve the slot against the authenticated merchant and require an active entitlement before changing or authenticating the account.

Provider authentication failures return a stable provider error code and an actionable message. Credentials are never included in responses or logs.

Bank Jago accounts use email notifications for transfer reconciliation. Configure the account through this endpoint:

`POST /m2o/accounts/{accountSlotCode}/bank-jago`

```json
{
  "account_name": "Nara Store",
  "account_number": "123456789012",
  "mailbox_email": "payments@example.com",
  "mailbox_app_password": "gmail-app-password",
  "email_language": "en",
  "unique_code_min": 1,
  "unique_code_max": 999,
  "payment_deadline_minutes": 30,
  "fallback_enabled": false
}
```

The endpoint returns `200 OK` with the credential-free account state after it verifies Gmail IMAP access. Use a Gmail app password for a mailbox that receives Bank Jago transaction notices. `email_language` is `id` or `en`; the unique-code range is inclusive and must be within `1`–`999`; `payment_deadline_minutes` must be within `1`–`1440`. The fallback setting applies only within the same account-ownership boundary and never permits routing to another merchant or to a platform account. The API returns only credential-free account state.

Mailbox verification returns `bank_jago_mailbox_unverified` if IMAP login fails. `invalid_bank_jago_configuration` means a field or allowed range must be corrected. A disconnected Jago account retains its slot and transaction history.

Enable or disable a slot with `PATCH`; disconnect it with `POST`. Disconnection clears provider credentials and session data while retaining the slot and its transaction history. Bank Jago disconnection is rejected while a payment may still need receipt reconciliation.

`PATCH /m2o/accounts/{accountSlotCode}`

```json
{ "enabled": false }
```

`POST /m2o/accounts/{accountSlotCode}/disconnect`

Both return `200 OK` with the safe `account` projection. `enabled` must be a JSON boolean. Repeating an enable/disable or disconnect operation is safe; these operations require an `Idempotency-Key` header but do not use it to persist a replay result. Disabling and disconnecting do not delete the account slot or its transaction history. Re-enabling a slot requires an active subscription with remaining entitlement; disconnecting a Bank Jago account is blocked while a payment may still need receipt reconciliation.

## 4. Create a payment

Create one payment at a time using the account slot code. This endpoint accepts one payment object and returns `201 Created` with `payment`; bulk `payments` arrays are not supported. The provider and payment method must be supported by that account and its adapter. Bank Jago payments use `bank_jago_transfer` and `bank_jago`:

`POST /m2o/payments/{accountSlotCode}`

```json
{
  "amount": 150000,
  "currency": "IDR",
  "payment_method": "bank_jago_transfer",
  "provider": "bank_jago",
  "merchant_reference_id": "ORDER-1024",
  "customer": {
    "name": "Nara",
    "email": "nara@example.com"
  }
}
```

For Bank Jago, the response also includes `payment_instructions` with the receiving account and exact `payable_amount` (the order amount plus its reserved unique code). Tell the payer to transfer that exact amount before `expires_at`. The unique amount is reserved against the selected account slot and is not globally unique across different Jago accounts. If no unambiguous amount is available, the API returns `503 bank_jago_amount_temporarily_unavailable`; retry after the supplied `Retry-After` interval rather than inventing an amount.

```json
{
  "payment": {
    "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "reference_id": "PAY-LXAMPLE",
    "provider": "bank_jago",
    "amount": 150000,
    "total_amount": 150123,
    "status": "pending",
    "payment_instructions": {
      "bank_name": "Bank Jago",
      "recipient_account_number": "123456789012",
      "recipient_name": "Nara Store",
      "transfer_amount": 150000,
      "unique_code": 123,
      "payable_amount": 150123,
      "instructions": "Transfer the exact payable amount before the deadline."
    },
    "expires_at": "2026-11-22T14:30:00Z"
  }
}
```

Send an `Idempotency-Key` for each payment so network retries cannot create another transaction. Replaying the same key with the same payment intent returns the original transaction; changing the amount, currency, provider, method, account slot, customer, metadata, or merchant reference with that key returns `409 idempotency_conflict`. The key is scoped to the merchant and live environment; use a new key for a new payment. `amount` must be a positive integer in IDR. `payment_method` must be supported by the selected account; `provider` must match that account and may be omitted only when the method identifies it unambiguously. `merchant_reference_id`, `customer`, and `metadata` are optional. Retrieve status with `GET /payments/{payment_id}` using the same merchant API key or handle the existing webhook subscription. Cancel an eligible pending payment through the standard [payment cancellation endpoint](https://docs.bayargo.id/payment-cancel). M2O payments use the standard payment lifecycle events and statuses, including `created`, `pending`, `paid`, `expired`, `cancelled`, and `failed`; see [webhook events](https://docs.bayargo.id/webhooks) for payload examples.

## 5. Review one account's transactions

List only payments routed through one account slot. The slot code must belong to the merchant authenticated by the API key; an unknown slot and another merchant's slot both return `404 provider_account_unavailable`.

`GET /m2o/accounts/{accountSlotCode}/transactions`

| Query parameter | Type | Behavior |
| --- | --- | --- |
| `page` | integer | 1-based page index; defaults to 1. |
| `page_index` | integer | Compatibility alias for `page`; `page` takes precedence when both are supplied. |
| `limit` | integer | Page size from 1 to 200; defaults to 20. |
| `offset` | integer | Zero-based row offset from 0 to 100,000; when supplied, it overrides the offset derived from `page`. |
| `q` | string | Searches payment ID, payment reference, merchant reference, provider, or status. |
| `status` | string, repeatable or comma-separated | Filters by transaction status. |
| `receipt_status` | string, repeatable or comma-separated | Bank Jago only; filters normalized receipt events by `unmatched`, `matched`, `duplicate`, `ignored`, or `ambiguous`. |
| `currency` | string, repeatable or comma-separated | Filters by currency code. |
| `amount_min`, `amount_max` | integer | Inclusive bounds on payable `total_amount`. |
| `from`, `to` | `YYYY-MM-DD` | Supply both for an inclusive UTC creation-date range. |
| `from_at`, `to_at` | RFC3339 timestamp | Optional inclusive start and exclusive end bounds; either may be used alone. Use these instead of date-only bounds for precise time filtering. |
| `sort` | string | Transaction sort key: `reference`, `reference_id`, `merchant_reference_id`, `status`, `method`, `payment_method_code`, `provider`, `amount`, `total_amount`, `fee_amount`, `net_amount`, `created_at`, `received_at`, or `id`. Bank Jago receipts support `received_at`, `status`, or `amount`. |
| `dir` | `asc` or `desc` | Sort direction; defaults to descending. |
| `count` | `exact` or `true` | Requests an exact total and total page count. Without it, transaction pagination may report a lower-bound total. Bank Jago receipt totals are always exact. |

```json
{
  "transactions": [
    {
      "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
      "reference_id": "PAY-LXAMPLE",
      "merchant_reference_id": "ORDER-1024",
      "provider": "shopeepay",
      "currency": "IDR",
      "amount": 150000,
      "total_amount": 151050,
      "status": "paid",
      "created_at": "2026-11-22T14:10:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "page_index": 1,
    "limit": 20,
    "offset": 0,
    "total": 1,
    "total_exact": true,
    "total_pages": 1,
    "has_more": false
  }
}
```

The endpoint returns `200 OK` with `transactions` and `pagination`. `page` is 1-based, `limit` defaults to 20 and is capped at 200, and offsets beyond the supported maximum are rejected. `page_index` is a compatibility alias; `offset` overrides the page-derived offset. Repeatable status and currency filters may be sent multiple times or as comma-separated values.

For a Bank Jago slot, the same response also contains a separately paginated `bank_jago_receipts` list and `receipt_pagination`. Receipt filters use the same search, amount, and date bounds as transactions; receipt pagination always reports an exact total. A receipt includes its stable `id`, parsed `amount` when available, reconciliation `status`, matched `transaction_id` when available, trusted mailbox `received_at`, and optional sender `message_date`. Mailbox IDs, message IDs, raw email content, and credentials are never returned. These receipt fields are omitted for other providers.

If a query returns no items, the account has no transactions matching the selected filters. Disconnected or subscription-suspended slots retain their transaction history for the owning merchant.

## Errors

| HTTP | Code | Meaning | Action |
| --- | --- | --- | --- |
| `403` | `subscription_required` | No active subscription grants M2O access. | Purchase or renew a plan. |
| `403` | `provider_not_entitled` | The plan or provider catalog does not grant access to this provider. | Choose a plan that includes an enabled M2O provider. |
| `403` | `merchant_not_approved` | The merchant is not approved to create payments. | Complete the merchant approval process before retrying. |
| `400` | `invalid_subscription_checkout` | Required checkout fields are missing or invalid. | Send `plan_code`, `provider`, and `payment_method`. |
| `400` | `invalid_subscription_payment_method` | The provider and payment method combination is unsupported. | Choose a supported combination returned by the payment-method API. |
| `400` | `invalid_subscription` | A subscription identifier is missing. | Use the subscription UUID returned by the subscriptions endpoint. |
| `400` | `invalid_payment_request` | The payment request is invalid or contains a bulk `payments` array. | Send one payment object with the documented fields. |
| `400` | `idempotency_key_header_required` | The payment idempotency key was sent in the JSON body. | Send it in the `Idempotency-Key` header. |
| `400` | `invalid_otp_method`, `invalid_otp`, `invalid_outlet` | A GoPay verification method, OTP, or outlet selection is invalid. | Use the current method/challenge/outlet returned by GoPay. |
| `400` | `invalid_date_range`, `page_too_deep` | A transaction-history date or page range is invalid. | Use the documented date formats and a lower page number. |
| `404` | `subscription_plan_unavailable` | The plan is not active or publicly available. | Select an active public plan. |
| `404` | `subscription_not_found` | The active subscription term is not available to this merchant. | Check the subscription UUID and current status. |
| `409` | `subscription_provider_unavailable` | A provider entitlement cannot currently be fulfilled. | Retry later or select another eligible plan. |
| `409` | `subscription_order_conflict` | Another pending order exists or the order state conflicts with this request. | Retrieve the pending order or resolve its payment before creating another. |
| `409` | `subscription_payment_method_unavailable` | The selected payment method is not enabled for this merchant. | Enable an eligible payment method or choose another. |
| `503` | `subscription_payment_unavailable` | The payment provider is temporarily unavailable. | Retry checkout with the same idempotency key. |
| `409` | `provider_slot_limit_reached` | All slots for this provider are in use. | Upgrade the plan or disconnect an unused account slot. |
| `404` | `provider_account_unavailable` | The code is unknown, belongs to another merchant, or cannot currently route payments. | Check ownership, connection state, and subscription entitlement. |
| `400` | `invalid_account_request` | A provider code, slot setting, or request field is invalid. | Correct the request fields. |
| `400` | `invalid_account_credentials` | Required provider credentials are missing. | Supply the fields required by the provider flow. |
| `400` | `invalid_bank_jago_configuration` | Jago details or an allowed range are invalid. | Check account details, language, code range, and deadline. |
| `400` | `unsupported_currency` | The requested currency is not currently supported. | Use `IDR`. |
| `422` | `bank_jago_mailbox_unverified` | Gmail IMAP could not authenticate the notification mailbox. | Enable IMAP and enter the mailbox's valid app password. |
| `409` | `bank_jago_payments_pending` | A Jago payment may still need receipt reconciliation. | Wait until the matching window closes before changing the configuration or disconnecting. |
| `502` | `provider_connection_failed` | A provider adapter could not verify the supplied account. | Check credentials and retry; secrets are never returned. |
| `502` | `payment_provider_rejected` | The provider rejected payment creation. | Retry later with the same idempotency key after checking payment status. |
| `503` | `bank_jago_amount_temporarily_unavailable` | No unambiguous unique payable amount is currently available in this ownership boundary. | Retry the same payment intent after `Retry-After`, using its original `Idempotency-Key`. |
| `503` | `m2o_unavailable`, `subscription_checkout_unavailable` | An M2O provider or subscription service is temporarily unavailable. | Retry after a delay; reuse the same key for the same checkout. |
| `400` | `invalid_amount` | The payment amount is missing, non-positive, or not a whole IDR amount. | Send a positive integer amount in IDR. |
| `400` | `unsupported_payment_method` | The requested provider and payment method do not match. | Use a combination supported by the selected account. |
| `409` | `payment_method_unavailable` | The payment method is disabled or unavailable to this merchant. | Choose an enabled payment method or retry after the provider recovers. |
| `409` | `idempotency_conflict` | An idempotency key was replayed with a different checkout, payment, or account-creation request. | Use a new key for a new request; retain the original key for retries of the same request. |
| `400` | `idempotency_key_required` | A public API `POST` request is missing an idempotency key or its key is outside the allowed length. | Send an 8–255 character `Idempotency-Key` header on the request. |
| `404` | `subscription_order_not_found` | The order is unknown or belongs to another merchant. | Check the order UUID returned during checkout. |
| `500` | `provider_catalog_unavailable`, `provider_accounts_unavailable`, `subscription_plans_unavailable`, `provider_account_operation_failed`, `subscription_checkout_failed`, `subscription_cancellation_failed` | Provider, plan, or account data could not be loaded or updated. | Retry later; do not repeat credential submission without checking account state. |
| `500` / `503` | `subscriptions_unavailable` | Subscription data or management is temporarily unavailable. | Retry after a delay. |
| `500` | `server_error` | An unexpected server error prevented payment creation. | Retry after a delay with the same payment idempotency key. |
| `401` | `invalid_api_key` | The key is missing, invalid, or revoked. | Check the server-side merchant key. |
| `403` | `api_key_ip_not_allowed` | The request IP is not in the key allowlist. | Add the server IP or CIDR to the allowlist. |
| `429` | `rate_limited` | The API rate limit was reached. | Wait before retrying. |
| `500` / `503` | `payment_unavailable` | A payment provider dependency is temporarily unavailable. | Retry after a delay with the same payment idempotency key. |

The server checks account ownership on slot-specific operations and requires an active subscription and matching provider entitlement for account activation and payment routing. A slot code does not grant access without the matching merchant API key. Errors use RFC 9457 problem details with a stable `code`, safe `detail`, and `request_id`; retryable responses may include a `Retry-After` header. See [Error Codes](https://docs.bayargo.id/errors) for the response shape and common API-key, allowlist, rate-limit, and retry behavior.


---

# Cancel Payment


> Cancel a payment transaction that is still pending.

Canonical: https://docs.bayargo.id/payment-cancel

`POST /payments/:id/cancel`

Cancel a transaction that is still `pending`.
The ShopeePay Partner SDK does not support cancellation.
For GoPay transactions, BayarGO first requests cancellation from GoPay. The local transaction changes to `cancelled` and emits `payment.cancelled` only after the provider confirms the cancellation. If the provider request fails, the transaction remains `pending`.

The `POST /transactions/:id/cancel` alias is available with the same behavior.

## Status Rules

| Initial status | Result |
| --- | --- |
| `pending` | `cancelled` |
| `refund_processing` | `paid`, the refund process is cancelled. |
| `created`, `paid`, `expired`, `failed`, `cancelled`, `settled`, `refund_failed`, `refunded` | Cannot be cancelled. |

## Path Params

| Param | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Transaction UUID or `reference_id`. |

## Request Example

```tsx
<ApiExample method="POST" path="/payments/f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001/cancel" />
```

## Response

```json
{
  "payment": {
    "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "reference_id": "PAY-LXAMPLE",
    "merchant_reference_id": "ORDER-1024",
    "payment_method_code": "qris",
    "currency": "IDR",
    "amount": 150000,
    "fee_amount": 1050,
    "net_amount": 150000,
    "total_amount": 151050,
    "status": "cancelled",
    "cancelled_at": "2026-05-19T10:05:00Z"
  }
}
```

## HTTP Error Codes

| HTTP | Code | Description |
| --- | --- | --- |
| `400` | `payment_cancel_failed` | Transaction cannot be cancelled from its current status, or the provider did not confirm the cancellation. |
| `401` | `invalid_api_key` | Secret key is invalid. |
| `403` | `merchant_not_approved` | Merchant is not active yet. |
| `403` | `api_key_ip_not_allowed` | Request IP is not in the API key allowlist. |
| `404` | `not_found` | Transaction was not found. |


---

# Payment Detail


> Retrieve payment details and the latest transaction status.

Canonical: https://docs.bayargo.id/payment-detail

`GET /payments/:id`

Returns transaction detail.

## Path Params

| Param | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Transaction UUID or `reference_id`. |

## Request Example

```tsx
<ApiExample method="GET" path="/payments/f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001" />
```

## Response

```json
{
  "payment": {
    "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "reference_id": "PAY-LXAMPLE",
    "merchant_reference_id": "ORDER-1024",
    "payment_method_code": "qris",
    "provider": "gopay",
    "currency": "IDR",
    "amount": 150000,
    "fee_amount": 1050,
    "net_amount": 150000,
    "total_amount": 151050,
    "status": "paid",
    "paid_at": "2026-05-19T10:01:00Z",
    "created_at": "2026-05-19T10:00:00Z",
    "updated_at": "2026-05-19T10:01:00Z"
  }
}
```

## Response Fields

| Field | Description |
| --- | --- |
| `payment.id` | Transaction UUID. |
| `payment.reference_id` | BayarGO transaction ID. |
| `payment.merchant_reference_id` | Merchant order ID. |
| `payment.status` | Transaction status. |
| `payment.total_amount` | Amount the customer must pay. |
| `payment.net_amount` | Amount after fee. |
| `payment.paid_at` | Time payment was received. |

## HTTP Error Code

| HTTP | Code | Description |
| --- | --- | --- |
| `401` | `invalid_api_key` | Secret key is invalid. |
| `403` | `merchant_not_approved` | Merchant is not active. |
| `404` | `not_found` | Transaction was not found. |


---

# Refund Payment


> Start a refund and track its status.

Canonical: https://docs.bayargo.id/payment-refund

`POST /payments/:id/refund`

Starts a refund for a transaction that is already `paid` and has not entered settlement.
The ShopeePay Partner SDK does not support refunds; this endpoint applies to GoPay transactions only.
When the request succeeds, the transaction status changes to `refund_processing`.

## Status Rules

| Initial status | Result |
| --- | --- |
| `paid` | `refund_processing` |
| `created`, `pending`, `expired`, `failed`, `cancelled`, `settled`, `refund_processing`, `refund_failed`, `refunded` | Cannot be refunded. |

## Refund Calculation

The main refund amount is the customer-paid amount (`total_amount`).
The customer receives that amount in full. The merchant settlement balance is still reduced by `fee_amount` as the transaction service fee.

| Fee payer | Customer pays | Main refund amount | Notes |
| --- | --- | --- | --- |
| `buyer` | `amount + fee_amount` | `amount + fee_amount` | The customer-paid amount is refunded through the provider; `fee_amount` still reduces merchant settlement. |
| `merchant` | `amount` | `amount` | `fee_amount` remains the merchant fee and reduces settlement. |

## Path Params

| Param | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Transaction UUID or `reference_id`. |

## Request Example

```tsx
<ApiExample method="POST" path="/payments/f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001/refund" />
```

## Response

```json
{
  "payment": {
    "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "reference_id": "PAY-LXAMPLE",
    "merchant_reference_id": "ORDER-1024",
    "payment_method_code": "qris",
    "currency": "IDR",
    "amount": 150000,
    "fee_amount": 1050,
    "net_amount": 150000,
    "total_amount": 151050,
    "status": "refund_processing"
  }
}
```

## HTTP Error Code

| HTTP | Code | Description |
| --- | --- | --- |
| `400` | `payment_refund_failed` | Transaction cannot be refunded from its current status. |
| `401` | `invalid_api_key` | Secret key is invalid. |
| `403` | `merchant_not_approved` | Merchant is not active. |
| `404` | `not_found` | Transaction was not found. |


---

# Create Payment


> Create single or bulk payment transactions.

Canonical: https://docs.bayargo.id/payments

`POST /payments`

Creates payment transactions. The request can contain a single transaction or a bulk payload through the `payments` field.

## Headers

| Header | Required | Description |
| --- | --- | --- |
| `Authorization` | Yes | `Bearer sk_xxx` |
| `Content-Type` | Yes | `application/json` |
| `Idempotency-Key` | No | Unique ID for a single request. For bulk, use `payments[].idempotency_key`. |

## Body Fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `amount` | integer | Yes for single request | Order amount. |
| `currency` | string | No | Default `IDR`. |
| `payment_method` | string | No | `qris` (default), `bca_va`, `bri_va`, `bni_va`, or `bank_jago_transfer`. |
| `provider` | string | No | QRIS supports `gopay` (default) and `shopeepay`; the three VA methods use `gopay_va`; `bank_jago_transfer` uses `bank_jago`. The method must be enabled for the merchant. Also applies to each `payments[]` item. |
| `merchant_reference_id` | string | No | Order ID from the merchant system. |
| `customer` | object | No | Customer data. |
| `metadata` | object | No | Extra merchant data. |
| `payments` | array | No | Transaction list for bulk create. Maximum `50` items per request. |
| `payments[].idempotency_key` | string | Recommended | Unique ID per bulk item. |

## Payment Method Fields

| Field | Description |
| --- | --- |
| `payment_method` | Payment method code. If empty, the API uses `qris`. |
| `provider` | Payment provider. Internal provider accounts are selected automatically and omitted from responses. |
| `qris_payload` | Payment payload in QRIS responses. |
| `qris_image_url` | QR image URL in QRIS responses. |
| `payment_instructions` | Bank transfer instructions returned for `bank_jago_transfer`, including the recipient and exact payable amount. |

## Single Request Example

```tsx
<ApiExample
  method="POST"
  path="/payments"
  idempotencyKey="ORDER-1024"
  body={{
    amount: 150000,
    payment_method: "qris",
	provider: "gopay",
    merchant_reference_id: "ORDER-1024",
    customer: {
      name: "Nara",
      email: "nara@example.com"
    }
  }}
/>
```

## Bulk Request Example

```tsx
<ApiExample
  method="POST"
  path="/payments"
  body={{
    payments: [
      {
        amount: 150000,
        payment_method: "qris",
        merchant_reference_id: "ORDER-1024",
        idempotency_key: "ORDER-1024"
      },
      {
        amount: 89000,
        payment_method: "qris",
        merchant_reference_id: "ORDER-1025",
        idempotency_key: "ORDER-1025"
      }
    ]
  }}
/>
```

## Single Response

```json
{
  "payment": {
    "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
    "reference_id": "PAY-LXAMPLE",
    "merchant_reference_id": "ORDER-1024",
    "payment_method_code": "qris",
    "provider": "gopay",
    "currency": "IDR",
    "amount": 150000,
    "fee_amount": 1050,
    "net_amount": 150000,
    "total_amount": 151050,
    "status": "pending",
    "qris_payload": "000201010212...",
    "qris_image_url": "<qris_image_url>",
    "gopay_deeplink": "https://link.gopay.co.id/...",
    "expires_at": "2026-05-19T10:30:00Z",
    "created_at": "2026-05-19T10:00:00Z",
    "updated_at": "2026-05-19T10:00:00Z"
  }
}
```

## Bulk Response

```json
{
  "payments": [
    {
      "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
      "reference_id": "PAY-LXAMPLE",
      "merchant_reference_id": "ORDER-1024",
      "payment_method_code": "qris",
      "amount": 150000,
      "fee_amount": 1050,
      "net_amount": 150000,
      "total_amount": 151050,
      "status": "pending",
      "expires_at": "2026-05-19T10:30:00Z"
    }
  ]
}
```

## Response Fields

| Field | Description |
| --- | --- |
| `payment.id` / `payments[].id` | Transaction UUID. |
| `payment.reference_id` / `payments[].reference_id` | BayarGO transaction ID. |
| `payment.merchant_reference_id` | Merchant order ID. |
| `payment.payment_method_code` | Payment method. |
| `payment.amount` | Order amount. |
| `payment.fee_amount` | Payment fee. |
| `payment.net_amount` | Amount recorded for the merchant. |
| `payment.total_amount` | Amount the customer must pay. |
| `payment.status` | Transaction status. |
| `payment.gopay_deeplink` | GoPay continuation link when the provider is `gopay` and the upstream provider supplied one. |
| `payment.virtual_account_number` | The bank VA number when GoPay has supplied the payment instructions. Read the payment details again if the number is still being prepared. Pay the returned `total_amount`, which can include a bank fee. |
| `payment.expires_at` | Payment deadline; after it passes, pending transactions become `expired`. |

## Fee Payer

| Value | Customer pays | Merchant receives |
| --- | --- | --- |
| `buyer` | `amount + fee_amount` | `amount` |
| `merchant` | `amount` | `amount - fee_amount` |

QRIS is created dynamically by the provider and validated with provider transaction IDs, not amount matching.

## Bank Jago transfer

`bank_jago_transfer` creates a payment against an eligible Bank Jago account configured by the platform. The platform reserves an account-scoped unique amount and returns the exact transfer instructions. Customers must transfer the returned `payment_instructions.payable_amount`; transferring only `amount` will not match the payment.

```json
{
  "payment_method": "bank_jago_transfer",
  "provider": "bank_jago",
  "amount": 150000,
  "currency": "IDR",
  "merchant_reference_id": "ORDER-1026"
}
```

The response includes `payment_instructions.bank_name`, `recipient_account_number`, `recipient_name`, `transfer_amount`, `unique_code`, `payable_amount`, and `instructions`, plus the transaction's `expires_at`. Unique amounts are reserved per provider account, so the same code can be used by a different Jago account. A code is not reused within an account while a transfer could still be matched to its earlier payment.

If all safe unique amounts are reserved, the API returns `503 bank_jago_amount_temporarily_unavailable` and a `Retry-After` header when the next reservation is expected to expire. Retry with the same idempotency key to retrieve the original payment; use a new key only when creating a new payment.

## HTTP Error Code

| HTTP | Code | Description |
| --- | --- | --- |
| `400` | `invalid_json` | Body is not valid JSON. |
| `400` | `invalid_amount` | `amount` must be greater than 0. |
| `400` | `invalid_bulk_size` | `payments` must contain 1 to 50 items. |
| `400` | `unsupported_payment_method` | Payment method is not supported. |
| `400` | `payment_create_failed` | Transaction could not be created. |
| `401` | `invalid_api_key` | Secret key is invalid. |
| `403` | `merchant_not_approved` | Merchant is not active. |
| `429` | `rate_limited` | Rate limit exceeded. |


---

# Transactions


> List and filter merchant transactions.

Canonical: https://docs.bayargo.id/transactions

`GET /transactions`

Returns merchant transactions.

## Query Params

| Param | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer | No | Number of transactions. Default `50`. |

## Request Example

```tsx
<ApiExample method="GET" path="/transactions?limit=50" />
```

## Response

```json
{
  "transactions": [
    {
      "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
      "reference_id": "PAY-LXAMPLE",
      "merchant_reference_id": "ORDER-1024",
      "payment_method_code": "qris",
      "currency": "IDR",
      "amount": 150000,
      "fee_amount": 1050,
      "net_amount": 150000,
      "total_amount": 151050,
      "status": "paid",
      "paid_at": "2026-05-19T10:01:00Z",
      "created_at": "2026-05-19T10:00:00Z",
      "updated_at": "2026-05-19T10:01:00Z"
    }
  ]
}
```

## Response Fields

| Field | Description |
| --- | --- |
| `transactions` | Transaction list. |
| `transactions[].id` | Transaction UUID. |
| `transactions[].reference_id` | BayarGO transaction ID. |
| `transactions[].merchant_reference_id` | Merchant order ID. |
| `transactions[].status` | Transaction status. |
| `transactions[].total_amount` | Amount the customer must pay. |

## HTTP Error Code

| HTTP | Code | Description |
| --- | --- | --- |
| `401` | `invalid_api_key` | Secret key is invalid. |
| `403` | `merchant_not_approved` | Merchant is not active. |
| `500` | `server_error` | Transactions could not be loaded. |


---

# Webhooks


> Receive and verify transaction status events.

Canonical: https://docs.bayargo.id/webhooks

Webhooks are sent to the URL registered in the merchant dashboard.

## Events

```txt
payment.created
payment.pending
payment.paid
payment.expired
payment.cancelled
payment.failed
payment.refund_processing
payment.refund_failed
payment.refunded
payment.settled
subscription_order.created
subscription_order.pending
subscription_order.paid
subscription_order.expired
subscription_order.cancelled
subscription_order.failed
```

| Event | Description |
| --- | --- |
| `payment.created` | Transaction was created. |
| `payment.pending` | Waiting for payment. |
| `payment.paid` | Payment was received. |
| `payment.expired` | Payment deadline has passed. |
| `payment.cancelled` | Transaction was cancelled. |
| `payment.failed` | Payment failed. |
| `payment.refund_processing` | Refund is being processed. |
| `payment.refund_failed` | Refund failed. |
| `payment.refunded` | Refund succeeded. |
| `payment.settled` | Transaction has entered settlement. |
| `subscription_order.created` | A plan checkout order and its payment were created. |
| `subscription_order.pending` | The plan checkout payment is waiting to be paid. |
| `subscription_order.paid` | The plan checkout payment was confirmed and the subscription was activated or scheduled. |
| `subscription_order.expired` | The plan checkout payment expired before confirmation. |
| `subscription_order.cancelled` | The plan checkout payment was cancelled. |
| `subscription_order.failed` | The plan checkout payment failed. |

## Payload

```json
{
  "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
  "event": "payment.paid",
  "reference_id": "PAY-LXAMPLE",
  "merchant_reference_id": "ORDER-1024",
  "status": "paid",
  "environment": "live",
  "amount": 150000,
  "fee_amount": 1050,
  "net_amount": 150000,
  "total_amount": 151050,
  "currency": "IDR",
  "payment_method": "qris",
  "provider": "gopay",
  "created_at": "2026-05-19T10:00:00Z",
  "updated_at": "2026-05-19T10:01:00Z"
}
```

## Headers

```http
Content-Type: application/json
User-Agent: BayarGO-Webhooks/0.1
X-Chiwa-Event: payment.paid
X-Chiwa-Delivery: 1d4c...
X-Chiwa-Signature: t=1779184860,v1=<hmac_sha256_hex>
```

Verify `X-Chiwa-Signature` before processing the payload.

Subscription checkout events use the `subscription_order.*` names and include the subscription
order ID so you can reconcile a plan purchase separately from ordinary payment events.

```json
{
  "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
  "event": "subscription_order.paid",
  "object": "subscription_order",
  "transaction_kind": "subscription",
  "subscription_order_id": "a7c16e5a-8f67-4d4a-b2d8-842aa7f08b5c",
  "reference_id": "PAY-LXAMPLE",
  "merchant_reference_id": "PLAN-ORDER-1024",
  "status": "paid",
  "environment": "live",
  "amount": 150000,
  "fee_amount": 0,
  "net_amount": 150000,
  "total_amount": 150000,
  "currency": "IDR",
  "payment_method": "qris",
  "provider": "gopay",
  "created_at": "2026-11-22T14:10:00Z",
  "updated_at": "2026-11-22T14:11:00Z"
}
```

## Merchant-owned payments

M2O payments send the same payment lifecycle events and flat payload fields. The `provider` and
`payment_method` identify the provider and method; the event does not contain the account slot code. Keep
the slot code with your order when creating a payment so your system can reconcile an event against
the correct account. See the [merchant-owned payments guide](https://docs.bayargo.id/merchant-owned-payments) for account
history and status lookup.

```json
{
  "id": "f2b1d5b0-7b1f-4c5d-9c37-93f0c8f6a001",
  "event": "payment.paid",
  "reference_id": "PAY-LXAMPLE",
  "merchant_reference_id": "ORDER-1024",
  "status": "paid",
  "environment": "live",
  "amount": 150000,
  "fee_amount": 0,
  "net_amount": 150000,
  "total_amount": 150123,
  "currency": "IDR",
  "payment_method": "bank_jago_transfer",
  "provider": "bank_jago",
  "created_at": "2026-11-22T14:10:00Z",
  "updated_at": "2026-11-22T14:11:00Z"
}
```
