Integrations / Shopify

    S

    Shopify

    Capture Shopify store events — orders, products, customers, fulfillments — and replay them for testing or debugging your Shopify app integrations.

    Auto-detected:Paggio detects Shopify events via the x-shopify-hmac-sha256 or x-shopify-topic header.

    Setup (Shopify Admin)

    1

    Create a Paggio endpoint

    Go to Dashboard → Webhooks → New Endpoint.

    Set a destination URL to your handler if you want live forwarding.

    2

    Go to Shopify webhook settings

    In your Shopify Admin, go to Settings → Notifications → Webhooks. Or via the Admin API.

    3

    Add your Paggio URL

    Click Create webhook and configure:

    • · Event — choose the event (e.g. Order creation)
    • · Format — JSON
    • · URL — your Paggio endpoint URL
    text
    https://paggio.dev/api/webhook/your-endpoint-slug
    4

    Send a test event

    Click Send test notification from the Shopify webhook settings, or place a test order in a development store.

    Via Shopify Admin API

    bash
    curl -X POST \
      "https://your-store.myshopify.com/admin/api/2024-01/webhooks.json" \
      -H "X-Shopify-Access-Token: {your-access-token}" \
      -H "Content-Type: application/json" \
      -d '{
        "webhook": {
          "topic": "orders/create",
          "address": "https://paggio.dev/api/webhook/your-endpoint-slug",
          "format": "json"
        }
      }'

    Verifying Shopify HMAC signatures

    app/api/shopify/webhook/route.ts
    import { createHmac } from 'crypto';
    
    export async function POST(req: Request) {
      const body = await req.text();
      const hmac = req.headers.get('x-shopify-hmac-sha256');
      const topic = req.headers.get('x-shopify-topic');
    
      // Verify HMAC
      const hash = createHmac('sha256', process.env.SHOPIFY_WEBHOOK_SECRET!)
        .update(body, 'utf8')
        .digest('base64');
    
      if (hash !== hmac) {
        return Response.json({ error: 'Unauthorized' }, { status: 401 });
      }
    
      const data = JSON.parse(body);
    
      switch (topic) {
        case 'orders/create':
          console.log('New order:', data.id, 'for', data.total_price);
          break;
        case 'products/update':
          console.log('Product updated:', data.title);
          break;
      }
    
      return Response.json({ received: true });
    }

    Common Shopify webhook topics

    TopicWhen it fires
    orders/createNew order placed
    orders/paidOrder payment received
    orders/fulfilledOrder fully fulfilled
    orders/cancelledOrder cancelled
    products/createNew product created
    products/updateProduct updated
    customers/createNew customer created
    fulfillments/createFulfillment created
    refunds/createRefund issued