Orders
The order model
The order model contains all the information about your orders, including the order details, customer information, line items, and tax information.
Properties
| Name | Type | Description |
|---|---|---|
id | string | Unique identifier for the order (starts with order_). |
resource | string | The resource type. Always order. |
customerId | string | null | ID of the customer who made this purchase. Always present, but null for orders with no associated customer. |
testmode | boolean | Whether this order is in test mode. |
metadata | object | null | Arbitrary key-value metadata for your application. |
paymentMethod | string | null | Payment method used for this order (e.g., ideal, creditcard, bancontact, paypal). |
status | string | The current status of the order. Can be created, pending, paid, canceled, or expired. |
cancellationReason | string | null | Why the order was canceled. null unless status is canceled, and null for orders canceled before this field existed. Currently payment_failure (payment recovery for this unpaid order was exhausted). |
invoiceNumber | string | null | Invoice number for this order (assigned after payment). |
total | Money | Total amount including taxes. A Money object with value (decimal string) and currency (ISO 4217 code). |
subtotal | Money | Subtotal amount before taxes. |
reversedSubtotal | Money | Amount of the captured payment already returned to the customer, before taxes, via refund or chargeback (settled). |
refundableSubtotal | Money | Remaining amount that can still be refunded, before taxes. Always zero for an order that is not a sale (any order type other than checkout_order and mandated_order, such as a payment-method authorization or a verification charge), because such orders cannot be refunded. |
taxSummary | array | Tax breakdown by rate. Each item contains a taxRate object (name, percentage, taxablePercentage) and an amount Money object. |
lines | array | Array of line items in this order. See OrderLine properties below. |
discounts | array | Every discount on the order, each listed once with the amount it takes off all lines added up, in the order it first appears on the lines. Empty when the order has no discount. Match an entry to its share on each line by id. See Discount properties below. |
customerDetails | BillingDetails | Customer billing details (buyer). Includes fullName, companyName, taxId, streetAndNumber, streetAdditional, city, region, postalCode, country, and email. |
createdAt | string | When this order was created (ISO 8601 format). |
links | object | HATEOAS links to related resources. Contains self, customer (null for orders without a customer) and customerInvoice, the invoice in the customer portal (text/html). On a refund or chargeback order, customerInvoice opens the credit note. The link is signed and expires after 72 hours; the customer can request a new one from the page. |
OrderLine Properties
| Name | Type | Description |
|---|---|---|
id | string | Unique identifier for this line item (starts with order_item_). |
resource | string | The resource type. Always orderline. |
description | string | Description of the item. |
quantity | integer | Number of units. |
basePrice | Money | Price per unit before discounts, on the product's tax basis: excluding taxes for tax-exclusive products, including them for tax-inclusive products. |
total | Money | Total price including taxes, after discounts (subtotal + taxes). |
subtotal | Money | Subtotal excluding taxes, after discounts. |
taxes | array | Tax breakdown by rate for this line. Each item contains a taxRate object and an amount Money object. |
discounts | array | This line's share of each discount, in the order they apply. Empty when the line has no discount. subtotal, taxes and total are already net of these discounts. See Discount properties below. |
productType | string | null | The product type this line links to. One of one_off_product, subscription_plan, subscription, billing_details_verification, auth_request_product, or null when the line has no product link. |
productId | string | null | The linked product's id (e.g. subscription_... for a subscription line). null when the line has no product link. |
Discount Properties
A discount applied to an order, as listed under the order's and each line's discounts. Discounts are set when creating a checkout. Amounts exclude VAT; the line's taxes already reflect the discount.
| Name | Type | Description |
|---|---|---|
id | string | null | Identifies this discount on this order. Every line's share of a discount and the order's entry for it carry the same id. It names one application, not a reusable coupon: every order, and every subscription renewal, gets new ids. null only on discounts applied before ids were introduced. |
description | string | null | The label sent with the discount, if any. |
discountType | string | null | How the discount is defined: percentage or fixed_amount. More values may be added; treat an unknown value as a discount of an unknown kind. null only on discounts applied before it was recorded. |
percentage | string | null | The percentage taken off, as a decimal string (e.g. "20.00"), for a percentage discount. null for a fixed_amount discount. |
amount | Money | The amount taken off, excluding VAT, also when the products' prices include VAT: €10.00 off a €121.00 price at 21% reads 8.26. |
List all orders
GET /v1/orders
This endpoint allows you to retrieve a paginated list of all your orders. By default, a maximum of ten orders are shown per page.
Optional parameters
| Name | Type | Description |
|---|---|---|
limit | integer | The number of orders to return (default: 10, max: 100). |
startingAfter | string | A cursor for use in pagination. Returns results after this order ID. |
endingBefore | string | A cursor for use in pagination. Returns results before this order ID. |
curl -G https://api.vatly.com/v1/orders \
-H "Authorization: Bearer live_your_api_key_here" \
-d limit=10
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$orders = $vatly->orders->page();
{
"data": [
{
"id": "order_Hn5xWqVfKm8RjTgYbUcP",
"resource": "order",
"customerId": "customer_Xk9pQrSvWm4NjLhYbUcP",
"testmode": false,
"metadata": {},
"paymentMethod": "ideal",
"status": "paid",
"cancellationReason": null,
"invoiceNumber": "INV-2024-0001",
"total": {
"value": "35.09",
"currency": "EUR"
},
"subtotal": {
"value": "29.00",
"currency": "EUR"
},
"reversedSubtotal": {
"value": "0.00",
"currency": "EUR"
},
"refundableSubtotal": {
"value": "29.00",
"currency": "EUR"
},
"taxSummary": [
{
"taxRate": {
"name": "VAT",
"percentage": 21,
"taxablePercentage": 100
},
"amount": {
"value": "6.09",
"currency": "EUR"
}
}
],
"lines": [
{
"id": "order_item_Mn6xBtPvKw2RjTgYcZaE",
"resource": "orderline",
"description": "Pro Monthly Subscription",
"quantity": 1,
"basePrice": {
"value": "29.00",
"currency": "EUR"
},
"total": {
"value": "35.09",
"currency": "EUR"
},
"subtotal": {
"value": "29.00",
"currency": "EUR"
},
"taxes": [
{
"taxRate": {
"name": "VAT",
"percentage": 21,
"taxablePercentage": 100
},
"amount": {
"value": "6.09",
"currency": "EUR"
}
}
],
"discounts": [],
"productType": "subscription",
"productId": "subscription_Qp7mNvBxKw3RjTgYcZaE"
}
],
"discounts": [],
"customerDetails": {
"fullName": "John Doe",
"companyName": "Acme Corp",
"taxId": null,
"streetAndNumber": "123 Main Street",
"streetAdditional": null,
"city": "Berlin",
"region": null,
"postalCode": "10115",
"country": "DE",
"email": "john@acme.com"
},
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/orders/order_Hn5xWqVfKm8RjTgYbUcP",
"type": "application/json"
},
"customer": {
"href": "https://api.vatly.com/v1/customers/customer_Xk9pQrSvWm4NjLhYbUcP",
"type": "application/json"
}
}
}
],
"count": 1,
"links": {
"self": {
"href": "https://api.vatly.com/v1/orders",
"type": "application/json"
},
"next": null,
"prev": null
}
}
Get an order
GET /v1/orders/:orderId
This endpoint allows you to retrieve a specific order by its ID.
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
curl https://api.vatly.com/v1/orders/order_Hn5xWqVfKm8RjTgYbUcP \
-H "Authorization: Bearer live_your_api_key_here"
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$order = $vatly->orders->get('order_Hn5xWqVfKm8RjTgYbUcP');
{
"id": "order_Hn5xWqVfKm8RjTgYbUcP",
"resource": "order",
"customerId": "customer_Xk9pQrSvWm4NjLhYbUcP",
"testmode": false,
"metadata": {},
"paymentMethod": "ideal",
"status": "paid",
"cancellationReason": null,
"invoiceNumber": "INV-2024-0001",
"total": {
"value": "35.09",
"currency": "EUR"
},
"subtotal": {
"value": "29.00",
"currency": "EUR"
},
"reversedSubtotal": {
"value": "0.00",
"currency": "EUR"
},
"refundableSubtotal": {
"value": "29.00",
"currency": "EUR"
},
"taxSummary": [
{
"taxRate": {
"name": "VAT",
"percentage": 21,
"taxablePercentage": 100
},
"amount": {
"value": "6.09",
"currency": "EUR"
}
}
],
"lines": [
{
"id": "order_item_Jk4pQrSvWm8NjLhYbUcP",
"resource": "orderline",
"description": "Pro Monthly Subscription",
"quantity": 1,
"basePrice": {
"value": "29.00",
"currency": "EUR"
},
"total": {
"value": "35.09",
"currency": "EUR"
},
"subtotal": {
"value": "29.00",
"currency": "EUR"
},
"taxes": [
{
"taxRate": {
"name": "VAT",
"percentage": 21,
"taxablePercentage": 100
},
"amount": {
"value": "6.09",
"currency": "EUR"
}
}
],
"discounts": [],
"productType": "subscription",
"productId": "subscription_Jk4pQrSvWm8NjLhYbUcP"
}
],
"discounts": [],
"customerDetails": {
"fullName": "John Doe",
"companyName": "Acme Corp",
"taxId": null,
"streetAndNumber": "123 Main Street",
"streetAdditional": null,
"city": "Berlin",
"region": null,
"postalCode": "10115",
"country": "DE",
"email": "john@acme.com"
},
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/orders/order_Hn5xWqVfKm8RjTgYbUcP",
"type": "application/json"
},
"customer": {
"href": "https://api.vatly.com/v1/customers/customer_Xk9pQrSvWm4NjLhYbUcP",
"type": "application/json"
},
"customerInvoice": {
"href": "https://vatly.com/invoices/order_Hn5xWqVfKm8RjTgYbUcP",
"type": "text/html"
}
}
}
Create invoice update link
POST /v1/orders/:orderId/invoice-update-link
Creates a signed link that customers can use to update the invoice details for this order: billing address, VAT number, and company name. The link is valid for a limited time (typically 24 hours).
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | The unique identifier of the order. |
curl -X POST https://api.vatly.com/v1/orders/order_Hn5xWqVfKm8RjTgYbUcP/invoice-update-link \
-H "Authorization: Bearer live_your_api_key_here"
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');
$link = $vatly->orders->createInvoiceUpdateLink('order_Hn5xWqVfKm8RjTgYbUcP');
{
"href": "https://vatly.com/invoices/order_Hn5xWqVfKm8RjTgYbUcP/edit?signature=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"type": "text/html"
}