Back to arky.io

E-shop

Products, orders, checkout, and payment processing

The E-shop module provides complete e-commerce functionality including product management, order processing, and checkout.

Products

Create Product

POST /v1/businesses/{businessId}/products
SDK: sdk.eshop.createProduct()

Create a new product. New products start in the active state.

const result = await sdk.eshop.createProduct({
key: 'premium-widget',
slug: { en: 'premium-widget' },
taxonomies: [
  { taxonomyId: 'tax_category', entryIds: ['ent_widgets'] }
],
blocks: [
  {
    key: 'details',
    type: 'TEXT',
    content: {
      body: { en: 'Product specifications...' }
    }
  }
],
variants: [
  {
    sku: 'WIDGET-SM',
    prices: [{ market: 'USD', amount: 2999 }],
    inventory: [{ locationId: 'loc_warehouse', available: 100 }],
    attributes: [],
    weight: 500
  },
  {
    sku: 'WIDGET-LG',
    prices: [{ market: 'USD', amount: 3999 }],
    inventory: [{ locationId: 'loc_warehouse', available: 50 }],
    attributes: [],
    weight: 750
  }
]
});

Parameters

Name Type Description
key required string Unique product key identifier
slug optional Record<string, string> Locale-keyed URL slugs (e.g., {en: 'my-product'})
blocks optional Block[] Content blocks for product details
taxonomies optional TaxonomyEntry[] Taxonomy entries the product belongs to (category, collection, etc.)
variants optional Variant[] Product variants (sku, prices, inventory, attributes, weight)

Get Product

GET /v1/businesses/{businessId}/products/{id}
SDK: sdk.eshop.getProduct()

Retrieve a product by ID or slug.

// By ID
const result = await sdk.eshop.getProduct({
  id: 'prod_xyz789'
});

// By slug (locale-aware)
const result = await sdk.eshop.getProduct({
  slug: 'premium-widget'
});

Parameters

Name Type Description
id optional string Product ID (use this OR slug)
slug optional string Product slug (locale-aware lookup)

List Products

GET /v1/businesses/{businessId}/products
SDK: sdk.eshop.getProducts()

List products with filtering and pagination.

const result = await sdk.eshop.getProducts({
ids: ['prod_1', 'prod_2'],
taxonomyQuery: [
  { taxonomyId: 'tax_category', entryIds: ['ent_widgets'] }
],
matchAll: true,
status: 'active',
query: 'premium',
sortField: 'createdAt',
sortDirection: 'desc',
cursor: null,
limit: 20,
createdAtFrom: 1704067200,
createdAtTo: 1706745600
});

const { items, cursor } = result;
items.forEach(product => {
console.log(product.key, product.variants);
});

Parameters

Name Type Description
ids optional string[] Filter by specific product IDs
taxonomyQuery optional TaxonomyQuery[] Filter by taxonomy entries (category, collection, etc.)
matchAll optional boolean If true, match all taxonomy filters (AND); if false, match any (OR)
status optional active | archived Filter by product status
query optional string Search query in product content
sortField optional string Sort field (createdAt, updatedAt, etc.)
sortDirection optional asc | desc Sort direction
cursor optional string Pagination cursor
limit optional number Items per page (max 100)
createdAtFrom optional number Filter by creation date (Unix timestamp)
createdAtTo optional number Filter by creation date (Unix timestamp)

Update Product

PUT /v1/businesses/{businessId}/products/{id}
SDK: sdk.eshop.updateProduct()

Update an existing product. Use status to archive or re-activate a product.

const result = await sdk.eshop.updateProduct({
  id: 'prod_xyz789',
  key: 'updated-widget',
  slug: { en: 'updated-widget', es: 'widget-actualizado' },
  taxonomies: [
    { taxonomyId: 'tax_category', entryIds: ['ent_widgets', 'ent_sale'] }
  ],
  blocks: [/* updated blocks */],
  variants: [
    {
      id: 'var_existing',
      sku: 'WIDGET-SM-V2',
      prices: [{ market: 'USD', amount: 3499 }],
      inventory: [{ locationId: 'loc_warehouse', available: 150 }],
      attributes: [],
      weight: 500
    }
  ],
  status: 'active'
});

Parameters

Name Type Description
id required string Product ID to update
key optional string Product key identifier
slug optional Record<string, string> Locale-keyed URL slugs
blocks optional Block[] Content blocks
taxonomies optional TaxonomyEntry[] Taxonomy entries the product belongs to
variants optional Variant[] Product variants (id, sku, prices, inventory, attributes, weight)
status optional active | archived Product status

Delete Product

DELETE /v1/businesses/{businessId}/products/{id}
SDK: sdk.eshop.deleteProduct()

Delete a product.

await sdk.eshop.deleteProduct({
  id: 'prod_xyz789'
});

Orders

Create Order

POST /v1/businesses/{businessId}/orders
SDK: sdk.eshop.createOrder()

Create a new order without payment processing (use checkout for payment). Created orders start with status: 'active' and workflowStatus: 'created'.

const result = await sdk.eshop.createOrder({
  market: 'USD',
  customerId: 'acc_customer123',
  items: [
    { productId: 'prod_xyz789', variantId: 'var_small', quantity: 2 },
    { productId: 'prod_abc456', variantId: 'var_default', quantity: 1 }
  ],
  shippingAddress: {
    name: 'Jane Doe',
    street1: '456 Customer Ave',
    city: 'New York',
    state: 'NY',
    postalCode: '10001',
    country: 'US'
  },
  forms: [
    {
      key: 'shipping-notes',
      entries: [{ key: 'note', value: 'Leave at door' }]
    }
  ]
});

Parameters

Name Type Description
market required string Market/currency code (e.g., USD, EUR)
items required CheckoutItem[] Order items (productId, variantId, quantity)
customerId optional string Customer account ID
shippingAddress optional Address Shipping address
billingAddress optional Address Billing address
forms optional FormEntry[] Order form entries (customer info, notes, etc.)

Get Order

GET /v1/businesses/{businessId}/orders/{id}
SDK: sdk.eshop.getOrder()

Retrieve an order by ID.

const order = await sdk.eshop.getOrder({
  id: 'ord_xyz789'
});

console.log(order.status, order.workflowStatus, order.total, order.items);

Parameters

Name Type Description
id required string Order ID

List Orders

GET /v1/businesses/{businessId}/orders
SDK: sdk.eshop.getOrders()

List orders with filtering. Orders have two status fields: status (active / archived) for soft archival, and workflowStatus for the payment/fulfillment lifecycle.

const result = await sdk.eshop.getOrders({
customerId: 'acc_customer123',
status: 'active',
workflowStatus: 'confirmed',
productIds: ['prod_xyz789'],
query: 'john@example.com',
sortField: 'createdAt',
sortDirection: 'desc',
cursor: null,
limit: 50,
createdAtFrom: 1704067200,
createdAtTo: 1735689600
});

result.items.forEach(order => {
console.log(order.id, order.status, order.workflowStatus, order.total);
});

Parameters

Name Type Description
customerId optional string Filter by customer account ID
status optional active | archived Filter by order archival status
workflowStatus optional string Filter by workflow status: created, pending, authorized, confirmed, completed, cancelled, failed
productIds optional string[] Filter by products in order
audienceId optional string Filter by audience
query optional string Search query
sortField optional string Sort field
sortDirection optional asc | desc Sort direction
cursor optional string Pagination cursor
limit optional number Items per page
createdAtFrom optional number Filter by creation date (Unix timestamp)
createdAtTo optional number Filter by creation date (Unix timestamp)

Update Order

PUT /v1/businesses/{businessId}/orders/{id}
SDK: sdk.eshop.updateOrder()

Update an order’s archival state, workflow status, addresses, form entries, items, or payment.

// Advance the workflow
await sdk.eshop.updateOrder({
id: 'ord_xyz789',
workflowStatus: 'confirmed'
});

// Archive an order
await sdk.eshop.updateOrder({
id: 'ord_xyz789',
status: 'archived'
});

// Update addresses / form entries
await sdk.eshop.updateOrder({
id: 'ord_xyz789',
shippingAddress: {
  name: 'Jane Doe',
  street1: '456 Customer Ave',
  city: 'New York',
  state: 'NY',
  postalCode: '10001',
  country: 'US'
},
forms: [
  { key: 'notes', entries: [{ key: 'note', value: 'Leave at door' }] }
],
items: [
  { productId: 'prod_xyz', variantId: 'var_1', quantity: 2 }
]
});

Parameters

Name Type Description
id required string Order ID to update
status optional active | archived Archival status
workflowStatus optional string Workflow status: created, pending, authorized, confirmed, completed, cancelled, failed
shippingAddress optional Address | null Shipping address (pass null to clear)
billingAddress optional Address | null Billing address (pass null to clear)
forms optional FormEntry[] Order form entries
items optional CheckoutItem[] Order items (productId, variantId, quantity)
payment optional Payment Payment object update
Note

status controls whether the order is visible in the active list or archived. workflowStatus drives the payment and fulfillment lifecycle and is usually advanced by the server (checkout, webhooks, etc.).

Checkout

Get Quote

POST /v1/businesses/{businessId}/orders/quote
SDK: sdk.eshop.getQuote()

Calculate order total before checkout. The SDK injects market automatically from the client config.

const quote = await sdk.eshop.getQuote({
items: [
  { productId: 'prod_xyz789', variantId: 'var_small', quantity: 2 }
],
paymentMethodId: 'pm_card_visa',
shippingMethodId: 'ship_standard',
promoCode: 'SAVE10',
location: {
  country: 'US',
  state: 'NY',
  postalCode: '10001'
}
});

console.log('Subtotal:', quote.subtotal);
console.log('Discount:', quote.discount);
console.log('Shipping:', quote.shipping);
console.log('Tax:', quote.tax);
console.log('Total:', quote.total);

Parameters

Name Type Description
items required EshopItem[] Cart items with productId, variantId, and quantity
paymentMethodId optional string Payment method for fee calculation
shippingMethodId optional string Shipping method for rate calculation
promoCode optional string Promo code for discount
location optional ZoneLocation Shipping location used for tax and zone resolution

Checkout

POST /v1/businesses/{businessId}/orders/checkout
SDK: sdk.eshop.checkout()

Process payment and complete an order. The SDK injects businessId and market from the client config. The checkout response includes orderId, order number, a Stripe clientSecret (when 3DS or additional confirmation is required), and the payment object.

const result = await sdk.eshop.checkout({
items: [
  { productId: 'prod_xyz789', variantId: 'var_small', quantity: 2 }
],
paymentMethodId: 'pm_card_visa',
shippingMethodId: 'ship_standard',
shippingAddress: {
  name: 'Jane Doe',
  street1: '456 Customer Ave',
  city: 'New York',
  state: 'NY',
  postalCode: '10001',
  country: 'US'
},
forms: [
  {
    key: 'customer-info',
    entries: [
      { key: 'email', value: 'customer@example.com' },
      { key: 'firstName', value: 'John' },
      { key: 'lastName', value: 'Doe' }
    ]
  }
],
promoCodeId: 'promo_save10'
});

if (result.clientSecret) {
// Additional confirmation (e.g. 3D Secure) required on the client
const { error } = await stripe.confirmCardPayment(result.clientSecret);
if (error) throw new Error(error.message);
}

console.log('Order placed:', result.orderId, result.number);

Parameters

Name Type Description
items required EshopItem[] Cart items with productId, variantId, and quantity
shippingMethodId required string Selected shipping method
paymentMethodId optional string Payment method from Stripe
shippingAddress optional Address Shipping address
billingAddress optional Address Billing address
forms optional FormEntry[] Order form entries (customer info, notes, etc.)
promoCodeId optional string Applied promo code ID

Complete Checkout Flow

import { loadStripe } from '@stripe/stripe-js';

const stripe = await loadStripe('pk_live_xxx');

async function checkout(cart: CartItem[]) {
  // 1. Get quote to show prices
  const quote = await sdk.eshop.getQuote({
    items: cart.map(item => ({
      productId: item.productId,
      variantId: item.variantId,
      quantity: item.quantity
    })),
    shippingMethodId: selectedShipping,
    promoCode: promoCodeInput
  });

  console.log('Total:', quote.total);

  // 2. Create Stripe payment method
  const { paymentMethod, error } = await stripe.createPaymentMethod({
    type: 'card',
    card: cardElement,
    billing_details: {
      email: customerEmail
    }
  });

  if (error) {
    throw new Error(error.message);
  }

  // 3. Checkout
  const result = await sdk.eshop.checkout({
    items: cart.map(item => ({
      productId: item.productId,
      variantId: item.variantId,
      quantity: item.quantity
    })),
    paymentMethodId: paymentMethod.id,
    shippingMethodId: selectedShipping,
    shippingAddress,
    forms: [
      {
        key: 'customer',
        entries: [
          { key: 'email', value: customerEmail },
          { key: 'firstName', value: customerFirstName },
          { key: 'lastName', value: customerLastName }
        ]
      }
    ],
    promoCodeId: appliedPromoId
  });

  if (result.clientSecret) {
    // Handle 3D Secure / additional confirmation
    const { error } = await stripe.confirmCardPayment(result.clientSecret);
    if (error) throw new Error(error.message);
  }

  return result.orderId;
}
Tip

Use the getQuote endpoint to show price breakdowns before the customer commits to purchase.