Section 10 of 14
Verification
What This Does
After pushing corrected customs values to ShipStation, we read them back via the API and compare what we sent vs what ShipStation actually saved. This trust-but-verify approach catches any issues where ShipStation silently rejected or modified our values.
Why It Matters
Just because we sent corrected values doesn't mean ShipStation saved them. APIs can silently drop fields, round differently, or reject updates. Verification is our safety net — it confirms the customs forms will actually show the correct values when printed.
How It Works
- 1.We call getOrder() on ShipStation to read the customs items back.
- 2.We compare each item by matching on description + HS code + country of origin + quantity.
- 3.We compare the customs VALUE with a $0.02 tolerance (to allow for minor rounding differences in ShipStation's system).
- 4.If everything matches: VERIFIED. If any mismatch: MISMATCH. If the read-back API call fails: UNVERIFIED.
- 5.VERIFIED orders are marked COMPLETED. MISMATCH/UNVERIFIED orders are marked COMPLETED_UNVERIFIED.
The Code
Key Decisions
- ●We match items by description+tariff+country+quantity rather than by index position, because ShipStation might reorder items.
- ●$0.02 tolerance allows for minor floating point differences in ShipStation's internal storage.
- ●Both MISMATCH and UNVERIFIED result in COMPLETED_UNVERIFIED — the correction was attempted, but we can't confirm it worked.
What Could Go Wrong
- ●If ShipStation's API is temporarily down when we try to verify, the order becomes UNVERIFIED. The correction likely succeeded, but we can't confirm.
- ●If ShipStation silently rounded our values, the verification might show a small mismatch within tolerance — which would still pass.