Verify and fulfill
- Verify the signature and event ID.
- Retrieve the local payment if needed.
- Match payment ID, order ID, amount, and currency.
- Confirm the event represents a final successful state.
- Fulfill once and record the event ID.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Connect payment confirmation to order fulfillment.
export async function handleConfirmedPayment(event) {
if (event.type !== "payment.confirmed") return;
const payment = event.data.object;
const order = await orders.findByPaymentId(payment.id);
if (!order || order.amountMinor !== payment.amountMinor || order.currency !== payment.currency) {
throw new Error("payment does not match the order");
}
await orders.fulfillOnce(order.id, event.id);
}