Step by step code to sync Shopify orders to Pipedrive using webhooks

Some links on this page are affiliate links. If you buy through them, we may earn a commission at no extra cost to you.

· By IMRAN HOSSAIN

Quick answer: You register a Shopify order webhook (orders/create or orders/paid), host a secure HTTPS endpoint that verifies Shopify HMAC signatures, transform the order JSON to Pipedrive fields, and call the Pipedrive API to create or update a person and deal. The minimal pipeline is webhook -> verify -> map -> Pipedrive API POST. Pipedrive integrations

  • Receive, verify, transform Shopify order webhooks and post to Pipedrive via API.
  • Production checklist, security steps, retry and idempotency rules to avoid duplicate deals.
  • Node.js and serverless code examples plus deployment and testing tips for small teams.

What is a Shopify webhook and why use it to sync orders?

A Shopify webhook is an HTTP callback Shopify sends when a store event happens, so you can react without polling.

Shopify webhooks push order events such as orders/create, orders/updated, orders/paid in JSON to a URL you provide. Using webhooks is more efficient than polling because Shopify sends only new or changed data, reducing API calls and lag. When you combine webhooks with a handler that verifies HMAC-SHA256 signatures and then calls the Pipedrive API, you get near real-time CRM entries that reflect purchase activity. Webhooks also let you implement idempotency by storing the shopify order id and rejecting duplicates. Use webhooks for reliability, lower latency, and lower API usage compared with scheduled syncs. For alternate automation routes or no-code flows, consider Zapier or n8n if you prefer managed connectors.

How do I create an order webhook in Shopify?

Create an order webhook in Shopify either from the Shopify admin or by calling the Admin API with the orders/create topic and your JSON endpoint.

From Shopify admin, go to Settings, Notifications, then Webhooks, choose the event orders/create or orders/paid, choose JSON, and provide your HTTPS URL. For programmatic registration, use the Shopify Admin REST webhooks endpoint or the GraphQL Admin API webhooks subscription. When you register programmatically you receive a webhook id you can delete later. Set a retry policy in Shopify admin only for manual webhooks; programmatic handlers should implement their own retry and dead letter logic because Shopify will attempt a few deliveries then stop, depending on delivery status. Always use an HTTPS endpoint that responds 200 quickly to acknowledge receipt; long-running processing should be delegated to background jobs to avoid timeouts.

How do I verify Shopify webhook authenticity?

Verify Shopify webhooks by computing an HMAC-SHA256 over the raw request body using your Shopify shared secret and comparing it to the X-Shopify-Hmac-Sha256 header.

When Shopify posts a webhook it sets the X-Shopify-Hmac-Sha256 header containing a base64 HMAC. You must compute HMAC-SHA256 using your app’s shared secret and compare the base64 digests in a time-safe comparison to prevent timing attacks. In Node.js, capture the raw request body before JSON parsing, compute crypto.createHmac(‘sha256’, secret).update(rawBody).digest(‘base64’), and compare. Reject requests missing that header or with mismatched values with HTTP 401. This prevents forged events and ensures only Shopify-originated orders create or update Pipedrive data. Also ensure TLS is enforced with modern ciphers and keep your shared secret in a secure secret store such as environment variables or a secrets manager.

How should I map Shopify order fields to Pipedrive fields?

Map a Shopify order to Pipedrive by creating or finding a person (buyer), creating a deal titled with order number, and storing order items and totals in deal fields or notes.

Decide the mapping strategy before coding. Typical mapping: Shopify order.email to Pipedrive person.email, order.customer.id to person.external_id, order.name or order.order_number to deal.title, and order.total_price to a deal custom field named Order Value. For order lines you can store JSON in a custom field or create an activity with the line items in the note. If you need line-level CRM objects, create separate Pipedrive activities or use custom objects. Keep mapping rules deterministic so retries are idempotent. If contacts are deduplicated in Pipedrive by email, check first using the Pipedrive persons/search endpoint and create only when absent. If you prefer no-code mapping, a marketplace app or middleware can handle this automatically, but custom mapping gives full control and avoids field mismatches.

What trade-offs matter when choosing direct webhook code vs no-code tools?

Direct webhook code gives full control and lower per-event cost, while no-code tools speed setup but add per-transaction fees and less control over mapping and retries.

Choose direct code if you need precise mapping, custom idempotency, or want to avoid per-transaction middleware fees. Use no-code services like Zapier or Make if you need a quick pilot and cannot maintain code. Hidden costs often ignored include per-event middleware charges and extra storage for retries. For example, middleware plans typically bill per task; estimate your monthly order volume and check each vendor’s pricing page before committing. If you manage compliance, direct code makes it easier to meet data retention rules and maintain logs in your systems. If you plan to scale beyond a few thousand orders per month, custom code hosted on a platform such as AWS Lambda or Heroku tends to be more cost-effective because you control execution and batching. Use the trade-off: choose speed and low maintenance for pilots, choose control and lower long-term cost for production usage.

Which programming stack should I use to implement the webhook handler?

Use Node.js with Express for quick development or a serverless function on AWS Lambda or Vercel for low maintenance deployments.

Node.js is widely used for webhook handlers because of lightweight JSON handling and available npm modules for HMAC, HTTP, and Pipedrive API clients. If you choose serverful hosting, Express on Heroku or a small VPS works and is easy to debug with ngrok in development. For lower ops, an AWS Lambda function behind API Gateway or Vercel serverless functions reduces maintenance. Keep webhook verification and a quick 200 response in the function, then enqueue heavy work to a queue like AWS SQS or a background worker. If you prefer a no-code integration route, evaluate Zapier, n8n, or a Pipedrive Shopify app; for decision help see the comparison between Pipedrive vs Zoho CRM if you are comparing CRMs.

What does a minimal Node.js webhook handler look like?

A minimal Node.js handler verifies HMAC, acknowledges with 200, then enqueues a job to upsert person and create a deal in Pipedrive.

Below is a concise flow in plain text you can adapt into an Express route. Capture the raw body before JSON parsing, verify X-Shopify-Hmac-Sha256, respond 200 immediately on success, then transform and call Pipedrive. Use a job queue for the Pipedrive POST if creating deals may take time. The Pipedrive REST API accepts POST /deals with fields such as title, value, person_id, and custom fields. To find or create a person, use GET /persons/search followed by POST /persons when missing. Keep your Pipedrive API token in an environment variable and rotate it periodically. For reference about migrations and integrations, see tips on how to migrate to Pipedrive.

// Pseudocode outline for Express route
// 1. capture rawBody
// 2. verify HMAC with SHOPIFY_SECRET
// 3. res.sendStatus(200)
// 4. enqueue job: ensurePerson(order.email) -> createDeal(mappedFields)

How do I handle retries, idempotency and duplicate orders?

Implement idempotency by storing Shopify order ids and rejecting repeat processing, and implement retries that back off and move to a dead-letter queue after repeated failures.

Shopify may redeliver webhooks for network failures, so your handler must treat webhook deliveries as potentially duplicated. Store the unique Shopify order.id or order.name in a persistent store and check before creating Pipedrive data. For network or transient Pipedrive API errors, retry with exponential backoff and a capped number of attempts, then place failing events into a dead-letter queue for manual review. If the Pipedrive call is successful but the acknowledgement failed, your idempotency key prevents duplicate deals. Use deterministic deal titles such as Order #1001 to identify duplicates, and prefer upserts using person email and order id stored in a custom deal field to reconcile later. For automated workflows and advanced retry control, you can consider managed automation platforms, or roll your own using queues such as AWS SQS.

Where should I deploy this code and how do I secure it?

Deploy on a secure, HTTPS-capable host such as AWS Lambda, Vercel, or Heroku, and store secrets in a secrets manager or environment variables with strict access controls.

Choose serverless platforms for low maintenance or a small VPS if you need full control. Ensure the endpoint enforces TLS 1.2 or later and uses a valid certificate. Store keys and tokens in secure stores such as AWS Secrets Manager, Vercel Environments, or Heroku Config Vars. Rotate Pipedrive API tokens and Shopify shared secrets periodically, and restrict access to the deployment console. Limit inbound IPs if you can, though Shopify uses many IPs, so HMAC verification is the primary defense. For local development test with ngrok to expose a secure tunnel. If you need compliance or audit logs, send webhook receipts to a centralized log store with retention configured. For integration alternatives or automation recipes, consider reading the guide on Pipedrive and Monday for automation patterns you can adapt.

Which one fits you? (beginner, tight budget, solo, team)

Choose direct code if you need control, a no-code connector for speedy start, and middleware for low-maintenance but higher cost.

  • Beginner, choose a Pipedrive marketplace app or Zapier because setup is GUI-driven and requires no code; it is fastest to start.
  • Tight budget, choose custom code on AWS Lambda or Heroku because per-event costs are lower long term than middleware fees.
  • Solo developer, use Node.js + Express on Vercel and ngrok for development for fast iteration and low ops.
  • Small team/agency, build a secure webhook service with a queue and monitoring to handle growth and audits. If you need comparisons, check Pipedrive vs Monday pricing to justify platform choices.

Who should NOT use custom code: teams with no maintenance capacity or those that prefer to avoid any backend responsibility; they should use a marketplace app or Zapier instead. For migration advice if switching CRMs, see the article about Pipedrive vs Keap.

What are the exact API calls to create or update a Pipedrive deal?

Create or update deals in Pipedrive by calling the Pipedrive REST endpoints to find or create a person, then POST /deals with mapped fields; use person_id to link the deal.

Typical sequence: 1) search persons by email, 2) if missing, POST /persons with name and email, 3) POST /deals with title, value, person_id and any custom_fields. To update an existing deal, call PUT /deals/{id}. Use Pipedrive API keys or OAuth2 according to your security model. Make your calls idempotent by including the Shopify order id in a custom field so repeated processing does not create duplicates. For automated testing, Pipedrive provides sandbox accounts via the Pipedrive Marketplace for apps; check the Pipedrive API docs while building. If you need integration recipes combining accounting or inventory systems, compare recommended linkups for accounting at NetSuite and Sage ecommerce.

Option Price range Best for Key strengths Main limits
Custom webhook code Server costs only Control, scalability Full mapping, idempotency Requires dev time
Zapier / Make Subscription fees Quick setup No code, fast Per-task costs, less control
Shopify / Pipedrive app App fees vary Plug-and-play Marketplace support Mapping limits, vendor lock

Checklist: what you must do before going live

Complete verification, mapping, idempotency, retries, logging and secret handling before enabling the webhook in production.

  • Register webhook in Shopify admin or via API and test with a development tunnel.
  • Implement HMAC-SHA256 verification and reject unauthenticated requests.
  • Implement persistent idempotency by storing Shopify order ids.
  • Map essential fields: order number, total, buyer email, shipping address.
  • Ensure Pipedrive person search and deal creation are idempotent.
  • Add exponential backoff retries and a dead-letter queue for failures.
  • Store secrets in a secrets manager and enable TLS and logging.
  • Run end-to-end tests with sample orders and reconcile results.

What common mistakes should I avoid?

The most common mistakes are not verifying webhooks, blocking on long processing in the request, and not implementing idempotency.

Other frequent errors include storing secrets in source code, assuming webhook delivery order, and mapping without considering different currencies or refunds. Avoid creating duplicate persons by not searching by email first. Do not perform heavy I/O before sending a 200 response; instead, enqueue work. Watch for timezone differences on order timestamps and normalize times to UTC. If you rely on middleware without checking per-task costs, a small store can quickly exceed a free plan. For guidance on integrations with bookkeeping or payment systems after syncing orders, look at suggested options for Xero ecommerce integrations and QuickBooks vs Sage integrations.

How should I test and monitor the integration?

Test with ngrok or a staging HTTPS endpoint, send sample order webhooks from Shopify, and monitor delivery, processing success, and Pipedrive API responses.

Create automated tests that hit your endpoint with signed payloads and assert that person and deal records are created correctly in Pipedrive. Use logging to capture raw payloads, verification results, and API responses. Monitor error rates, queue lengths, and retry counts with alerts. Add a reconciliation job that compares recent Shopify orders with Pipedrive deals to detect missed deliveries. For low-touch monitoring, a simple uptime check and a daily reconciliation report are often enough; for higher volumes use structured logs and metrics. If you need to expand the integration to link orders to accounting or inventory, plan for audit trails and reconcile with accounting integrations like the NetSuite and Sage guides on this site.

FAQ

See the top six voice-style questions and concise answers above in the FAQ JSON for quick spoken responses.

Summary and final verdict

Direct webhook code is the best long-term solution if you need precise mapping, automated retries, and lower per-order cost, while marketplace apps or middleware speed initial setup. Implement HMAC verification, idempotency with Shopify order ids, enqueue heavy work, and create or link Pipedrive persons before creating deals for reliable results. Follow the checklist and avoid common mistakes to keep your sync stable and auditable.

For Shopify webhook reference and exact API parameters, consult the official Shopify webhooks docs. For Pipedrive endpoints and authentication details, consult the Pipedrive API docs.

Internal resources to help next steps include migration and pricing comparisons such as Pipedrive vs Keap pricing, Pipedrive vs Monday, Pipedrive vs Infusionsoft, Xero and Sage integrations, Pipedrive vs Monday pricing, sync OneNote and Notion, Fireflies integrations, Build custom Coda apps, Migrate from ClickFunnels, Alternatives to Salesforce, Klaviyo alternatives, Pietra review, Using security keys, and Pipedrive vs Zoho CRM which can help when expanding integrations.

Good luck building a reliable sync. If you want, tell me your stack (Node.js, Python, serverless) and I will generate exact handler code and a mapping file for your Pipedrive custom fields.

Edit Template