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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 金额和币种

> 如何发送 amount.value：主单位、ISO 4217 币种代码，以及 KRW、JPY、CLP 等零小数位币种的整数规则。

您发送到 Yuno API 的每个金额都是一个包含 `currency` 和 `value` 的对象。`currency` 是 ISO 4217 三字母代码。`value` 是以该币种主单位表示的金额：对于 USD 25.00，请发送 `25`，而不是 `2500`。

有 16 种币种没有辅币单位。对于这些币种，`value` 必须是整数。Yuno 不会为您舍入或截断该值：如果请求中的 `value` 带有小数部分，Yuno 会在创建任何内容之前返回 `400 INVALID_PARAMETERS`。

```json Request theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
"amount": {
  "currency": "KRW",
  "value": 11833
}
```

## 零小数位币种

| 代码 | 币种 |
| :- | :- |
| `BIF` | 布隆迪法郎 |
| `CLP` | 智利比索 |
| `DJF` | 吉布提法郎 |
| `GNF` | 几内亚法郎 |
| `ISK` | 冰岛克朗 |
| `JPY` | 日元 |
| `KMF` | 科摩罗法郎 |
| `KRW` | 韩元 |
| `PYG` | 巴拉圭瓜拉尼 |
| `RWF` | 卢旺达法郎 |
| `UGX` | 乌干达先令 |
| `VND` | 越南盾 |
| `VUV` | 瓦努阿图瓦图 |
| `XAF` | 中非法郎 |
| `XOF` | 西非法郎 |
| `XPF` | 太平洋法郎 |

其他所有币种都接受带小数的 `value`。`COP` 不在此列表中，因为 ISO 4217 规定哥伦比亚比索有两位小数，所以 `COP 11833.2` 会被接受，而 `KRW 11833.2` 不会。各国币种的小数位数列在[国家/地区参考](https://docs.y.uno/reference/country-reference.md)中。

末尾的零不会导致校验失败：对于 `KRW`，`11833.00` 会被接受，而 `11833.2` 会被拒绝。

## 规则的适用范围

对于在币种代码旁携带 `value` 的每个字段，Yuno 都会在创建操作的请求和更新操作的请求中进行校验：

* [结账会话](https://docs.y.uno/zh-hans/reference/checkout-sessions/create-checkout-session.md)、[支付](https://docs.y.uno/zh-hans/reference/payments/create-payment.md)和[支付链接](https://docs.y.uno/reference/payment-links/create-payment-link.md)中的 `amount`。
* 退款中的 `amount`：[退款支付](https://docs.y.uno/reference/payments/refund-payment.md)、[取消或退款支付](https://docs.y.uno/reference/payments/cancel-or-refund-a-payment.md)以及[通过交易取消或退款支付](https://docs.y.uno/reference/payments/cancel-or-refund-payment-with-transaction.md)。该校验在 Yuno 查找支付之前运行，因此对 `KRW` 支付进行带小数的部分退款也会以相同的错误失败。
* 根据 `cardholder_currency` 校验 `currency_conversion.cardholder_amount`，根据 `merchant_currency` 校验 `merchant_amount`。
* 拆分支付金额，以及收款方拆分配置中的 `fixed_amount`。
* 订阅、计划、计量器、配送方式和 payout 金额。

## 错误

```json Response theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "INVALID_PARAMETERS",
  "messages": [
    "The field 'amount.value' has an invalid amount."
  ]
}
```

该消息会指出校验失败的字段。带小数的 `cardholder_amount` 会返回 `The field 'currency_conversion.cardholder_amount' has an invalid amount.`

## 在构建订单时舍入一次

如果您的商品目录以两位小数定价，请在构建订单时按照您的定价所要求的舍入规则，将每一行舍入为整数单位，并存储舍入后的值。在结账会话、支付和每笔退款中发送这些相同的整数。

不要在每次 API 调用时都从两位小数的值进行舍入。一次性舍入的总额与逐行舍入的一组明细项可能相差一个单位，这会导致部分退款失败，或使退款总额超过已收取的金额。

对于部分退款，请根据已存储的整数单位行金额计算退款 `value`，并检查该支付所有退款的总和不超过其已收取的 `amount.value`。

## 示例

第一个请求被拒绝，因为 `value` 带有小数部分。第二个请求是同一订单，其值已舍入到整韩元。

```bash Rejected theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request POST \
     --url https://api-sandbox.y.uno/v1/checkout/sessions \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'private-secret-key: <Your private-secret-key>' \
     --header 'public-api-key: <Your public-api-key>' \
     --data '
{
  "account_id": "{{account-code}}",
  "customer_id": "{{customer-id}}",
  "merchant_order_id": "order-kr-0001",
  "payment_description": "Tickets",
  "country": "KR",
  "amount": {
    "currency": "KRW",
    "value": 11833.2
  }
}
'
```

```json Response theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "code": "INVALID_PARAMETERS",
  "messages": [
    "The field 'amount.value' has an invalid amount."
  ]
}
```

```bash Accepted theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request POST \
     --url https://api-sandbox.y.uno/v1/checkout/sessions \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'private-secret-key: <Your private-secret-key>' \
     --header 'public-api-key: <Your public-api-key>' \
     --data '
{
  "account_id": "{{account-code}}",
  "customer_id": "{{customer-id}}",
  "merchant_order_id": "order-kr-0001",
  "payment_description": "Tickets",
  "country": "KR",
  "amount": {
    "currency": "KRW",
    "value": 11833
  }
}
'
```

同一笔支付的部分退款也遵循相同的规则：

```bash Partial refund theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request POST \
     --url https://api-sandbox.y.uno/v1/payments/{{payment-id}}/cancel-or-refund \
     --header 'X-Idempotency-Key: <Your idempotency-key>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'private-secret-key: <Your private-secret-key>' \
     --header 'public-api-key: <Your public-api-key>' \
     --data '
{
  "description": "One ticket refunded",
  "reason": "REQUESTED_BY_CUSTOMER",
  "merchant_reference": "order-kr-0001-refund-1",
  "amount": {
    "currency": "KRW",
    "value": 1183
  }
}
'
```

## 相关内容

* **参考：**[故障排除](https://docs.y.uno/zh-hans/docs/troubleshooting.md)列出了此错误以及其他常见响应。
* **参考：**[国家/地区参考](https://docs.y.uno/reference/country-reference.md)提供了每个国家/地区的币种及其小数位数。
* **指南：**[退款支付](https://docs.y.uno/zh-hans/docs/direct-integration-use-cases/refund-payments.md)介绍了全额退款和部分退款。
* **参考：**[支付详情](https://docs.y.uno/zh-hans/docs/payment-features/payment-amount-details.md)将总额拆分为费用、运费、小费、税费和折扣。


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