> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# CheckoutService

**Published**: 2026-11-30
**Category**: Services

Places an order from the buyer's cart, accessible via `lynkow.checkout`. Requires
`publishableKey`. Placement waits for every cart call invoked before it, then uses the
signed-in session, or for a guest the cart token `lynkow.cart` holds. If the buyer or
that token changes before the confirmation arrives, the call rejects with `UNAUTHORIZED`.

Access via: `lynkow.checkout`

## Methods

**2** methods

### `placeOrder`

```typescript
placeOrder(input: EmbeddedPlaceOrderInput, options?: CheckoutSubmitOptions): Promise<EmbeddedPlaceOrderResult>
```

Turns the buyer's cart into an order. Requires `acceptsTerms: true`; a guest also
sends `email`. With `paymentMethod: 'card'` the result carries `payment.checkoutUrl`:
redirect the buyer there, then confirm with CheckoutService.refreshPayment.
With an EmbeddedPlaceOrderInput (`paymentFlow: 'embedded'`), `payment` is an
EmbeddedOrderPayment that mounts the payment form in your page instead.
Other methods place the order without `payment`. Throws `LynkowError`
`VALIDATION_ERROR` with an `apiCode` such as `TERMS_NOT_ACCEPTED`,
`TERMS_PAGE_NOT_CONFIGURED`, `CART_EMPTY`, `OUT_OF_STOCK`, `TOTAL_CHANGED`,
`PAYMENT_METHOD_UNAVAILABLE`, `PAYMENT_FLOW_UNAVAILABLE` or a code listed on
PlaceOrderInput, creating no order; `NOT_FOUND` (`CART_NOT_FOUND`); `CONFLICT` (`CART_ALREADY_COMPLETED`);
`FORBIDDEN` (`ACCOUNT_REQUIRED`) when the site requires an account; and
`SERVICE_UNAVAILABLE` (`PAYMENT_CHECKOUT_UNAVAILABLE`) when the payment page fails
after the order was placed unpaid.

| Parameter | Type | Description |
| --- | --- | --- |
| `input` | `EmbeddedPlaceOrderInput` | PlaceOrderInput, or EmbeddedPlaceOrderInput for in-page payment: `acceptsTerms: true`, plus `email` for a guest, and the address, payment, fulfillment and shipping choices. |
| `options` | `CheckoutSubmitOptions` | CheckoutSubmitOptions: `locale`, `recaptchaToken`, `formStartedAt` and `fetchOptions`. |


Returns: `Promise<EmbeddedPlaceOrderResult>`

```typescript
const cart = await lynkow.cart.retrieve()
const order = await lynkow.checkout.placeOrder({
  email: 'buyer@example.com',
  paymentMethod: 'card',
  expectedTotalCents: cart.totalCents,
  acceptsTerms: true, // ticked by the buyer on the checkout page
})
if (order.payment) {
  // Keep paymentId and captureToken for the return page, then redirect.
  window.location.assign(order.payment.checkoutUrl)
}
```

---

### `refreshPayment`

```typescript
refreshPayment(paymentId: string, captureToken?: string, options?: BaseRequestOptions): Promise<OrderPaymentRefreshResult>
```

Checks a card payment with the payment provider once the buyer returns from the
payment page, and returns the payment and order statuses. Safe to repeat. A guest
passes the `captureToken` from OrderPayment; the signed-in buyer who owns the
order can omit it. Only `status: 'captured'` means the payment was taken. Throws
`LynkowError` `FORBIDDEN` (`apiCode` `PAYMENT_CAPABILITY_REQUIRED`) for an unknown
payment or when neither the token nor the session authorizes it.

| Parameter | Type | Description |
| --- | --- | --- |
| `paymentId` | `string` | The `pay_...` id from OrderPayment.paymentId. |
| `captureToken` | `string` | The guest's OrderPayment.captureToken; optional for the owning signed-in buyer. |
| `options` | `BaseRequestOptions` | `fetchOptions` passes through. |


Returns: `Promise<OrderPaymentRefreshResult>`

```typescript
const order = await lynkow.checkout.placeOrder({ email, paymentMethod: 'card', acceptsTerms: true })
// Keep paymentId and captureToken privately for the hosted-checkout return page.
if (order.payment) {
  const result = await lynkow.checkout.refreshPayment(
    order.payment.paymentId,
    order.payment.captureToken,
  )
  if (result.status === 'captured') showConfirmation(order.id)
}
```