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

# Refund a Payment

> POST /api/refund

Refunds a successfully paid transaction back to the customer's original payment method.

## What can be refunded

| Paid with | Refundable? | How long |
| - | - | - |
| FPX | Yes — full or partial | 3–5 business days to reach the customer |
| DuitNow QR | Yes — full or partial | 3–5 business days to reach the customer |

After a successful refund request the transaction's status becomes `Pending_Refund`, then `Refunded` once the money has been returned. Track it with [`GET /api/transaction/{ref}`](https://docs.sayabelipay.com/api-reference/transaction-details). A refund can't be cancelled once requested.

## Request

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

| Field | Type | Required | Notes |
| - | - | - | - |
| `transaction_id` | string | Yes | The transaction's reference (same value used for [transaction details](https://docs.sayabelipay.com/api-reference/transaction-details.md)). |
| `refund_reason` | string | Yes | |
| `bank_code` | string | Yes | |
| `bank_account_number` | string | Yes | Numeric. |
| `account_name` | string | Yes | |
| `email` | string | Yes | |
| `amount` | string | No | Partial refund amount (decimal, e.g. `"5.00"`). Omit for a full refund. Must be less than the transaction's total. |

> [!NOTE]
>
> `bank_code`/`bank_account_number`/`account_name`/`email` are required by this endpoint's validation on every account, but the refund itself goes back to the customer's **original payment method** automatically — these fields aren't used to redirect the money to a different destination. Send real, non-empty values to pass validation regardless.

```bash cURL theme={null}
curl -X POST https://sayabelipay.com/api/refund \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
  -d transaction_id=9B8FEEB60F9E3 \
  -d refund_reason="Customer requested" \
  -d bank_code=MYBB \
  -d bank_account_number=1234567890 \
  -d account_name="Jane Tan" \
  -d email=jane@example.com
```

```php PHP theme={null}
$response = Http::withBasicAuth($clientId, $clientSecret)->asForm()->post(
    'https://sayabelipay.com/api/refund',
    [
        'transaction_id' => '9B8FEEB60F9E3',
        'refund_reason' => 'Customer requested',
        'bank_code' => 'MYBB',
        'bank_account_number' => '1234567890',
        'account_name' => 'Jane Tan',
        'email' => 'jane@example.com',
    ]
);
```

## Response

```json theme={null}
{
  "status": 200,
  "data": {
    "status": "success",
    "...": "full refund object from the processor"
  }
}
```

### Rejected by the payment processor

If the processor refuses the refund, HTTP `502`:

```json theme={null}
{ "status": 502, "message": "ChipPay rejected the refund request.", "gateway_error": "..." }
```

### Not eligible

Only a transaction with status `Success` can be refunded. Refunding one that's still `Pending`, already refunded, or unsuccessful returns:

```json theme={null}
{ "error": 400, "message": "Only successfully paid purchases can be refunded." }
```

### Not found

```json theme={null}
{ "error": 404, "message": "Transaction not found" }
```

Returned both when `transaction_id` genuinely doesn't exist, and when it belongs to a different merchant account — this endpoint never confirms or denies the existence of another merchant's transactions.


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