---
title: "订单退款试算"
description: "订单退款试算接口"
doc_type: openapi
doc_category: openapi
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/order/order-management/order-refund-trial'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-rest-api/order/order-management/order-refund-trial.md'
---
# 订单退款试算

订单退款试算接口

- **Base URL:** `https://{handle}.myshopline.com/admin/openapi`
- **Required Scopes:** `write_orders`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** RESTful

## Endpoint

```http
POST /orders/:order_id/refunds/calculate.json
```

## Base URL

* `https://{handle}.myshopline.com/admin/openapi`

  * `{handle}`: `handle` ：店铺的唯一标识符，值为店铺域名的前缀。例如，域名为 `open001.myshopline.com` 的店铺，其 `handle` 是 `open001` 。

## Required Permissions

* `write_orders`

## Request

### Path Parameters

* `order_id`

  string (required)

  订单id

### Request Headers

* `Content-Type`

  string (required)

  字段值固定为 `application/json; charset=utf-8`。

* `Authorization`

  string (required)

  资源的访问令牌。参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入。

### Request Body

* `refund_line_items`

  array<object>

  试算商品

  * `line_item_id`

    string

    试算退款商品行id

  * `quantity`

    long

    试算退款商品数量

  * `type`

    string

    当以商品进行退款时, 价格试算需要提供商品的发货状态 Unshipped：商品未发货；Returned：商品已退货

* `shipping`

  object

  运费

  * `amount`

    string

    要退的运费金额，double类型字符串，精度2

  * `full_refund`

    boolean

    是否退完剩余运费

* `currency`

  string

  结算币种，非必填 币种没传，应用会校验订单结算币种是否为店铺币种，如果不是店铺币种，就会报错，提示必须传结算币种："currency must be X" 币种有传，则校验币种是否为该订单的结算币种，如果不是会报错，提示："currency must be X"

## Response

### Status Codes

* `200`

  更多状态码信息，参考 [HTTP 状态码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/http-status-code.md?lang=zh-hans-cn)。

* `401`

  

* `429`

  

### Response Headers

* `traceId`

  请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。

### Response Body

#### 200

* `refund`

  object

  试算结果

  * `transactons`

    array<object>

    当试算金额大于0时，原路返回系统按照规则自动回填支付单及金额

    * `maximum_refundable`

      string

      当前支付单当可退最大金额

    * `order_id`

      string

      订单编号

    * `parent_id`

      string

      支付单号

    * `amount`

      string

      金额，该支付单结算币种的对应金额

    * `currency`

      string

      币种，该支付单对应的结算币种

    * `gateway`

      string

      支付渠道

    * `kind`

      string

      suggested_refund

  * `currency`

    string

    币种，该退款对应的结算币种

  * `refund_line_items`

    array<object>

    当有商品行应退金额试算请求时返回

    * `type`

      string

      要计算的商品所属, Unshipped：商品未发货，Shipped：商品已发货， Returned：商品已退货

    * `discount_total_amount`

      string

      商品行总折扣金额

    * `line_item_id`

      string

      商品行（入参商品行）

    * `price`

      string

      商品售价

    * `quantity`

      integer

      数量（实际可退数量）

    * `subtotal`

      string

      商品行应退金额

    * `total_tax`

      string

      商品行应退税金额

  * `shipping`

    object

    当有运费试算请求时返回

    * `amount`

      string

      订单运费

    * `maximum_refundable`

      string

      最大可退运费

    * `tax`

      string

      订单运费税

  * `total_duties_set`

    object

    退款总关税

    * `shop_money`

      object

      卖家侧金额信息

      * `amount`

        string

        金额

      * `currency_code`

        string

        币种

    * `presentment_money`

      object

      买家侧金额信息

      * `amount`

        string

        金额

      * `currency_code`

        string

        币种


#### 401

* `errors`

  string

  错误描述。


#### 429

* `errors`

  string

  错误描述。


## OpenAPI Definition

```json
{
  "description": "订单退款试算接口",
  "externalDocs": {
    "description": "接口使用的权限点: `write_orders` ，更多权限点使用信息，请参考:",
    "url": "ec20/3cv5d7wpfgr6a8z5/xabczf5442284vkq?lang=zh-hans-cn",
    "errorTableDescription": ""
  },
  "operationId": "WdjOC38Q",
  "parameters": [
    {
      "name": "order_id",
      "in": "path",
      "description": "订单id",
      "required": true,
      "style": "simple",
      "schema": {
        "name": "order_id",
        "description": "订单id",
        "type": "string",
        "example": ""
      },
      "example": ""
    },
    {
      "name": "Content-Type",
      "in": "header",
      "description": "字段值固定为 `application/json; charset=utf-8`。",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Content-Type",
        "type": "string",
        "example": "application/json; charset=utf-8"
      }
    },
    {
      "name": "Authorization",
      "in": "header",
      "description": "资源的访问令牌。参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入。",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Authorization",
        "description": "资源的访问令牌。请参考 [应用授权](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/app-authorization.md?lang=zh-hans-cn) 获取访问令牌，然后将获取到的访问令牌以 Bearer 格式传入",
        "type": "string",
        "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
      },
      "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "refund_line_items": {
              "name": "refund_line_items",
              "description": "试算商品",
              "type": "array",
              "items": {
                "name": "refund_line_items",
                "description": "试算商品",
                "type": "object",
                "properties": {
                  "line_item_id": {
                    "name": "line_item_id",
                    "description": "试算退款商品行id",
                    "type": "string",
                    "example": "\"12343423111\""
                  },
                  "quantity": {
                    "name": "quantity",
                    "description": "试算退款商品数量",
                    "type": "long",
                    "example": 1
                  },
                  "type": {
                    "name": "type",
                    "description": "当以商品进行退款时, 价格试算需要提供商品的发货状态 Unshipped：商品未发货；Returned：商品已退货",
                    "type": "string",
                    "example": ""
                  }
                },
                "required": [
                  "type"
                ],
                "example": {
                  "type": "",
                  "line_item_id": "\"12343423111\"",
                  "quantity": 1
                }
              },
              "example": [
                {
                  "line_item_id": "\"12343423111\"",
                  "quantity": 1,
                  "type": ""
                }
              ]
            },
            "shipping": {
              "name": "shipping",
              "description": "运费",
              "type": "object",
              "properties": {
                "amount": {
                  "name": "amount",
                  "description": "要退的运费金额，double类型字符串，精度2",
                  "type": "string",
                  "example": "\"10.00\""
                },
                "full_refund": {
                  "name": "full_refund",
                  "description": "是否退完剩余运费",
                  "type": "boolean",
                  "example": true
                }
              },
              "example": {
                "full_refund": true,
                "amount": "\"10.00\""
              }
            },
            "currency": {
              "name": "currency",
              "description": "结算币种，非必填 币种没传，应用会校验订单结算币种是否为店铺币种，如果不是店铺币种，就会报错，提示必须传结算币种：\"currency must be X\" 币种有传，则校验币种是否为该订单的结算币种，如果不是会报错，提示：\"currency must be X\"",
              "type": "string",
              "example": "USD"
            }
          },
          "example": {
            "currency": "USD",
            "refund_line_items": [
              {
                "quantity": 1,
                "type": "",
                "line_item_id": "\"12343423111\""
              }
            ],
            "shipping": {
              "full_refund": true,
              "amount": "\"10.00\""
            }
          }
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "更多状态码信息，参考 [HTTP 状态码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/http-status-code.md?lang=zh-hans-cn)。",
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "refund": {
                "name": "refund",
                "description": "试算结果",
                "type": "object",
                "properties": {
                  "transactons": {
                    "name": "transactons",
                    "description": "当试算金额大于0时，原路返回系统按照规则自动回填支付单及金额",
                    "type": "array",
                    "items": {
                      "name": "transactons",
                      "description": "当试算金额大于0时，原路返回系统按照规则自动回填支付单及金额",
                      "type": "object",
                      "properties": {
                        "maximum_refundable": {
                          "name": "maximum_refundable",
                          "description": "当前支付单当可退最大金额",
                          "type": "string",
                          "example": "\"41.89\""
                        },
                        "order_id": {
                          "name": "order_id",
                          "description": "订单编号",
                          "type": "string",
                          "example": "\"21056836827909126061559008\""
                        },
                        "parent_id": {
                          "name": "parent_id",
                          "description": "支付单号",
                          "type": "string",
                          "example": "\"26056836827909126061559008\""
                        },
                        "amount": {
                          "name": "amount",
                          "description": "金额，该支付单结算币种的对应金额",
                          "type": "string",
                          "example": "\"41.89\""
                        },
                        "currency": {
                          "name": "currency",
                          "description": "币种，该支付单对应的结算币种",
                          "type": "string",
                          "example": "\"CNY\""
                        },
                        "gateway": {
                          "name": "gateway",
                          "description": "支付渠道",
                          "type": "string",
                          "example": "bogus"
                        },
                        "kind": {
                          "name": "kind",
                          "description": "suggested_refund",
                          "type": "string",
                          "example": "suggested_refund"
                        }
                      },
                      "example": {
                        "amount": "\"41.89\"",
                        "currency": "\"CNY\"",
                        "gateway": "bogus",
                        "kind": "suggested_refund",
                        "maximum_refundable": "\"41.89\"",
                        "order_id": "\"21056836827909126061559008\"",
                        "parent_id": "\"26056836827909126061559008\""
                      }
                    },
                    "example": [
                      {
                        "kind": "suggested_refund",
                        "maximum_refundable": "\"41.89\"",
                        "order_id": "\"21056836827909126061559008\"",
                        "parent_id": "\"26056836827909126061559008\"",
                        "amount": "\"41.89\"",
                        "currency": "\"CNY\"",
                        "gateway": "bogus"
                      }
                    ]
                  },
                  "currency": {
                    "name": "currency",
                    "description": "币种，该退款对应的结算币种",
                    "type": "string",
                    "example": "\"CNY\""
                  },
                  "refund_line_items": {
                    "name": "refund_line_items",
                    "description": "当有商品行应退金额试算请求时返回",
                    "type": "array",
                    "items": {
                      "name": "refund_line_items",
                      "description": "当有商品行应退金额试算请求时返回",
                      "type": "object",
                      "properties": {
                        "type": {
                          "name": "type",
                          "description": "要计算的商品所属, Unshipped：商品未发货，Shipped：商品已发货， Returned：商品已退货",
                          "type": "string",
                          "example": ""
                        },
                        "discount_total_amount": {
                          "name": "discount_total_amount",
                          "description": "商品行总折扣金额",
                          "type": "string",
                          "example": "\"199.00\""
                        },
                        "line_item_id": {
                          "name": "line_item_id",
                          "description": "商品行（入参商品行）",
                          "type": "string",
                          "example": "\"33121216544\""
                        },
                        "price": {
                          "name": "price",
                          "description": "商品售价",
                          "type": "string",
                          "example": "\"199.00\""
                        },
                        "quantity": {
                          "name": "quantity",
                          "description": "数量（实际可退数量）",
                          "type": "integer",
                          "example": 1
                        },
                        "subtotal": {
                          "name": "subtotal",
                          "description": "商品行应退金额",
                          "type": "string",
                          "example": "\"195.67\""
                        },
                        "total_tax": {
                          "name": "total_tax",
                          "description": "商品行应退税金额",
                          "type": "string",
                          "example": "\"195.67\""
                        }
                      },
                      "example": {
                        "line_item_id": "\"33121216544\"",
                        "price": "\"199.00\"",
                        "quantity": 1,
                        "subtotal": "\"195.67\"",
                        "total_tax": "\"195.67\"",
                        "type": "",
                        "discount_total_amount": "\"199.00\""
                      }
                    },
                    "example": [
                      {
                        "total_tax": "\"195.67\"",
                        "type": "",
                        "discount_total_amount": "\"199.00\"",
                        "line_item_id": "\"33121216544\"",
                        "price": "\"199.00\"",
                        "quantity": 1,
                        "subtotal": "\"195.67\""
                      }
                    ]
                  },
                  "shipping": {
                    "name": "shipping",
                    "description": "当有运费试算请求时返回",
                    "type": "object",
                    "properties": {
                      "amount": {
                        "name": "amount",
                        "description": "订单运费",
                        "type": "string",
                        "example": "\"5.00\""
                      },
                      "maximum_refundable": {
                        "name": "maximum_refundable",
                        "description": "最大可退运费",
                        "type": "string",
                        "example": "\"10.00\""
                      },
                      "tax": {
                        "name": "tax",
                        "description": "订单运费税",
                        "type": "string",
                        "example": "\"1.00\""
                      }
                    },
                    "example": {
                      "tax": "\"1.00\"",
                      "amount": "\"5.00\"",
                      "maximum_refundable": "\"10.00\""
                    }
                  },
                  "total_duties_set": {
                    "name": "total_duties_set",
                    "description": "退款总关税",
                    "type": "object",
                    "properties": {
                      "shop_money": {
                        "name": "shop_money",
                        "description": "卖家侧金额信息",
                        "type": "object",
                        "properties": {
                          "amount": {
                            "name": "amount",
                            "description": "金额",
                            "type": "string",
                            "example": "8.88"
                          },
                          "currency_code": {
                            "name": "currency_code",
                            "description": "币种",
                            "type": "string",
                            "example": "USD"
                          }
                        },
                        "example": {
                          "amount": "8.88",
                          "currency_code": "USD"
                        }
                      },
                      "presentment_money": {
                        "name": "presentment_money",
                        "description": "买家侧金额信息",
                        "type": "object",
                        "properties": {
                          "amount": {
                            "name": "amount",
                            "description": "金额",
                            "type": "string",
                            "example": "8.88"
                          },
                          "currency_code": {
                            "name": "currency_code",
                            "description": "币种",
                            "type": "string",
                            "example": "USD"
                          }
                        },
                        "example": {
                          "amount": "8.88",
                          "currency_code": "USD"
                        }
                      }
                    },
                    "example": {
                      "presentment_money": {
                        "currency_code": "USD",
                        "amount": "8.88"
                      },
                      "shop_money": {
                        "amount": "8.88",
                        "currency_code": "USD"
                      }
                    }
                  }
                },
                "example": {
                  "shipping": {
                    "tax": "\"1.00\"",
                    "amount": "\"5.00\"",
                    "maximum_refundable": "\"10.00\""
                  },
                  "total_duties_set": {
                    "presentment_money": {
                      "amount": "8.88",
                      "currency_code": "USD"
                    },
                    "shop_money": {
                      "currency_code": "USD",
                      "amount": "8.88"
                    }
                  },
                  "transactons": [
                    {
                      "maximum_refundable": "\"41.89\"",
                      "order_id": "\"21056836827909126061559008\"",
                      "parent_id": "\"26056836827909126061559008\"",
                      "amount": "\"41.89\"",
                      "currency": "\"CNY\"",
                      "gateway": "bogus",
                      "kind": "suggested_refund"
                    }
                  ],
                  "currency": "\"CNY\"",
                  "refund_line_items": [
                    {
                      "total_tax": "\"195.67\"",
                      "type": "",
                      "discount_total_amount": "\"199.00\"",
                      "line_item_id": "\"33121216544\"",
                      "price": "\"199.00\"",
                      "quantity": 1,
                      "subtotal": "\"195.67\""
                    }
                  ]
                }
              }
            },
            "example": {
              "refund": {
                "total_duties_set": {
                  "presentment_money": {
                    "currency_code": "USD",
                    "amount": "8.88"
                  },
                  "shop_money": {
                    "amount": "8.88",
                    "currency_code": "USD"
                  }
                },
                "transactons": [
                  {
                    "order_id": "\"21056836827909126061559008\"",
                    "parent_id": "\"26056836827909126061559008\"",
                    "amount": "\"41.89\"",
                    "currency": "\"CNY\"",
                    "gateway": "bogus",
                    "kind": "suggested_refund",
                    "maximum_refundable": "\"41.89\""
                  }
                ],
                "currency": "\"CNY\"",
                "refund_line_items": [
                  {
                    "discount_total_amount": "\"199.00\"",
                    "line_item_id": "\"33121216544\"",
                    "price": "\"199.00\"",
                    "quantity": 1,
                    "subtotal": "\"195.67\"",
                    "total_tax": "\"195.67\"",
                    "type": ""
                  }
                ],
                "shipping": {
                  "amount": "\"5.00\"",
                  "maximum_refundable": "\"10.00\"",
                  "tax": "\"1.00\""
                }
              }
            }
          }
        }
      }
    },
    "401": {
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "错误描述。",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    },
    "429": {
      "headers": {
        "traceId": {
          "description": "请求的全局唯一标识符。用于追踪请求在系统中的流转，以便于问题发生时进行定位和调试。"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "错误描述。",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "method": "post",
  "path": "/orders/:order_id/refunds/calculate.json",
  "servers": [
    {
      "url": "https://{handle}.myshopline.com/admin/openapi",
      "variables": {
        "handle": {
          "default": "openapiceshidianpu",
          "description": "`handle` ：店铺的唯一标识符，值为店铺域名的前缀。例如，域名为 `open001.myshopline.com` 的店铺，其 `handle` 是 `open001` 。"
        }
      }
    }
  ],
  "info": {
    "title": "订单退款试算",
    "version": "v20270301"
  },
  "authIndexes": [
    "write_orders"
  ]
}
```