|
| 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`. | |
0 commit comments