> ## 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.

# Getting Payment Status

> Why polling matters — there is no push webhook to your server

> [!WARNING]
>
> SayaBeliPay does not send your server a push notification (webhook) when a payment's status changes. There is no event subscription to configure. Status reaches you two ways, and only one of them is reliable — read on.

## 1. The browser redirect (not reliable on its own)

After the customer finishes (or abandons) checkout, their browser is redirected to your account's **Callback URL**, with the outcome appended as query parameters:

```
https://your-site.com/finish?transactionId=9B8FEEB60F9E3&merchantOrderNo=YOUR_ORDER_NO&status=Success
```

This is a genuinely useful signal — it's how you'd show the customer an immediate "payment successful" page — but it is **not guaranteed to happen**. If the customer closes the tab, loses connection, or their browser is blocked from redirecting for any reason, this never reaches you at all, regardless of whether the payment actually succeeded on the processor's side.

> [!WARNING]
>
> Never mark an order as paid, ship a product, or grant access to a service based on this redirect alone. Treat it purely as a UX signal for the customer in front of you right now, and confirm the real status server-side before acting on it.

## 2. Polling the API (the reliable source of truth)

Call [`GET /api/transaction/{ref}`](https://docs.sayabelipay.com/api-reference/transaction-details) with the `transactionId` you were given when you created the payment (the `transaction_id` field in the [create payment](https://docs.sayabelipay.com/api-reference/create-payment.md) response context, i.e. your own reference — see that page for exactly which value to use).

```bash theme={null}
curl https://sayabelipay.com/api/transaction/9B8FEEB60F9E3 \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"
```

```json theme={null}
{
  "status": 200,
  "data": {
    "transaction_id": "9B8FEEB60F9E3",
    "order_no": "YOUR_ORDER_NO",
    "status": "Success",
    "transaction_amount": "20.00",
    "...": "..."
  }
}
```

### Recommended pattern

1. Right after creating the payment, start polling this endpoint for that transaction on a short interval (e.g. every 5–10 seconds) — from your server, not the customer's browser.
2. Stop polling once `status` reaches a final value (`Success`, `Unsuccessful` or `Expired` — see below).
3. If the browser redirect arrives in the meantime, use it to update the UI immediately, but keep treating the poll result as the source of truth for actually fulfilling the order.
4. If nothing terminal happens within a reasonable window (a few minutes), stop polling on a schedule and fall back to checking manually or via [`GET /api/transactions`](https://docs.sayabelipay.com/api-reference/list-transactions) later — a payment that's still genuinely pending on the processor's side can take longer than a typical polling window to resolve.

### Status values

| `status` | Meaning | Final? |
| - | - | - |
| `Pending` | Waiting for the customer to pay, or the bank is still confirming. | No — keep polling |
| `Success` | Paid. Money received. | Yes |
| `Unsuccessful` | Payment failed or was declined, or the customer cancelled on the checkout page. | Yes |
| `Expired` | Not paid within 60 minutes (e.g. the customer closed the tab). | Yes |
| `Cancelled` | You cancelled it with [the cancel endpoint](https://docs.sayabelipay.com/api-reference/cancel-transaction.md). The customer can no longer pay it. | Yes |
| `Overdue` | The checkout's due time passed without payment. | Treat as not paid |
| `Pending_Refund` | A refund was requested and is being processed. | No |
| `Refunded` | The refund has completed. | Yes |

The same value is appended as `status` to your Callback URL when the customer returns from checkout.

> [!WARNING]
>
> Only `Success` means "money received." Treat every other value as **not paid**, and don't hard-fail on a value you don't recognise — new values may be added.


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