跳到主要内容
将当前页面内容以 Markdown 格式复制到剪贴板

订单退款

订单退款 API 允许您基于现有的订单,创建、查看和删除单个退款。

订单退款属性

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
date_createddate-timeThe date the order refund was created, in the site's timezone. READ-ONLY
date_created_gmtdate-timeThe date the order refund was created, as GMT. READ-ONLY
amountstringTotal refund amount. Optional. If this parameter is provided, it will take precedence over line item totals, even when total of line items does not matches with this amount.
reasonstringReason for refund.
refunded_byintegerUser ID of user who created the refund.
refunded_paymentbooleanIf the payment was refunded via the API. See api_refund. READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties
line_itemsarrayLine items data. See Order refund - Line items properties
tax_linesarrayTax lines data. See Order refund - Tax lines properties READ-ONLY
shipping_linesarrayShipping lines data. See Order refund - Shipping lines properties
fee_linesarrayFee lines data. See Order refund - Fee lines properties
api_refundbooleanWhen true, the payment gateway API is used to generate the refund. Default is true. WRITE-ONLY
api_restockbooleanWhen true, the selected line items are restocked Default is true. WRITE-ONLY

Order refund - Meta data properties

AttributeTypeDescription
idintegerMeta ID. READ-ONLY
keystringMeta key.
valuestringMeta value.

Order refund - Line items properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
namestringProduct name.
product_idintegerProduct ID.
variation_idintegerVariation ID, if applicable.
quantityintegerQuantity ordered.
tax_classstringTax class of product.
subtotalstringLine subtotal (before discounts).
subtotal_taxstringLine subtotal tax (before discounts). READ-ONLY
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order refund line item - Taxes properties READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties
skustringProduct SKU. READ-ONLY
pricestringProduct price. READ-ONLY

Order refund line item - Taxes properties

AttributeTypeDescription
idintegerTax rate ID. READ-ONLY
totalstringTax total. READ-ONLY
subtotalstringTax subtotal. READ-ONLY

Order refund - Tax lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
rate_codestringTax rate code. READ-ONLY
rate_idintegerTax rate ID. READ-ONLY
labelstringTax rate label. READ-ONLY
compoundbooleanWhether or not this is a compound tax rate. READ-ONLY
tax_totalstringTax total (not including shipping taxes). READ-ONLY
shipping_tax_totalstringShipping tax total. READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties

Order refund - Shipping lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
method_titlestringShipping method name.
method_idstringShipping method ID.
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order refund - Tax lines properties READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties

Order refund - Fee lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
namestringFee name.
tax_classstringTax class of fee.
tax_statusstringTax status of fee. Options: taxable and none.
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order refund - Tax lines properties READ-ONLY
meta_dataarrayMeta data. See Order refund - Meta data properties

创建退款

此 API 帮助您为订单创建新的退款。

POST /wp-json/wc/v3/orders/<id>/refunds
curl -X POST https://example.com/wp-json/wc/v3/orders/723/refunds \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"amount": "30",
"line_items": [
{
"id": "111",
"refund_total": 10,
"refund_tax": [
{
"id": "222",
"refund_total": 20
}
]
}
}'

行项目参数

参数类型描述
idinteger订单中行项目的 ID。
refund_totalnumber此行项目中,不包括税费的退款金额。
refund_taxarray税率的退款信息。请参阅 退款税费参数

退款税费参数

参数类型描述
idinteger税率的 ID。
refund_totalnumber此行项目的退款税费金额。

获取退款

此 API 允许您检索和查看来自某个订单的具体退款信息。

GET /wp-json/wc/v3/orders/<id>/refunds/<refund_id>
curl https://example.com/wp-json/wc/v3/orders/723/refunds/726 \
-u consumer_key:consumer_secret

可用参数

参数类型描述
dp字符串每个资源中使用的十进制位数。

列出所有退款

此 API 可以帮助您查看某个订单的所有退款。

注意:要查看商店中的所有退款列表,无论与哪个订单相关,请查看 退款 endpoint

GET /wp-json/wc/v3/orders/<id>/refunds
curl https://example.com/wp-json/wc/v3/orders/723/refunds \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to those matching a string.
afterstringLimit response to resources published after a given ISO8601 compliant date.
beforestringLimit response to resources published before a given ISO8601 compliant date.
dates_are_gmtbooleanInterpret after and before as UTC dates when true.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderbystringSort collection by object attribute. Options: date, modified, id, include, title and slug. Default is date.
parentarrayLimit result set to those of particular parent IDs.
parent_excludearrayLimit result set to all items except those of a particular parent ID.
dpintegerNumber of decimal points to use in each resource. Default is 2.

Delete a refund

This API helps you delete an order refund.

DELETE /wp-json/wc/v3/orders/<id>/refunds/<refund_id>
curl -X DELETE https://example.com/wp-json/wc/v3/orders/723/refunds/726?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringRequired to be true, as resource does not support trashing.