# Build a checkout

A short path from an empty cart to a paid order:

```js title="From cart to purchase"
await subbly.cart.create()
await subbly.cart.addItem({ productId: 3301, quantity: 1 })

await subbly.cart.update({
  customer: { email: 'ada@example.com', tosConsent: true },
  shippingAddress: { /* … */ },
})

const methods = await subbly.cart.getShippingMethods({
  countryId: 826,
  zip: 'NW1 5JD',
})
await subbly.cart.update({ shippingMethodId: methods[0].id })

await subbly.auth.login({ email, password })
await subbly.cart.attachCustomer()

const { invoice } = await subbly.checkout.purchase(subbly.cart.id)
```

Each step has its own page:
[cart](/reference/subbly-sdk/cart#create),
[items](/reference/subbly-sdk/cart#add-item),
[shipping](/reference/subbly-sdk/cart#get-shipping-methods),
[authentication](/reference/subbly-sdk/auth#login) and
[checkout](/reference/subbly-sdk/checkout#purchase).

## Next steps

- [Handle errors](/developer-resources/subbly-js-sdk/handle-errors) — what a
  failed call rejects with.
- [Run a funnel](/developer-resources/subbly-js-sdk/run-a-funnel) — add
  upsell offers before, during and after checkout.
- [Storefront API](/api/storefront) — the HTTP API the SDK calls.
