# 付款

## gateway_transaction_query

向金流查一筆交易；金流說已經付款的話，把付款記到請款單上。

給 Agent 的原文：

> Ask the payment gateway about a transaction; when it says paid, the payment is recorded on the bill.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string | 必填 |  |
| `idempotency_key` | string | 必填 | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`payments:record`

寫入、核可：不用

## gateway_transaction_search

查線上付款的金流交易（新的在前），或用 id 查一筆和它收到的通知。

給 Agent 的原文：

> Search online payment transactions (newest first), or get one with its notifications by id.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string（可以是 null） |  | Get one transaction with its notifications instead of searching |
| `limit` | integer |  | default: 20 |
| `cursor` | string（可以是 null） |  |  |
| `created_from` | date（可以是 null） |  |  |
| `created_to` | date（可以是 null） |  |  |
| `statuses` | PENDING \| AWAITING_PAYMENT \| PAID \| FAILED \| UNMATCHED[]（可以是 null） |  |  |
| `keyword` | string |  | Part of the transaction number or bill number |

授權項目：`payments:read`

核可：不用

## payment_record

記錄一筆不是經金流收到的付款（例如轉帳、現金），回更新後的請款單。一定要人核可。

給 Agent 的原文：

> Record a manual payment (bank transfer, cash…) on a bill. Returns the updated bill.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `bill` | string | 必填 | Bill number (BL-000001) or id |
| `amount` | string | 必填 |  |
| `method` | BANK_TRANSFER \| CASH \| CHECK \| CREDIT_CARD \| OTHER \| ATM \| CVS \| BARCODE | 必填 |  |
| `paid_date` | date | 必填 |  |
| `reference` | string |  |  |
| `note` | string |  |  |
| `idempotency_key` | string | 必填 | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`payments:record`

寫入、核可：一定要

## payment_search

查付款，付款日新的在前；作廢的要帶 include_voided 才回。

給 Agent 的原文：

> Search payments, newest payment date first; voided ones only with include_voided.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `limit` | integer |  | 1 to 100 default: 20 |
| `cursor` | string（可以是 null） |  | next_cursor from the previous page |
| `paid_date_from` | date（可以是 null） |  |  |
| `paid_date_to` | date（可以是 null） |  |  |
| `methods` | BANK_TRANSFER \| CASH \| CHECK \| CREDIT_CARD \| OTHER \| ATM \| CVS \| BARCODE[]（可以是 null） |  |  |
| `customer_ref` | string（可以是 null） |  |  |
| `include_voided` | boolean |  | default: false |

授權項目：`payments:read`

核可：不用

## payment_void

作廢一筆手動記錄的付款（紀錄留著），回更新後的請款單。一定要人核可。

給 Agent 的原文：

> Void a manual payment (the record stays). Returns the updated bill.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `payment_id` | string | 必填 |  |
| `reason` | string | 必填 |  |
| `idempotency_key` | string | 必填 | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`payments:void`

寫入、核可：一定要

## unmatched_payment_resolve

把一筆重複或多付的款項標成已處理，附上怎麼處理的說明。一定要人核可。

給 Agent 的原文：

> Mark an unmatched online payment as handled, with a note on how.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string | 必填 |  |
| `note` | string | 必填 | How it was handled (1 to 200 characters) |
| `idempotency_key` | string | 必填 | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`payments:record`

寫入、核可：一定要

## unmatched_payment_search

查沒辦法記到請款單上的線上付款（重複或多付的款項）；沒帶 include_resolved 只回還沒處理的。

給 Agent 的原文：

> Search online payments that could not be recorded on their bill; only unresolved ones unless include_resolved.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `limit` | integer |  | default: 20 |
| `cursor` | string（可以是 null） |  |  |
| `include_resolved` | boolean |  | default: false |

授權項目：`payments:read`

核可：不用
