@bates-solutions/squareup API Reference - v3.2.0
    Preparing search index...

    Class OrderBuilder

    Fluent builder for creating Square orders

    const order = await square.orders
    .builder()
    .addItem({ name: 'Latte', amount: 450 })
    .addItem({ catalogObjectId: 'ITEM_123', quantity: 2 })
    .withTip(100)
    .withCustomer('CUST_123')
    .build();
    Index
    • Parameters

      • client: SquareClient
      • locationId: string
      • defaultCurrency: "USD" | "CAD" | "GBP" | "EUR" | "AUD" | "JPY" = 'USD'

      Returns OrderBuilder

    • Add an order discount. Reference an existing CatalogDiscount by catalogObjectId (price tracks the catalog), or define one inline. For a LINE_ITEM-scoped discount, give it a uid and reference that from each line's appliedDiscounts.

      Parameters

      Returns this

      builder
      .addItem({ catalogObjectId: 'ITEM_1', quantity: 1, appliedDiscounts: [{ discountUid: 'wholesale' }] })
      .addDiscount({ uid: 'wholesale', catalogObjectId: 'DISCOUNT_1', scope: 'LINE_ITEM' });
    • Add an order tax. Define an ad hoc tax inline with name + percentage, or reference an existing CatalogTax by catalogObjectId. For a LINE_ITEM-scoped tax, give it a uid and reference that from each line's appliedTaxes. To charge only the taxes you add, also set withPricingOptions({ autoApplyTaxes: false }).

      Parameters

      Returns this

      When the tax has neither catalogObjectId nor a numeric percentage

      builder
      .addItem({ name: 'Design fee', amount: 2500 })
      .addTax({ uid: 'gst', name: 'GST', percentage: '5', scope: 'ORDER' })
      .withPricingOptions({ autoApplyTaxes: false });
    • Shorthand for a DRAFT order with autoApplyDiscounts: true.

      ⚠️ Not valid for a subscription order template — Square rejects auto_apply_discounts there (The order template amount must not have auto_apply_discounts set to true). For a subscription template, use withState('DRAFT') and make the amount explicit via addDiscount(...) (catalog-authoritative) or per-line basePriceMoney. This helper remains for non-subscription DRAFT orders that do want auto-applied pricing rules.

      Returns this

    • Preview the order without creating it Returns the order configuration that would be sent

      Returns {
          currency: "USD" | "CAD" | "GBP" | "EUR" | "AUD" | "JPY";
          customerId?: string;
          discounts: OrderDiscount[];
          idempotencyKey?: string;
          lineItems: OrderLineItem[];
          locationId: string;
          pricingOptions?: OrderPricingOptions;
          referenceId?: string;
          state?: OrderState;
          taxes: OrderTaxRequest[];
          tipAmount?: bigint;
      }

    • Set the currency for the order

      Parameters

      • currency: "USD" | "CAD" | "GBP" | "EUR" | "AUD" | "JPY"

        Currency code

      Returns this

      Builder instance for chaining

    • Provide an explicit idempotency key. Useful for retrying subscription template creation without producing duplicate orders.

      Parameters

      • key: string

      Returns this

    • Add a reference ID for external tracking

      Parameters

      • referenceId: string

        External reference ID

      Returns this

      Builder instance for chaining

    • Set the order state. Use 'DRAFT' when creating an order template that will back a subscription phase.

      Parameters

      • state: OrderState

      Returns this