datewise/app/routes/webhooks.orders.cancelled.tsx
metatroncubeswdev e56182e0e3 chore: initial Datewise app (rebranded from SlotSure prototype)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:06:49 -04:00

12 lines
596 B
TypeScript

import type { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
import { firstDelivery, handleOrderCancelled } from "../services/orders.server";
export const action = async ({ request }: ActionFunctionArgs) => {
const { shop, topic, payload, webhookId } = await authenticate.webhook(request);
const eventId = request.headers.get("x-shopify-event-id") ?? webhookId;
if (!(await firstDelivery(eventId, topic, shop))) return new Response();
await handleOrderCancelled(shop, payload as { admin_graphql_api_id: string });
return new Response();
};