Skip to content

E-Commerce

Automatically create and send invoices when orders are completed.

Invoice from Order

Convert order data to a compliant invoice:

Order invoicetypescript
// title: Create invoice from order
const invoice = await sdk.invoices.create(
  {
    customer: {
      name: order.billingAddress.name,
      email: order.email,
      address: order.billingAddress.street,
      city: order.billingAddress.city,
      zip: order.billingAddress.zip,
      country: order.billingAddress.country,
    },
    items: order.items.map((item) => ({
      name: item.productName,
      quantity: item.quantity,
      price: item.unitPrice,
    })),
    note: `Order #${order.orderNumber}`,
  },
  { entity_id: entityId }
);

Send with Order Confirmation

Send invoicetypescript
// title: Send invoice to customer
await sdk.email.send(invoice.id, {
  to: order.email,
  subject: `Invoice for Order #${order.orderNumber}`,
  message: "Thank you for your purchase! Please find your invoice attached.",
});

Key Benefits

  • Automatic compliance — Tax rates based on customer location
  • Order linking — Use metadata to link invoices to orders
  • Instant delivery — Email invoices automatically on purchase
  • Multi-currency — Support international customers

Integration Points

EventAction
Order completedCreate invoice
Payment confirmedSend invoice email
Refund issuedCreate credit note

Integration Flow

E-commerce integration flow
┌──────────────┐     ┌─────────────────┐     ┌──────────────┐
│   Customer   │     │   Your Store    │     │    Space     │
│   Checkout   │────▶│   Backend       │────▶│   Invoices   │
└──────────────┘     └─────────────────┘     └──────────────┘
                            │                       │
                            │  1. Order completed   │
                            │─────────────────────▶│
                            │                       │
                            │  2. Create invoice    │
                            │─────────────────────▶│
                            │                       │
                            │  3. Send to customer  │
                            │─────────────────────▶│
                            │                       │

Next Steps