Skip to content

Commit c65de56

Browse files
committed
Add docs for the new refunds endpoint
Refs #46895
1 parent ba4a081 commit c65de56

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ woocommerce.get("orders/723/refunds/726").parsed_response
333333

334334
This API helps you to view all the refunds from an order.
335335

336+
Note: To view a list of refunds from your store, regardless of order, check out the [refunds endpoint](#refunds).
337+
336338
### HTTP request ###
337339

338340
<div class="api-endpoint">

source/includes/wp-api-v3/_refunds.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Refunds #
2+
3+
The refunds API is a simple, read-only endpoint that allows you to retrieve a list of refunds outside the context of an existing order. To create, view, and delete individual refunds, check out the [order refunds API](#order-refunds).
4+
5+
## Refund properties ##
6+
7+
All properties are the same as those in the [order refunds endpoint](#order-refund-properties), but with one additional property:
8+
9+
| Attribute | Type | Description |
10+
|-------------|---------|----------------------------------------------------|
11+
| `parent_id` | integer | The ID of the order the refund is associated with. |
12+
13+
## Retrieve a list of refunds ##
14+
15+
This API lets you retrieve and view refunds from your store, regardless of which order they are associated with.
16+
17+
### HTTP request ###
18+
19+
<div class="api-endpoint">
20+
<div class="endpoint-data">
21+
<i class="label label-get">GET</i>
22+
<h6>/wp-json/wc/v3/refunds</h6>
23+
</div>
24+
</div>
25+
26+
```shell
27+
curl https://example.com/wp-json/wc/v3/refunds \
28+
-u consumer_key:consumer_secret
29+
```
30+
31+
```javascript
32+
WooCommerce.get("refunds")
33+
.then((response) => {
34+
console.log(response.data);
35+
})
36+
.catch((error) => {
37+
console.log(error.response.data);
38+
});
39+
```
40+
41+
```php
42+
<?php print_r($woocommerce->get('refunds')); ?>
43+
```
44+
45+
```python
46+
print(wcapi.get("refunds").json())
47+
```
48+
49+
```ruby
50+
woocommerce.get("refunds").parsed_response
51+
```
52+
53+
> JSON response example:
54+
55+
```json
56+
[
57+
{
58+
"id": 726,
59+
"parent_id": 124,
60+
"date_created": "2017-03-21T17:07:11",
61+
"date_created_gmt": "2017-03-21T20:07:11",
62+
"amount": "10.00",
63+
"reason": "",
64+
"refunded_by": 1,
65+
"refunded_payment": false,
66+
"meta_data": [],
67+
"line_items": [],
68+
"_links": {
69+
"self": [
70+
{
71+
"href": "https://example.com/wp-json/wc/v3/orders/723/refunds/726"
72+
}
73+
],
74+
"collection": [
75+
{
76+
"href": "https://example.com/wp-json/wc/v3/orders/723/refunds"
77+
}
78+
],
79+
"up": [
80+
{
81+
"href": "https://example.com/wp-json/wc/v3/orders/723"
82+
}
83+
]
84+
}
85+
},
86+
{
87+
"id": 724,
88+
"parent_id": 63,
89+
"date_created": "2017-03-21T16:55:37",
90+
"date_created_gmt": "2017-03-21T19:55:37",
91+
"amount": "9.00",
92+
"reason": "",
93+
"refunded_by": 1,
94+
"refunded_payment": false,
95+
"meta_data": [],
96+
"line_items": [
97+
{
98+
"id": 314,
99+
"name": "Woo Album #2",
100+
"product_id": 87,
101+
"variation_id": 0,
102+
"quantity": -1,
103+
"tax_class": "",
104+
"subtotal": "-9.00",
105+
"subtotal_tax": "0.00",
106+
"total": "-9.00",
107+
"total_tax": "0.00",
108+
"taxes": [],
109+
"meta_data": [
110+
{
111+
"id": 2076,
112+
"key": "_refunded_item_id",
113+
"value": "311"
114+
}
115+
],
116+
"sku": "",
117+
"price": -9
118+
}
119+
],
120+
"_links": {
121+
"self": [
122+
{
123+
"href": "https://example.com/wp-json/wc/v3/orders/723/refunds/724"
124+
}
125+
],
126+
"collection": [
127+
{
128+
"href": "https://example.com/wp-json/wc/v3/orders/723/refunds"
129+
}
130+
],
131+
"up": [
132+
{
133+
"href": "https://example.com/wp-json/wc/v3/orders/723"
134+
}
135+
]
136+
}
137+
}
138+
]
139+
```
140+
141+
#### Available parameters ####
142+
143+
| Parameter | Type | Description |
144+
|------------------|---------|------------------------------------------------------------------------------------------------------------------------------|
145+
| `context` | string | Scope under which the request is made; determines fields present in response. Options: `view` and `edit`. Default is `view`. |
146+
| `page` | integer | Current page of the collection. Default is `1`. |
147+
| `per_page` | integer | Maximum number of items to be returned in result set. Default is `10`. |
148+
| `search` | string | Limit results to those matching a string. |
149+
| `after` | string | Limit response to resources published after a given ISO8601 compliant date. |
150+
| `before` | string | Limit response to resources published before a given ISO8601 compliant date. |
151+
| `exclude` | array | Ensure result set excludes specific IDs. |
152+
| `include` | array | Limit result set to specific ids. |
153+
| `offset` | integer | Offset the result set by a specific number of items. |
154+
| `order` | string | Order sort attribute ascending or descending. Options: `asc` and `desc`. Default is `desc`. |
155+
| `orderby` | string | Sort collection by object attribute. Options: `date`, `id`, `include`, `title` and `slug`. Default is `date`. |
156+
| `parent` | array | Limit result set to those of particular parent IDs. |
157+
| `parent_exclude` | array | Limit result set to all items except those of a particular parent ID. |
158+
| `dp` | integer | Number of decimal points to use in each resource. Default is `2`. |

source/index.html.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ includes:
3535
- wp-api-v3/product-tags
3636
- wp-api-v3/product-reviews
3737
- wp-api-v3/reports
38+
- wp-api-v3/refunds
3839
- wp-api-v3/taxes
3940
- wp-api-v3/tax-classes
4041
- wp-api-v3/webhooks

0 commit comments

Comments
 (0)