Work SampleSystem Design Document

Order Risk Hold for Imported Shopify Orders

Fraudulent orders reach the warehouse because the ERP never sees Shopify's risk verdict. This document specifies how the ERP stores that verdict, holds risky orders from delivery and records who released them and why.

Author
Nikola Djurovic
Type
System Design Document
Length
23 pages, 5 figures
Date

1.1The Problem

Shopify runs a fraud analysis on every order and returns a risk assessment with a recommendation: accept, investigate or cancel. That output stops at Shopify. The ERP imports the order every 10 minutes with no risk data attached, so the sales manager sees a normal Sales Order and can ship it.

This costs the business twice:

  1. Goods leave the warehouse on orders that are later charged back. The company loses the stock, the shipping cost and the card amount.
  2. Nobody can say who released a suspicious order and why, so chargeback disputes cannot be reconstructed.

The risk information already exists at the moment of import. The ERP does not store it and does not act on it.

1.2Four Scenarios the Design Has to Handle

  • SCENARIO 1

    High Risk Order Ships Today

    Three cameras, EUR 2,480, a card issued in a different country from the shipping address. Shopify says cancel. The order imports as Open, ships the same afternoon, and the chargeback arrives four weeks later.

  • SCENARIO 2

    Medium Risk, No Signal

    Shopify recommends investigating. In the ERP the order looks like every other order, so nobody calls the customer.

  • SCENARIO 3

    Legitimate Customer Flagged

    A returning customer orders while travelling. The sales manager confirms by phone and needs to ship today. The control has to allow that and record who allowed it.

  • SCENARIO 4

    Analysis Not Finished

    The import runs before Shopify completes its analysis and the risk comes back as pending. The order must still import, and it must not be treated as safe.

1.3Requirements

Scope prioritised with MoSCoW. Twelve functional and four non-functional requirements, each with an ID that the acceptance criteria and tests trace back to.

Functional requirements
IDRequirementPriority
FR-01The import stores the Shopify risk assessments, the risk facts and the Shopify recommendation on the imported Sales Order.Must
FR-02The ERP derives a single Risk Level per order from the assessments, using the highest severity returned.Must
FR-03An order with Risk Level High or Medium is set to status Risk Hold at import.Must
FR-04A user cannot create a shipment for an order on hold at High risk.Must
FR-05A user can create a shipment for an order on hold at Medium risk after confirming a warning and entering a reason.Must
FR-06Releasing a High risk hold requires the new Risk Override right. The release records user, timestamp and reason.Must
FR-07Risk fields, assessments and facts are visible on the Sales Order screen, read only.Must
FR-08An order whose risk is pending, missing or not recognised is imported, marked for review and blocked from delivery until the risk resolves.Must
FR-09The restriction is enforced in the order service, so the API and any background job are subject to it, not only the screen.Must
FR-10Risk hold behaviour is driven by settings: which levels hold, whether unknown risk blocks, and which right releases a hold.Should
FR-11A later risk update from Shopify re-evaluates an order that has not shipped yet.Should
FR-12Orders imported before go-live are not held retroactively.Must
Non-functional requirements
IDRequirement
NFR-01The risk evaluation adds no more than 10 percent to the import job's runtime at 1,000 orders per run, so the 10-minute schedule holds.
NFR-02No exception in risk mapping or persistence stops the import run or blocks the import of the order itself.
NFR-03Every hold release goes to the audit log with user, timestamp, previous and new status, and reason, retained for the chargeback dispute window.
NFR-04Risk state is communicated by text and label, not by colour alone.

1.4The Solution in Brief

The import writes Shopify's risk data onto the Sales Order and checks it against the hold settings before the sales manager sees the order.

  • High or Medium risk imports with status Risk Hold. Pending or unreadable risk imports with status Risk Review. Both block delivery. Everything else imports as Open and behaves as it does today.
  • At Medium risk, any user with delivery rights can confirm a warning and record a reason. That matches Shopify's advice to investigate.
  • At High risk, only a user with the Risk Override right can release the hold. That matches Shopify's advice to cancel.
  • The check sits in the order service, so the screen, the API and background jobs all get the same refusal.

Thresholds change with fraud patterns and the season, so hold levels live in settings. A go-live date setting keeps the open order book from freezing on release day.

2.1Diagrams

Each figure opens at full size. Colours follow one legend across the document, and every state is also labelled in text.

Flowchart: Shopify fraud analysis, 10-minute import job, fetch order and risk, create Sales Order, then decisions on whether a risk block was returned, whether values are recognised, whether assessments exist and whether the write succeeded, ending in Risk Hold, Risk Review or Open status in the sales manager's work list.
Figure 1. Order import with risk checks. The first import of an order, including the three exception paths that must never stop the import run (NFR-02).
State diagram: from Risk Level to Risk Review, Risk Hold or Open; Risk Review resolves to Open or Risk Hold; Risk Hold is released to Open with a reason; Open can be upgraded to Risk Hold; Risk Review and Risk Hold can be cancelled; Open ends when delivered and invoiced.
Figure 2. Sales Order status flow. Four statuses and the events that move an order between them. A lower risk level never releases a hold on its own.
Flowchart of a later import run for an order the ERP already holds: if a shipment exists, log and notify only; if cancelled or closed, update risk fields only; otherwise reinsert assessments, recalculate the risk level, and hold the order again if the level increased.
Figure 3. Risk refresh on a later import run. What happens when Shopify updates its verdict after the first import (FR-11).
Clickable Prototype
Figure 4, live. The same screen built to be clicked: switch the Shopify risk level, try to ship, release the hold with and without the Risk Override right, and watch the API calls and audit entries the system writes.
Annotated wireframe of the Sales Order screen with seven numbered new controls: risk banner, Create Shipment button state, status values, Order Risk group, Risk details button, Release Risk Hold button and a new Order Risk tab.
Figure 4. Sales Order screen with the new risk controls. New controls are outlined and numbered, with the behaviour of each one beside the screen. Italic text is UI copy for technical writer review.
Wireframes of the medium risk confirmation dialog with a mandatory reason field, and the read-only Order Risk tab listing provider, risk level, sentiment and fact description.
Figure 5. Medium risk confirmation dialog and the Order Risk tab. Confirm stays disabled until the reason has at least 10 characters.

3Testing Strategy

The feature blocks money moving in one direction and lets a user override the block in the other. Testing weight goes on the rule engine, the permission check and the audit trail. The document defines 9 acceptance criteria, an automated test plan across unit, integration, API contract, performance and regression layers, and a manual plan that ends in UAT sign-off by the sales manager. Two of the acceptance criteria:

AC-02, positive. Medium risk order is delivered with a recorded reason Given an order has Risk Level = Medium and Status = Risk Hold, and the user has delivery rights When the user presses Create Shipment, enters “Customer confirmed by phone” and presses Confirm Then Status becomes Open, the acceptance fields and the reason are stored and shown, the shipment is created, and the audit log holds one entry with the previous status, the new status, the user and the reason

AC-06, negative. Release refused without the right Given an order has Risk Level = High and Status = Risk Hold, and the user does not hold the Risk Override right Then Release Risk Hold is disabled with an explanatory tooltip, a direct call to POST /salesorders/{id}/risk-acceptance returns 403 and writes a security log entry, and a direct call to POST /salesorders/{id}/shipments returns 409 ORDER_RISK_BLOCKED

What Else Is in the Full Document

  • Field mapping from the Shopify Admin GraphQL risk objects to the ERP
  • The rule that derives one Risk Level from several assessments
  • Settings, exception handling and status effects per risk level
  • UI copy for every banner, dialog, tooltip and empty state
  • API endpoints with response codes, and the database changes
  • Simplifications, limitations, bottlenecks and open questions
  • Data examples in an appendix

Need a specification like this for your team? I take freelance B2B contracts with teams worldwide.