E-Commerce
Automatically create and send invoices when orders are completed.
Invoice from Order
Convert order data to a compliant invoice:
// 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
// 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
metadatato link invoices to orders - Instant delivery — Email invoices automatically on purchase
- Multi-currency — Support international customers
Integration Points
| Event | Action |
|---|---|
| Order completed | Create invoice |
| Payment confirmed | Send invoice email |
| Refund issued | Create 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
- Invoices Guide — Full invoice options
- Email Guide — Custom email templates