Build on Novinzo plugins, themes and integrations for the commerce platform.

src/index.js

export default {
  async fetch(request, env) {
    const path = new URL(request.url).pathname;

    if (path === "/webhooks/variant-purchased") {
      const { storeId, orderId, variantId, quantity } = await request.json();
      await env.DB.prepare(
        "INSERT INTO purchases … ON CONFLICT DO NOTHING",
      ).bind(storeId, orderId, variantId, quantity).run();
      // acknowledge only after the durable write completes
      return new Response(null, { status: 204 });
    }
  },
};

Webhook delivered

variant-purchased204
{
  "storeId":   "7c1e…a90b",
  "orderId":   "f3d2…1c44",
  "variantId": "0b9a…e27f",
  "quantity":  2
}

Your first plugin is close one Worker, one webhook, and a store to install it on.