Order Refunds
The refund model
The refund model contains all the information about order refunds, including the refund lines, amounts, and tax information.
Properties
| Name | Type | Description |
|---|---|---|
id | string | Unique identifier for the refund (starts with ref_). |
resource | string | The resource type. Always refund. |
orderId | string | null | ID of the credit note order created for this refund. Only present after the refund is processed. |
merchantId | string | ID of the merchant. |
customerId | string | ID of the customer receiving the refund. |
testmode | boolean | Whether this refund is in test mode. |
status | string | The current status of the refund. Can be pending, completed, failed, or canceled. |
originalOrderId | string | ID of the original order being refunded. |
total | Money | Total refund amount including taxes. A Money object with value (decimal string) and currency (ISO 4217 code). |
subtotal | Money | Refund subtotal before taxes. |
taxSummary | Money | Total tax amount being refunded. |
lines | array | Array of refund line items. See RefundLine properties below. |
createdAt | string | When this refund was created (ISO 8601 format). |
links | object | HATEOAS links to related resources. Contains self, originalOrder, and optionally order (the credit note). |
RefundLine Properties
| Name | Type | Description |
|---|---|---|
id | string | Unique identifier for this refund line (starts with rli_). |
resource | string | The resource type. Always refundline. |
description | string | Description of the refunded item. |
quantity | integer | Number of units being refunded. |
basePrice | Money | Refund amount per unit before taxes. |
total | Money | Total refund amount including taxes. |
subtotal | Money | Refund subtotal before taxes. |
taxes | Money | Tax amount being refunded. |
Create a refund
POST /v1/orders/:orderId/refunds
This endpoint allows you to create a partial refund for a specific order. You specify which order line items to refund and the amount for each.
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
Request body
| Name | Type | Description |
|---|---|---|
items | array | (Required) Array of items to refund. Each item has: itemId (string, required) - ID of the order line item, amount (Money, required) - amount to refund before taxes, description (string, optional) - custom description, descriptionAdditionalLine (string, optional) - additional description line. |
metadata | object | Arbitrary key-value metadata for your application. |
curl -X POST https://api.vatly.com/v1/orders/ord_abc123/refunds \
-H "Authorization: Bearer live_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"itemId": "oli_abc123",
"amount": {
"value": "15.00",
"currency": "EUR"
},
"description": "Partial refund for service issue"
}
]
}'
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$refund = $vatly->orders->refunds('ord_abc123')->create([
'items' => [
[
'itemId' => 'oli_abc123',
'amount' => [
'value' => '15.00',
'currency' => 'EUR',
],
'description' => 'Partial refund for service issue',
],
],
]);
{
"id": "ref_abc123def456",
"resource": "refund",
"orderId": null,
"merchantId": "mer_abc123",
"customerId": "cus_xyz789",
"testmode": false,
"status": "pending",
"originalOrderId": "ord_abc123",
"total": {
"value": "18.15",
"currency": "EUR"
},
"subtotal": {
"value": "15.00",
"currency": "EUR"
},
"taxSummary": {
"value": "3.15",
"currency": "EUR"
},
"lines": [
{
"id": "rli_abc123",
"resource": "refundline",
"description": "Partial refund for service issue",
"quantity": 1,
"basePrice": {
"value": "15.00",
"currency": "EUR"
},
"total": {
"value": "18.15",
"currency": "EUR"
},
"subtotal": {
"value": "15.00",
"currency": "EUR"
},
"taxes": {
"value": "3.15",
"currency": "EUR"
}
}
],
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/refunds/ref_abc123def456",
"type": "application/json"
},
"originalOrder": {
"href": "https://api.vatly.com/v1/orders/ord_abc123",
"type": "application/json"
},
"order": null
}
}
Create a full refund
POST /v1/orders/:orderId/refunds/full
This endpoint allows you to create a full refund for a specific order. This will refund the entire remaining amount of the order.
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
Request body (optional)
| Name | Type | Description |
|---|---|---|
metadata | object | Arbitrary key-value metadata for your application. |
curl -X POST https://api.vatly.com/v1/orders/ord_abc123/refunds/full \
-H "Authorization: Bearer live_your_api_key_here"
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$refund = $vatly->orders->refunds('ord_abc123')->full();
{
"id": "ref_xyz789abc123",
"resource": "refund",
"orderId": null,
"merchantId": "mer_abc123",
"customerId": "cus_xyz789",
"testmode": false,
"status": "pending",
"originalOrderId": "ord_abc123",
"total": {
"value": "120.99",
"currency": "EUR"
},
"subtotal": {
"value": "100.00",
"currency": "EUR"
},
"taxSummary": {
"value": "20.99",
"currency": "EUR"
},
"lines": [
{
"id": "rli_full123",
"resource": "refundline",
"description": "Pro Monthly Subscription (Full Refund)",
"quantity": 1,
"basePrice": {
"value": "100.00",
"currency": "EUR"
},
"total": {
"value": "120.99",
"currency": "EUR"
},
"subtotal": {
"value": "100.00",
"currency": "EUR"
},
"taxes": {
"value": "20.99",
"currency": "EUR"
}
}
],
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/refunds/ref_xyz789abc123",
"type": "application/json"
},
"originalOrder": {
"href": "https://api.vatly.com/v1/orders/ord_abc123",
"type": "application/json"
},
"order": null
}
}
List order refunds
GET /v1/orders/:orderId/refunds
This endpoint allows you to retrieve a list of all refunds for a specific order.
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
limit | integer | The number of refunds to return (default: 10, max: 100). |
startingAfter | string | A cursor for use in pagination. Returns results after this refund ID. |
endingBefore | string | A cursor for use in pagination. Returns results before this refund ID. |
curl https://api.vatly.com/v1/orders/ord_abc123/refunds \
-H "Authorization: Bearer live_your_api_key_here"
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$refunds = $vatly->orders->refunds('ord_abc123')->page();
{
"data": [
{
"id": "ref_abc123def456",
"resource": "refund",
"orderId": "ord_credit123",
"merchantId": "mer_abc123",
"customerId": "cus_xyz789",
"testmode": false,
"status": "completed",
"originalOrderId": "ord_abc123",
"total": {
"value": "18.15",
"currency": "EUR"
},
"subtotal": {
"value": "15.00",
"currency": "EUR"
},
"taxSummary": {
"value": "3.15",
"currency": "EUR"
},
"lines": [
{
"id": "rli_abc123",
"resource": "refundline",
"description": "Partial refund for service issue",
"quantity": 1,
"basePrice": {
"value": "15.00",
"currency": "EUR"
},
"total": {
"value": "18.15",
"currency": "EUR"
},
"subtotal": {
"value": "15.00",
"currency": "EUR"
},
"taxes": {
"value": "3.15",
"currency": "EUR"
}
}
],
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/refunds/ref_abc123def456",
"type": "application/json"
},
"originalOrder": {
"href": "https://api.vatly.com/v1/orders/ord_abc123",
"type": "application/json"
},
"order": {
"href": "https://api.vatly.com/v1/orders/ord_credit123",
"type": "application/json"
}
}
}
],
"links": {
"self": {
"href": "https://api.vatly.com/v1/orders/ord_abc123/refunds?limit=10",
"type": "application/json"
},
"next": null,
"prev": null
},
"count": 1
}
Get an order refund
GET /v1/orders/:orderId/refunds/:refundId
This endpoint allows you to retrieve details of a specific refund for a specific order.
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
refundId | string | The unique identifier of the refund. |
curl https://api.vatly.com/v1/orders/ord_abc123/refunds/ref_abc123def456 \
-H "Authorization: Bearer live_your_api_key_here"
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$refund = $vatly->orders->refunds('ord_abc123')->get('ref_abc123def456');
{
"id": "ref_abc123def456",
"resource": "refund",
"orderId": "ord_credit123",
"merchantId": "mer_abc123",
"customerId": "cus_xyz789",
"testmode": false,
"status": "completed",
"originalOrderId": "ord_abc123",
"total": {
"value": "18.15",
"currency": "EUR"
},
"subtotal": {
"value": "15.00",
"currency": "EUR"
},
"taxSummary": {
"value": "3.15",
"currency": "EUR"
},
"lines": [
{
"id": "rli_abc123",
"resource": "refundline",
"description": "Partial refund for service issue",
"quantity": 1,
"basePrice": {
"value": "15.00",
"currency": "EUR"
},
"total": {
"value": "18.15",
"currency": "EUR"
},
"subtotal": {
"value": "15.00",
"currency": "EUR"
},
"taxes": {
"value": "3.15",
"currency": "EUR"
}
}
],
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/refunds/ref_abc123def456",
"type": "application/json"
},
"originalOrder": {
"href": "https://api.vatly.com/v1/orders/ord_abc123",
"type": "application/json"
},
"order": {
"href": "https://api.vatly.com/v1/orders/ord_credit123",
"type": "application/json"
}
}
}
Cancel an order refund
DELETE /v1/orders/:orderId/refunds/:refundId
This endpoint allows you to cancel a pending refund for a specific order. Only pending refunds can be cancelled.
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
refundId | string | The unique identifier of the refund to cancel. |
curl -X DELETE https://api.vatly.com/v1/orders/ord_abc123/refunds/ref_abc123def456 \
-H "Authorization: Bearer live_your_api_key_here"
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$vatly->orders->refunds('ord_abc123')->cancel('ref_abc123def456');
Returns 204 No Content on success.