Skip to content

Create Payment

This endpoint is used to create new payment transactions. It supports various payment methods through a single uniform interface. You only need to change the method_type and method_detail parameters.

⚠️ Important: Only tenants with the Client role can access this endpoint. You must use an API Key, not a JWT.

http
POST /v1/payments/create

Request Headers

HeaderTypeRequiredDescription
AuthorizationstringMust contain Bearer {api_key}
Content-TypestringAlways application/json
X-Idempotency-KeystringA unique key per order (e.g., your system's order number) to prevent duplication in case of network errors

Request Body

FieldTypeRequiredDescription
amountintegerThe bill amount in the smallest unit (cents). Example: Rp 100,000 is written as 10000000
currencystringThe currency. Currently only supports "IDR"
method_typestringThe payment method type. See the Method Type table
method_detailobjectSpecific parameters for the payment method. Always include the "type" field with the same value as method_type. See per-method details below
customer_namestringYour customer's name
customer_emailstringCustomer's email (must be a valid email format if provided)
customer_phonestringCustomer's phone number (important for some E-Wallet types)
itemsarrayDetails of products/services purchased by the customer
expiry_minutesintegerExpiration time in minutes. Default: 60. Minimum: 2 (Winpay)

Method Type (method_type)

ValueDescription
virtual_accountBank Virtual Account Transfer
qrisQRIS Payment (Dynamic)
e_walletDigital Wallets (OVO, DANA, etc.)
over_the_counterPayments at retail outlets (Alfamart, Indomaret)

Method Detail

The method_detail field is required, and its object structure depends on the method_type value. Note that the "type" field must be present inside the method_detail object.

1. Virtual Account

json
{
  "type": "virtual_account",
  "bank": "BCA" // See active banks list at /v1/active-methods
}

2. QRIS

json
{
  "type": "qris"
}

3. E-Wallet

json
{
  "type": "e_wallet",
  "wallet_type": "DANA" // OVO, DANA, SHOPEEPAY, etc.
}

4. Over The Counter (Retail)

json
{
  "type": "over_the_counter",
  "store": "ALFAMART" // ALFAMART, INDOMARET
}

Array Items

Optional array object for product details:

json
[
  {
    "id": "SKU-001",
    "name": "Kopi Susu Gula Aren",
    "price": 2500000, 
    "quantity": 2
  }
]

(Remember: price is in cents, so 2500000 = Rp 25,000)


Response

The standard response structure returns payment details including method-specific instructions (method_data).

Success Response (200 OK)

json
{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "tenant_id": "b6a3b2b8-f09d-4767-8fa0-68153c30a91f",
    "payment_code": "TEST-12345678",
    "idempotency_key": "order-123",
    "amount": 10000000,
    "currency": "IDR",
    "method_type": "virtual_account",
    "method_data": {
      "type": "virtual_account",
      "bank": "BCA",
      "va_number": "88880123456789"
    },
    "status": "pending",
    "provider": "winpay",
    "provider_payment_id": "WP-998877",
    "customer_name": "Budi Santoso",
    "customer_email": "[email protected]",
    "customer_phone": "081234567890",
    "items": [],
    "expires_at": "2026-07-21T12:00:00Z",
    "paid_at": null,
    "amount_paid": null,
    "failure_reason": null,
    "created_at": "2026-07-21T11:00:00Z",
    "updated_at": "2026-07-21T11:00:00Z"
  }
}

Response Field method_data

This field changes according to the payment method, similar to the request's method_detail:

  • Virtual Account: { "type": "virtual_account", "bank": "BCA", "va_number": "8888..." }
  • QRIS: { "type": "qris", "qr_string": "000201010211...", "qr_image_url": "https://..." }
  • E-Wallet: { "type": "e_wallet", "wallet_type": "DANA", "redirect_url": "https://...", "deeplink": "dana://..." }
  • Over The Counter: { "type": "over_the_counter", "store_name": "ALFAMART", "payment_code": "44445555" }

Complete Request Examples

1. Virtual Account

bash
curl -X POST https://gerbang-pay-api.gai.co.id/v1/payments/create \
  -H "Authorization: ApiKey gp_live_xxx" \
  -H "Content-Type: application/json" \
  -H "X-Idempotency-Key: order-va-001" \
  -d '{
    "amount": 15000000,
    "currency": "IDR",
    "method_type": "virtual_account",
    "method_detail": { "type": "virtual_account", "bank": "BCA" },
    "customer_name": "Budi"
  }'

2. QRIS

bash
curl -X POST https://gerbang-pay-api.gai.co.id/v1/payments/create \
  -H "Authorization: ApiKey gp_live_xxx" \
  -H "Content-Type: application/json" \
  -H "X-Idempotency-Key: order-qris-002" \
  -d '{
    "amount": 5000000,
    "currency": "IDR",
    "method_type": "qris",
    "method_detail": { "type": "qris" }
  }'

3. E-Wallet

bash
curl -X POST https://gerbang-pay-api.gai.co.id/v1/payments/create \
  -H "Authorization: ApiKey gp_live_xxx" \
  -H "Content-Type: application/json" \
  -H "X-Idempotency-Key: order-ewallet-003" \
  -d '{
    "amount": 2500000,
    "currency": "IDR",
    "method_type": "e_wallet",
    "method_detail": { "type": "e_wallet", "wallet_type": "OVO" }
  }'

4. Over The Counter (Retail)

bash
curl -X POST https://gerbang-pay-api.gai.co.id/v1/payments/create \
  -H "Authorization: ApiKey gp_live_xxx" \
  -H "Content-Type: application/json" \
  -H "X-Idempotency-Key: order-otc-004" \
  -d '{
    "amount": 10000000,
    "currency": "IDR",
    "method_type": "over_the_counter",
    "method_detail": { "type": "over_the_counter", "store": "ALFAMART" }
  }'

Common Error Responses

400 Bad Request

json
{
  "success": false,
  "error": {
    "code": "BAD_REQUEST",
    "message": "bad request: Amount must be greater than zero"
  }
}

409 Idempotency Conflict

Occurs if you send the exact same X-Idempotency-Key but with different body parameters.

json
{
  "success": false,
  "error": {
    "code": "IDEMPOTENCY_CONFLICT",
    "message": "idempotency conflict: Same key submitted with different payload"
  }
}

502 Provider Error

Occurs if the Winpay or Midtrans server rejects your request (e.g., incorrect bank name).

json
{
  "success": false,
  "error": {
    "code": "PROVIDER_ERROR",
    "message": "provider error [winpay]: Bank BCA is not supported for this merchant"
  }
}

Gerbang Pay API Documentation