Rafael SilvaContact

Automation2026

Kit stock automation

Updates ERP stock for each piece in a paid kit, with protection against duplicate movements.

Contribution
The whole stock service: webhook, kit parsing, SKU mapping, ERP sign-in, idempotent stock movements and the switches around them.
Status
Live
Year
2026
Stack
Supabase, Postgres

Credits Bling as ERP.


Evidence

What it delivers

Production capture · live store

Where each piece is chosen

Kit builder on the live store: step 1 of 2, colour and size for the first piece, previous and next piece buttons (product photos blurred, brand and product names replaced)
The kit page asks for the colour and size of each piece, one step at a time. Product photos blurred; brand and product names replaced.
Execution record · anonymised

Go-live record, 31 May 2026

A real kit order: what the integration did with each piece

PieceERP SKUStock in the ERP
Top…19811−1 · success
Short…25096−1 · success

How the pieces are read (property names from the integration's code, not this order's payload)

_kit_component_N_sku
_kit_component_N_variant_id
_kit_component_N_quantity

A repeated webhook can't move the same piece twice: the key order + line + SKU is saved before the stock call.

From the integration's go-live record. SKUs shortened; order, warehouse and movement numbers withheld.

Kit stock automation

Kit builder on the live store: step 1 of 2, colour and size for the first piece, previous and next piece buttons (product photos blurred, brand and product names replaced)

Client names and logos hidden.


Overview

What I built

  • The Shopify order-paid webhook is checked with HMAC before anything runs.
  • Kit pieces come from the order's line-item properties; each piece maps to its SKU in the ERP.
  • ERP sign-in with OAuth tokens stored in the database and refreshed automatically when they expire.
  • Stock movements are idempotent and sit behind two switches, dry run by default, with retry and backoff when the ERP rate-limits.
  • A manual rollback is documented for each release.

Part of Fitness-apparel store & kit operations.


How it's wired

The flow, step by step

ExplanationA diagram drawn for this page: how the flow is built, not live traffic.

A paid kit order is checked with HMAC, split into its pieces, and each piece's stock is moved once in the ERP.
  • Shopify

1 kit → its pieces HMAC · SKU per piece · idempotent

  • Piece A stock in the ERP
  • Piece B stock in the ERP
  1. Order paid webhook, HMAC checked
  2. Kit pieces read from the order
  3. ERP SKU for each piece
  4. Idempotent stock intent
  5. Stock moved in Bling

Screens

Where it shows up

Production capture · live store
The kit builder on a phone, where each piece is chosen (product photos blurred, brand and product names replaced)
The kit builder on a phone, where each piece is chosen (product photos blurred, brand and product names replaced).

Need something similar? Tell me what you're working on.

Contact on LinkedIn

or e-mail contato@rafaelshopify.dev


Explore more