Skip to content

Commit dbfea21

Browse files
Merge pull request #191 from woocommerce/update/for-fix-27376
Update refund creation documentation for fix 27376
2 parents 65c2f28 + 20d14c8 commit dbfea21

File tree

1 file changed

+83
-22
lines changed

1 file changed

+83
-22
lines changed

source/includes/wp-api-v3/_order-refunds.md

+83-22
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ The refunds API allows you to create, view, and delete individual refunds.
44

55
## Order refund properties ##
66

7-
| Attribute | Type | Description |
8-
|--------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------|
9-
| `id` | integer | Unique identifier for the resource. <i class="label label-info">read-only</i> |
10-
| `date_created` | date-time | The date the order refund was created, in the site's timezone. <i class="label label-info">read-only</i> |
11-
| `date_created_gmt` | date-time | The date the order refund was created, as GMT. <i class="label label-info">read-only</i> |
12-
| `amount` | string | Refund amount. |
13-
| `reason` | string | Reason for refund. |
14-
| `refunded_by` | integer | User ID of user who created the refund. |
15-
| `refunded_payment` | boolean | If the payment was refunded via the API. See `api_refund`. <i class="label label-info">read-only</i> |
16-
| `meta_data` | array | Meta data. See [Order refund - Meta data properties](#order-refund-meta-data-properties) |
17-
| `line_items` | array | Line items data. See [Order refund - Line items properties](#order-refund-line-items-properties) |
18-
| `api_refund` | boolean | When true, the payment gateway API is used to generate the refund. Default is `true`. <i class="label label-info">write-only</i> |
7+
| Attribute | Type | Description |
8+
|--------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------|
9+
| `id` | integer | Unique identifier for the resource. <i class="label label-info">read-only</i> |
10+
| `date_created` | date-time | The date the order refund was created, in the site's timezone. <i class="label label-info">read-only</i> |
11+
| `date_created_gmt` | date-time | The date the order refund was created, as GMT. <i class="label label-info">read-only</i> |
12+
| `amount` | string | Total 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. |
13+
| `reason` | string | Reason for refund. |
14+
| `refunded_by` | integer | User ID of user who created the refund. |
15+
| `refunded_payment` | boolean | If the payment was refunded via the API. See `api_refund`. <i class="label label-info">read-only</i> |
16+
| `meta_data` | array | Meta data. See [Order refund - Meta data properties](#order-refund-meta-data-properties) |
17+
| `line_items` | array | Line items data. See [Order refund - Line items properties](#order-refund-line-items-properties) |
18+
| `api_refund` | boolean | When true, the payment gateway API is used to generate the refund. Default is `true`. <i class="label label-info">write-only</i> |
1919

2020
### Order refund - Meta data properties ###
2121

@@ -43,14 +43,16 @@ The refunds API allows you to create, view, and delete individual refunds.
4343
| `meta_data` | array | Meta data. See [Order refund - Meta data properties](#order-refund-meta-data-properties) |
4444
| `sku` | string | Product SKU. <i class="label label-info">read-only</i> |
4545
| `price` | string | Product price. <i class="label label-info">read-only</i> |
46+
| `refund_total` | number | The amount to refund for this line item, excluding taxes. <i class="label label-info">write-only</i> |
4647

4748
#### Order refund line item - Taxes properties ####
4849

49-
| Attribute | Type | Description |
50-
|------------|---------|---------------------------------------------------------|
51-
| `id` | integer | Tax rate ID. <i class="label label-info">read-only</i> |
52-
| `total` | string | Tax total. <i class="label label-info">read-only</i> |
53-
| `subtotal` | string | Tax subtotal. <i class="label label-info">read-only</i> |
50+
| Attribute | Type | Description |
51+
|----------------|---------|--------------------------------------------------------------------------------|
52+
| `id` | integer | Tax rate ID. <i class="label label-info">read-only</i> |
53+
| `total` | string | Tax total. <i class="label label-info">read-only</i> |
54+
| `subtotal` | string | Tax subtotal. <i class="label label-info">read-only</i> |
55+
| `refund_total` | number | The amount to refund for this tax. <i class="label label-info">write-only</i> |
5456

5557
## Create a refund ##
5658

@@ -70,13 +72,36 @@ curl -X POST https://example.com/wp-json/wc/v3/orders/723/refunds \
7072
-u consumer_key:consumer_secret \
7173
-H "Content-Type: application/json" \
7274
-d '{
73-
"amount": "10"
75+
"amount": "30",
76+
"line_items": [
77+
{
78+
"id": "111",
79+
"refund_total": 10,
80+
"refund_tax": [
81+
{
82+
"id" "222",
83+
"refund_total": 20
84+
}
85+
]
86+
}
7487
}'
7588
```
7689

7790
```javascript
7891
const data = {
79-
amount: "10"
92+
amount: "30",
93+
line_items: [
94+
{
95+
id: "111",
96+
refund_total: 10,
97+
refund_tax: [
98+
{
99+
id: "222",
100+
refund_total: 20
101+
}
102+
]
103+
}
104+
]
80105
};
81106

82107
WooCommerce.post("orders/723/refunds", data)
@@ -91,7 +116,19 @@ WooCommerce.post("orders/723/refunds", data)
91116
```php
92117
<?php
93118
$data = [
94-
'amount' => '10'
119+
'amount' => '30',
120+
'line_items' => [
121+
[
122+
'id' => '111',
123+
'refund_total' => 10,
124+
'refund_tax' => [
125+
[
126+
'id' => '222',
127+
'amount' => 20
128+
]
129+
]
130+
]
131+
]
95132
];
96133

97134
print_r($woocommerce->post('orders/723/refunds', $data));
@@ -100,15 +137,39 @@ print_r($woocommerce->post('orders/723/refunds', $data));
100137

101138
```python
102139
data = {
103-
"amount": "10"
140+
"amount": "30",
141+
"line_items": [
142+
{
143+
"id": "111",
144+
"refund_total": 10,
145+
"refund_tax": [
146+
{
147+
"id" "222",
148+
"refund_total": 20
149+
}
150+
]
151+
}
152+
]
104153
}
105154

106155
print(wcapi.post("orders/723/refunds", data).json())
107156
```
108157

109158
```ruby
110159
data = {
111-
amount: "10"
160+
amount: "30",
161+
line_items: [
162+
{
163+
id: "111",
164+
refund_total: 10,
165+
refund_tax: [
166+
{
167+
id "222",
168+
refund_total: 20
169+
}
170+
]
171+
}
172+
]
112173
}
113174

114175
woocommerce.post("orders/723/refunds", data).parsed_response

0 commit comments

Comments
 (0)