Vatly
JavaScript SDK

Orders

Orders record checkout purchases and subscription renewals, including pending payments.

Orders record checkout purchases and subscription renewals, including pending payments. They carry invoice links and tax breakdowns, and let you create refunds and inspect chargebacks.

For all fields and options, see the Orders API reference. The OpenAPI spec is also available for tooling.

The Order resource

NameTypeDescription
idstringUnique identifier (order_…).
customerIdstring | nullThe customer this order belongs to.
statusstringcreated, pending, paid, canceled, or expired. Payment recovery is signaled by order.payment_failed, not a status of that name.
totalMoneyGross amount (incl. tax).
subtotalMoneyNet amount (excl. tax).
reversedSubtotalMoneyNet amount already reversed via refunds/chargebacks.
refundableSubtotalMoneyNet amount still refundable.
taxSummaryarrayPer-rate VAT breakdown.
linesOrderLine[]Line items, incl. productType / productId and relatedResources.
invoiceNumberstring | nullAssigned once the invoice is issued.
paymentMethodstring | nullPayment method used.
metadataobject | nullCustom metadata carried from the checkout.
testmodebooleanWhether this is a test order.

Subscription on an order line

lines[].relatedResources.subscriptionId names the subscription a signup, renewal or immediate-update line belongs to. productType / productId keep their meaning: a signup line references the plan (subscription_plan), a renewal or update line the subscription (subscription).

  • relatedResources is null on historical lines and on unrelated lines (one-off products, billing verification, authorization minimums). Older payloads may omit it.
  • subscriptionId is null on a signup line while its subscription is not yet available. A later orders.get returns the ID once it is.
  • An ID is not proof of activation or entitlement. Retrieve the subscription and check its status before granting access.
// For a paid checkout, use checkout.orderId.
const order = await vatly.orders.get("order_abc123");
for (const line of order.lines) {
  const subscriptionId = line.relatedResources?.subscriptionId; // string | null | undefined
  if (subscriptionId) {
    const subscription = await vatly.subscriptions.get(subscriptionId);
  }
}

Retrieve an order

GET /v1/orders/{orderId}

const order = await vatly.orders.get("order_abc123");
console.log(order.total.value, order.total.currency);

List orders

GET /v1/orders

const page = await vatly.orders.list({ limit: 25 });

for await (const order of vatly.orders.listAll()) {
  // ...
}

POST /v1/orders/{orderId}/invoice-update-link

Returns a hosted link where the customer can correct their invoice details (billing address, VAT number, company name).

const link = await vatly.orders.createInvoiceUpdateLink("order_abc123");
redirect(link.href);

Refunds on an order

Refunds are created against the order they belong to.

// Partial refund of specific items:
const refund = await vatly.orders.createRefund("order_abc123", {
  items: [
    { itemId: "order_item_abc123", amount: { value: "15.00", currency: "EUR" } },
  ],
});

// Full refund of the entire order:
const full = await vatly.orders.createFullRefund("order_abc123");

// List / get / cancel:
const page = await vatly.orders.listRefunds("order_abc123", { limit: 10 });
for await (const r of vatly.orders.listAllRefunds("order_abc123")) {
  // ...
}
const one = await vatly.orders.getRefund("order_abc123", "refund_abc123");
await vatly.orders.cancelRefund("order_abc123", "refund_abc123"); // only while pending

See Refunds for the top-level refund endpoints.

Chargebacks on an order

const page = await vatly.orders.listChargebacks("order_abc123");
const chargeback = await vatly.orders.getChargeback("order_abc123", "chargeback_abc123");

See Chargebacks for the top-level chargeback endpoints.

Copyright © 2026