OneShot

All packsProduct Feed & Merchant Center ComplianceSolve

gtin check digit algorithm wrong for gtin-8 gtin-12

A GS1 check digit written left-to-right is wrong for three of four GTIN lengths

Weighting a GTIN check digit 3,1,3,1... from the left instead of the right is correct for exactly one length and silently wrong for GTIN-8, GTIN-12 and GTIN-14.

This is one of the things Product Feed & Merchant Center Compliance already handles. Get your products into Google Shopping and keep them from being rejected.

Buy for $1292 of 3 clean-room builds passed · full refund if it fails on your machine

Is this you?

A GS1 check-digit implementation that reverses the payload once and hardcodes which end the 3,1,3,1... weighting starts from works for whichever single GTIN length it was tested against, and silently computes a wrong check digit for the other three -- a restricted-prefix GTIN (2..., 02..., 04...) is also arithmetically valid, so a checksum-only validator waves it straight through to a real Merchant Center rejection.

Why this one is easy to get wrong

The GS1 algorithm is usually demonstrated with one worked example at one fixed length, and generalizing "weight alternating digits 3 and 1" without reversing the payload first looks like a faithful implementation of that example -- it produces the right answer for the demonstrated length and a wrong one everywhere else, with no error to reveal the gap.

What you get instead

gs1CheckDigit reverses the payload, weights 3,1,3,1... from the right, sums, and takes (10 - sum % 10) % 10 -- written this way it is correct for GTIN-8, 12, 13 and 14 with one implementation, not four. checkGtin then runs checks in a fixed order (not-numeric, then ISBN-10, then length, then check digit, then restricted prefix, then coupon prefix) so a 10-digit ISBN gets a message that says 'convert to ISBN-13' instead of a generic length error.

Source: ARCHITECTURE.md 'GTIN' — checkable in the pack you receive

How you actually use this

You don’t install a library or wire up an SDK. Your own coding agent builds the code in your project, and you keep it — no runtime dependency on us.

  1. Step 1

    Download and unzip

    You get a folder: the docs that tell an agent what to build, a starting skeleton, and the test suite that decides when it's done.

  2. Step 2

    Open it in Claude Code or Cursor

    Point your coding agent at the folder. Nothing to install, no account with us, no API key.

  3. Step 3

    Paste one prompt

    The pack contains the exact prompt. Paste it as your first message and leave it alone — it works through the build itself, choosing a cheaper or stronger model per task.

  4. Step 4

    Run ./verify.sh

    One command. It prints a pass or fail for every check. Green means the build is done — the same script we ran to produce the receipt on this page.

Typical build: about 44 minutes of your agent working, mostly unattended. Then you integrate the working module into your app the way you would any code you’d written yourself.

Why you can believe this

2 of 3 runs passed

We ran this pack from an empty folder 3 times and published exactly what happened — every check, the model, the token cost, the wall time. Not a testimonial, and not our opinion: the same verify.sh you run yourself. Read the full receipt →

Buy for $12914-day refund if verify.sh fails →

Related problems