Skip to content
NewA realistic 3D head for a free swim cap editor
Nov 19, 2026·4 MIN READ
A twin for the paid part of the Printful API

A twin for the paid part of the Printful API

A test environment could never go past the one API call that costs money, so half of the order flow was never tested. A small proxy that fakes only that call fixed it, and the first full run found three bugs.

Every test order on a client's merch platform stopped at the same place. The order came in from a Shopify store, our system created a draft at Printful, the print-on-demand service that makes and ships the merch, and then nothing.

The problem

The next step is to confirm the draft. A confirm makes Printful charge for the order and start printing. There is no free version of that call, so local and staging never made it.

That left a hole in the middle of the flow. Everything after the confirm was untested: production, shipping, tracking, the order turning to Fulfilled in the store. It was the half of the flow where a mistake costs real money and lands at a real fan's door.

If one step of a flow can never run in a test environment, every step behind it is untested too, however good the tests before it are.

Why not a full mock

A mock of the whole API was my first idea, and I dropped it fast. A mock drifts away from the real thing. Costs, product variants and the rules for a draft are exactly the parts where I want the real answers, and the sandbox gives them for free.

Only one call was the problem. So only one call should be fake.

The idea: a proxy that fakes only the paid part

The twin is a proxy that pretends to be the Printful API. Our services call it in place of the real address. Every call goes straight through to the real sandbox, with one exception: the confirm. For that one the twin answers itself and keeps its own shadow copy of the order.

flowchart LR
    A[Our services] --> T["Printful twin<br/>(a proxy)"]
    T -->|"everything else"| P["Real Printful<br/>sandbox"]
    T -->|"confirm"| S["Twin answers itself"]
    S --> D["in production,<br/>shipped, delivered"]

From there the twin plays the rest of the order's life. A small page has a button for each step: start production, ship, delivered. The real order stays a free draft the whole time.

One rule is not negotiable: a confirm must never reach the real API. Anything that looks like a confirm and is not played by the twin is refused, not passed on.

What it gave us

With the hole closed I could write one test that takes an order all the way, from the storefront to Fulfilled with a tracking number. The first full run found three bugs:

One order per run

The confirm job stopped after its first order. Nobody had ever confirmed two in a row.

Shipped in one place only

The store said Fulfilled. Our own order tables still said pending.

A fix that never fired

My fix for the second bug worked in my manual check and failed in the real order of events.

None of them could show up before, because no test order had ever passed the confirm. They sat in the part of the flow we would have met for the first time in production.

Give a stand-in like this a name and a look that say what it is. The twin's page has "NOT THE REAL PRINTFUL" in its header for a reason.

The twin itself took a day and about 500 lines. Most of that day went into the bugs it uncovered, not into the twin. Next time I would build it before the feature, not after: I wrote the shipping part first and could only check it by hand, and all three bugs sat right behind that shortcut.

Share
Mariusz Smenżyk
Written by

Mariusz Smenżyk

Builder for sport. Make. Test. Launch.

Related notes