Skip to content

Latest commit

 

History

History
185 lines (180 loc) · 41.3 KB

File metadata and controls

185 lines (180 loc) · 41.3 KB

Order

Example Usage

import { Order } from "@polar-sh/sdk/models/components/order.js";

let value: Order = {
  id: "<value>",
  createdAt: new Date("2025-11-19T18:15:00.201Z"),
  modifiedAt: new Date("2025-09-24T15:32:02.340Z"),
  status: "pending",
  paid: true,
  subtotalAmount: 10000,
  discountAmount: 1000,
  netAmount: 9000,
  taxAmount: 720,
  totalAmount: 9720,
  appliedBalanceAmount: 0,
  dueAmount: 0,
  refundedAmount: 0,
  refundedTaxAmount: 0,
  currency: "usd",
  billingReason: "subscription_create",
  billingName: "<value>",
  billingAddress: {
    country: "US",
  },
  invoiceNumber: "<value>",
  isInvoiceGenerated: true,
  customerId: "<value>",
  productId: "<value>",
  discountId: "<value>",
  subscriptionId: "<value>",
  checkoutId: null,
  metadata: {
    "key": "<value>",
  },
  platformFeeAmount: 500,
  platformFeeCurrency: "usd",
  customer: {
    id: "992fae2a-2a17-4b7a-8d9e-e287cf90131b",
    createdAt: new Date("2025-03-24T08:16:45.004Z"),
    modifiedAt: new Date("2026-06-03T00:19:30.299Z"),
    metadata: {
      "key": "<value>",
    },
    externalId: "usr_1337",
    email: "customer@example.com",
    emailVerified: true,
    type: "team",
    name: "John Doe",
    billingAddress: {
      country: "US",
    },
    taxId: [
      "911144442",
      "us_ein",
    ],
    organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
    deletedAt: new Date("2026-01-06T00:41:18.481Z"),
    avatarUrl: "https://www.gravatar.com/avatar/xxx?d=404",
  },
  product: {
    metadata: {
      "key": "<value>",
    },
    id: "<value>",
    createdAt: new Date("2025-08-02T16:31:19.549Z"),
    modifiedAt: new Date("2024-04-19T20:07:27.928Z"),
    trialInterval: "day",
    trialIntervalCount: 893240,
    name: "<value>",
    description: "supposing tall alongside but apropos horst bah until",
    visibility: "draft",
    recurringInterval: "day",
    recurringIntervalCount: 883573,
    isRecurring: false,
    isArchived: true,
    organizationId: "<value>",
  },
  discount: {
    duration: "forever",
    durationInMonths: 300165,
    type: "fixed",
    amount: 1000,
    currency: "usd",
    amounts: {
      "eur": 900,
      "usd": 1000,
    },
    createdAt: new Date("2024-05-28T14:09:28.797Z"),
    modifiedAt: null,
    id: "<value>",
    metadata: {},
    name: "<value>",
    code: "<value>",
    startsAt: new Date("2024-01-13T13:43:10.078Z"),
    endsAt: new Date("2025-08-25T16:24:44.378Z"),
    maxRedemptions: 731444,
    redemptionsCount: 88175,
    organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
  },
  subscription: {
    metadata: {},
    createdAt: new Date("2026-05-21T17:10:25.414Z"),
    modifiedAt: new Date("2025-07-05T19:43:41.790Z"),
    id: "<value>",
    amount: 10000,
    currency: "usd",
    recurringInterval: "day",
    recurringIntervalCount: 387537,
    status: "active",
    currentPeriodStart: new Date("2024-06-05T22:13:20.253Z"),
    currentPeriodEnd: new Date("2024-04-27T09:17:45.045Z"),
    trialStart: new Date("2026-04-23T15:48:54.931Z"),
    trialEnd: new Date("2025-01-18T20:17:12.593Z"),
    cancelAtPeriodEnd: true,
    canceledAt: null,
    startedAt: new Date("2024-11-20T14:04:25.809Z"),
    endsAt: new Date("2026-03-13T07:31:02.223Z"),
    endedAt: new Date("2026-09-14T14:43:50.641Z"),
    customerId: "<value>",
    productId: "<value>",
    discountId: "<value>",
    checkoutId: "<value>",
    customerCancellationReason: "too_complex",
    customerCancellationComment: null,
  },
  items: [
    {
      createdAt: new Date("2025-11-25T18:23:36.883Z"),
      modifiedAt: new Date("2025-02-21T10:13:38.797Z"),
      id: "<value>",
      label: "Pro Plan",
      amount: 10000,
      taxAmount: 720,
      proration: false,
      productPriceId: "<value>",
    },
  ],
  description: "Pro Plan",
};

Fields

Field Type Required Description Example
id string ✔️ The ID of the object.
createdAt Date ✔️ Creation timestamp of the object.
modifiedAt Date ✔️ Last modification timestamp of the object.
status components.OrderStatus ✔️ N/A
paid boolean ✔️ Whether the order has been paid for. true
subtotalAmount number ✔️ Amount in cents, before discounts and taxes. 10000
discountAmount number ✔️ Discount amount in cents. 1000
netAmount number ✔️ Amount in cents, after discounts but before taxes. 9000
taxAmount number ✔️ Sales tax amount in cents. 720
totalAmount number ✔️ Amount in cents, after discounts and taxes. 9720
appliedBalanceAmount number ✔️ Customer's balance amount applied to this invoice. Can increase the total amount paid, if the customer has a negative balance, or decrease it, if the customer has a positive balance.Amount in cents. 0
dueAmount number ✔️ Amount in cents that is due for this order. 0
refundedAmount number ✔️ Amount refunded in cents. 0
refundedTaxAmount number ✔️ Sales tax refunded in cents. 0
currency string ✔️ N/A usd
billingReason components.OrderBillingReason ✔️ N/A
billingName string ✔️ The name of the customer that should appear on the invoice.
billingAddress components.Address ✔️ N/A
invoiceNumber string ✔️ The invoice number associated with this order.
isInvoiceGenerated boolean ✔️ Whether an invoice has been generated for this order.
seats number Number of seats purchased (for seat-based one-time orders).
customerId string ✔️ N/A
productId string ✔️ N/A
discountId string ✔️ N/A
subscriptionId string ✔️ N/A
checkoutId string ✔️ N/A
metadata Record<string, components.MetadataOutputType> ✔️ N/A
customFieldData Record<string, components.OrderCustomFieldData> Key-value object storing custom field values.
platformFeeAmount number ✔️ Platform fee amount in cents. 500
platformFeeCurrency string ✔️ Currency of the platform fee. usd
customer components.OrderCustomer ✔️ N/A
product components.OrderProduct ✔️ N/A
discount components.OrderDiscount ✔️ N/A
subscription components.OrderSubscription ✔️ N/A
items components.OrderItemSchema[] ✔️ Line items composing the order.
description string ✔️ A summary description of the order. Pro Plan