> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sayabelipay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Payment

> POST /api/payment

Creates a new payment and returns a checkout URL to redirect your customer to.

## Request

```
POST https://sayabelipay.com/api/payment
Content-Type: application/x-www-form-urlencoded
Authorization: Basic base64(client_id:client_secret)
```

| Field | Type | Required | Notes |
| - | - | - | - |
| `amount` | string | Yes | Minimum `10.00`. Format as a decimal string, e.g. `"20.00"`. |
| `quantity` | integer | Yes | Minimum `1`. |
| `order_no` | string | Yes | Your order reference. Must be **unique across SayaBeliPay** — a value that has been used before is rejected, so prefix it with something specific to your business (e.g. `ACME-1234`). |
| `order_detail` | string | Yes | Max 30 characters. Letters, numbers and spaces only — no punctuation. |
| `customer_name` | string | Yes | |
| `customer_email` | string | Yes | Must be a valid email address. |
| `customer_phone` | string | Yes | Numeric only, no `+` or spaces, e.g. `60123456789`. |
| `channel` | string | Yes | `FPX` or `DUITNOW_QR`. See [Payment Channels](https://docs.sayabelipay.com/guides/payment-channels.md). |
| `qr` | string | No | `1` to get the DuitNow QR itself instead of a checkout URL (`DUITNOW_QR`, live accounts only). See [DuitNow QR Generation](https://docs.sayabelipay.com/guides/duitnow-qr-own-page.md). |
| `hash` | string | Yes | See [Hash Generation](https://docs.sayabelipay.com/guides/hash-generation.md). |

```bash cURL theme={null}
curl -X POST https://sayabelipay.com/api/payment \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
  -d amount=20.00 \
  -d quantity=1 \
  -d order_no=ACME-1234 \
  -d order_detail="Order 1234" \
  -d customer_name="Jane Tan" \
  -d customer_email=jane@example.com \
  -d customer_phone=60123456789 \
  -d channel=FPX \
  -d hash=YOUR_COMPUTED_HASH
```

```php PHP theme={null}
$response = Http::withBasicAuth($clientId, $clientSecret)->asForm()->post(
    'https://sayabelipay.com/api/payment',
    [
        'amount' => '20.00',
        'quantity' => 1,
        'order_no' => 'ACME-1234',
        'order_detail' => 'Order 1234',
        'customer_name' => 'Jane Tan',
        'customer_email' => 'jane@example.com',
        'customer_phone' => '60123456789',
        'channel' => 'FPX',
        'hash' => $hash,
    ]
);
```

## Response

```json theme={null}
{
  "status": 200,
  "data": "https://gate.chip-in.asia/p/9b8feeb6-0f9e-.../"
}
```

`data` is the checkout URL — redirect your customer there. Always use the URL from the response rather than building one yourself.

## Errors

**Missing or malformed fields** — HTTP `422`:

```json theme={null}
{ "errors": { "amount": ["The amount must be at least RM 10.00."] } }
```

**`order_no` already used** — HTTP `400`:

```json theme={null}
{ "order_no": ["The order no is already exist."] }
```

The following come back with HTTP `200`, so always check the `status` field in the body, not just the HTTP code:

| Body `status` | Message | Meaning |
| - | - | - |
| `400` | The selected payment channel is not currently available. | The `channel` isn't enabled on your account. See [Payment Channels](https://docs.sayabelipay.com/guides/payment-channels.md). |
| `403` | Live payments are not enabled for this account yet. Please contact SayaBeliPay. | Your account is in Live Mode but live payments haven't been enabled. See [Going live](https://docs.sayabelipay.com/getting-started.md#going-live). |
| `502` | Payment gateway is temporarily unavailable. Please try again later. | The payment processor didn't respond. Nothing was created, so it's safe to retry with the same `order_no`. |

## After this call

The response contains only the checkout URL. To check this payment's status later, use the `transactionId` that reaches you via the [browser redirect](https://docs.sayabelipay.com/guides/payment-status.md) when the customer returns from checkout, or find the payment by `order_no` via [`GET /api/transactions`](https://docs.sayabelipay.com/api-reference/list-transactions).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.