Rafael SilvaContact

Integration2026

Connecting Shopify to invoicing and shipping

Staff were copying e-invoice keys from the ERP to the shipping platform by hand. I built an integration that checks each invoice and writes only valid keys to the Shopify order, with one shipment timeline across carriers. Built for three Brazilian D2C brands.

Contribution
Architecture, build and operation
Status
In production for three brands
Client
Three Brazilian D2C brands on Shopify, through a commerce agency
Period
Since September 2026
Stack
Supabase (Postgres), Deno Edge Functions, Shopify Admin API, Bling ERP

Credits Implementation assisted by AI coding agents

Product screen · synthetic dataLogistics panel that follows the integration, rendered from the product's own code with synthetic demo data and no production access.
Logistics overview on desktop: order status counts and the orders that need action (synthetic data)
Logistics overview on a phone: late, on-time, stalled and in-transit order counts (synthetic data)Exceptions on a phone: one row per order with the next action, split by operation and system (synthetic data)Order page on a phone: pending actions and the form that links a shipment to the order (synthetic data)Order timeline on a phone: carrier and Shopify events, newest first, with raw statuses (synthetic data)
Product screen · synthetic data

The panel that follows the integration: carrier and Shopify events

Logistics panel, order timeline: carrier and Shopify tracking events in one list, newest first, each with its raw status and event type
One timeline per order joins the carrier's and Shopify's events, keeping each raw status. Rendered from the logistics panel's own code with synthetic orders: it shows how the team follows the integration, not a live shipment.
Execution record · anonymised

Shadow-mode report, 28 September 2026

Label decisions on real orders with writes disabled: one brand, three days

MeasureResult
Orders evaluated37
Ineligible orders proposed for a label0
Eligible orders held back2

2,769 decisions logged: each order was re-checked every cycle until it settled. A period without Shopify access was excluded.

From the integration's shadow-window report. Brand and order numbers withheld.

Problem

Every shipment needed an electronic tax invoice (NF-e, Brazil's e-invoice) issued in the ERP, Bling, before a label could be bought in the shipping platform, Frenet. Staff copied the invoice's access key from one system to the other by hand. Around that handoff:

  • labels were sometimes created twice, or through the wrong shipping flow;
  • there was no single view of each shipment across carriers, including a same-day courier connected through a logistics platform;
  • bursts of ERP API calls hit its rate limit (HTTP 429), and a webhook that failed at the wrong moment could be lost.

What I built

  • Webhooks stored before processing. Each ERP webhook is verified and saved before the service confirms receipt, and repeated deliveries are processed once.
  • Invoice checks before Shopify. A worker re-reads each invoice from the ERP and only continues for the right type, an authorised status and a valid 44-digit key, then writes the key to the Shopify order with a concurrency check. The shipping platform reads it from there.
  • One shipment timeline. Order stages and shipment statuses from the ERP, the shipping platform and the courier are normalised into one timeline for the agency's dashboard.
  • Label decisions tested before automation. The label and fulfilment engine ran in shadow mode on real orders: it recorded what it would do, without creating labels or fulfilments, and I compared its decisions with what actually happened.

Proof

  • First live invoice with no manual step: from the ERP to Shopify and on to the shipping platform. The worker processed it in 1.24 s on its first attempt (one recorded run); with the one-minute schedule, the key reached Shopify about 47 s after the ERP's webhook.
  • Shadow evaluation, one brand, three days: with writes disabled, the engine evaluated 37 orders, re-checking each one as it changed (a period without Shopify access was excluded). Compared order by order with what happened in Shopify: 0 false positives (no ineligible order was proposed for a label) and 2 false negatives (eligible orders held back).
  • Rate limits: after rescheduling one brand's ERP polling job and cutting calls per cycle from 26 to about 11, rate-limit errors for that job went from 119 in one 24-hour window to 0 in the next (96 cycles, live traffic).
  • Tests in CI, 2 October 2026: 1,123 automated tests and 1,323 database assertions passing; every push also runs formatting, linting, type checks and secret scanning.
CI run for the integration platform: both jobs green and "No leaks detected" (repository and branch names redacted)
The CI run behind those numbers, 2 October 2026 (names redacted). The platform runs in the background; its shipment timeline lives inside the agency dashboard, shown below with synthetic orders.

Where the team sees it

The integration feeds the logistics panel inside the agency dashboard: late, stalled and in-transit orders, the ones that need action, one timeline per order and the exceptions to resolve. The screens below run the panel's own code with synthetic orders in an isolated demo, with no production endpoint called; the live panel holds customer data.

Logistics panel overview: late, on-time, stalled and in-transit orders, and the orders that need action (synthetic data)
Overview of the operation, with invented orders and customers.

The order timeline at the top of this page comes from the same panel: Shopify and carrier events in one list, newest first; ERP events join the same list.


Tech details

How it's built

Architecture

  • Supabase Postgres with a private schema and an RPC-only API: no direct table access, and every operation goes through reviewed database functions.
  • 21 Deno Edge Functions, pg_cron, pgTAP and GitHub Actions.
  • The worker runs every minute and claims events with FOR UPDATE SKIP LOCKED; events left in progress for five minutes go back to the queue. Retries use capped exponential backoff with jitter, and ERP calls are spaced at least 500 ms apart.
  • Shopify writes go to an order metafield with read → compare → write, so a concurrent change is detected instead of overwritten. GraphQL userErrors inside an HTTP 200 count as failures.
  • Invoices that fail the checks are marked ignored, failed or in conflict, and their keys never reach Shopify.
  • The shadow run logged 2,769 decisions over the three days, because each order was re-evaluated every cycle until it settled.

Decisions that mattered

  1. Store first, then acknowledge. An earlier prototype answered "success" even when its insert failed, which can lose an event silently.
  2. Check the invoice against the ERP before updating Shopify. During rollout, this stopped a still-pending invoice from being written to a live order.
  3. New invoices only at first. Historical orders stayed manual, which limited the impact of rollout errors and kept rollback simple.
  4. Evaluate label actions before enabling writes, and treat "held back" as the safe way to fail.

What this means for your store

This project used Brazilian ERP and shipping providers (Bling, Frenet and a logistics platform). For another provider, I would first check its API and test the workflow in a sandbox, then adapt the event handling, retries and validation.

Contact on LinkedIn

or e-mail contato@rafaelshopify.dev


Explore more