donutshop is a simple way to connect a juicebox project to a printful store
built with:
Important
This is still a work in progress. Product images and printful products are hardcoded. The next steps are to make these dynamic and configurable.
- Clone the repo
npm install
cp blank.env.local .env.local
- Create a printful account and store
- Login with same account and create printful private token (help)
- Name the token, add an email (required), set expiration date, and set minimum scopes shown below, add to
.env.local
(help) - Create a wallet connect project and add to
.env.local
- Create an infura API key and add to
.env.local
- Create a upstash redis instance and add to
.env.local
(used to track order nonces) - Set the
NEXT_PUBLIC_JUICEBOX_PROJECT_ID
in.env.local
to the juicebox project id (help) - Deploy!
sequenceDiagram
participant C as Checkout
participant I as Initialize Order API
participant J as Juicebox
participant P as Place Order API
participant F as Printful API
C->>I: Request orderIdObj
I->>I: Generate id
I->>I: hmac(id, SECRET)
I-->>C: { id, idHash }
C->>J: pay(..., memo = idHash)
J-->>C: { txnHash }
C->>P: { txnHash, id, shippingAddress }
P->>J: Fetch transaction details
P->>P: check id = hmac(id, SECRET)
P->>F: check order doesn't exist
F-->>P: order doesn't exist
P->>F: Place order with id
F-->>P: order placed information
P-->>C: Confirm order placed