Vatly
PHP

Orders

Vatly PHP SDK - Orders

Orders are created automatically when a checkout completes successfully or when a subscription renews.

The Order Resource

Below you'll find all properties for the Vatly Order resource.

Properties

NameTypeDescription
idstringUnique identifier for the order (order_...).
resourcestringAlways order.
customerIdstring | nullThe customer ID, or null for orders with no associated customer.
statusstringThe order status (see Order statuses).
cancellationReasonstring | nullWhy the order was canceled: payment_failure when payment recovery for this unpaid order was exhausted. null unless the status is canceled, and null for orders canceled before this field existed.
totalMoneyTotal amount including taxes.
subtotalMoneySubtotal amount before taxes.
reversedSubtotalMoneyAmount of the captured payment returned to the customer, before taxes, via refund or chargeback (settled).
refundableSubtotalMoneyRemaining amount that can still be refunded, before taxes.
taxSummaryTaxSummaryCollectionTax breakdown by rate.
linesarrayThe order lines. Use $order->lines() for a collection of OrderLine objects.
customerDetailsAddressCustomer billing details.
paymentMethodstring | nullThe payment method used, for example ideal or creditcard.
invoiceNumberstring | nullThe invoice number, assigned after payment.
testmodeboolWhether this is a test order.
metadataarrayYour custom metadata.
createdAtstringCreation timestamp (ISO 8601).
linksOrderLinksLinks to this order, the customer (null for orders with no associated customer) and the customer invoice. The customerInvoice URL is signed and expires after 72 hours (the customer then sees a page to request a new link).

Retrieve an order

GET /v1/orders/:id

Retrieve an order by its ID.

$order = $vatly->orders->get('order_abc123');

echo $order->status;
echo $order->total->value . ' ' . $order->total->currency;

if ($order->isPaid()) {
    echo 'Invoice: ' . $order->invoiceNumber;
}

if ($order->isCanceled()) {
    echo 'Canceled because: ' . ($order->cancellationReason ?? 'unknown');
}

List all orders

GET /v1/orders

Retrieve a paginated list of all orders.

Optional attributes

NameTypeDescription
startingAfterstringA cursor for pagination: return the page after this order ID.
endingBeforestringA cursor for pagination: return the page before this order ID.
limitintegerThe number of orders to return (default: 10, max: 100).
$orders = $vatly->orders->page();

foreach ($orders as $order) {
    echo $order->id . ': ' . $order->total->value . ' ' . $order->total->currency;
}

// Pass the cursors and limit in order: startingAfter, endingBefore, limit
$orders = $vatly->orders->page('order_abc123', null, 25);

Order statuses

StatusDescription
createdOrder has just been created
pendingPayment is being processed
paidPayment successful
canceledOrder has been canceled
expiredOrder has expired

A failed payment does not change the order to a status of its own. You receive the order.payment_failed webhook while Vatly tries to recover the payment. If recovery is exhausted, the order is canceled with cancellationReason: payment_failure, and you receive order.canceled.


Helper methods

The Order object provides convenient helper methods.

$order->isCreated();   // true if status is 'created'
$order->isPending();   // true if status is 'pending'
$order->isPaid();      // true if status is 'paid'
$order->isCanceled();  // true if status is 'canceled'
$order->isExpired();   // true if status is 'expired'

$order->isReversed();          // true if any of the payment was returned to the customer
$order->isPartiallyReversed(); // true if some, but not all, of the payment was returned
$order->isFullyReversed();     // true if the full payment was returned
Copyright © 2026