The flow, step by step
Documents @snap4id-sdk/embed-protocol 1.0.0 · @snap4id-sdk/app-embed 1.0.0 · protocol 1.0
This is what happens on the wire whichever way you host the page. The React Native component performs every host step for you; a native host implements them (see any native app).
sequenceDiagram
autonumber
participant P as Snap4ID page
participant H as Your app (host)
participant S as Store
participant R as Purchase check
participant SV as Snap4ID
H->>P: open https://snap4.id/embed/{partnerId} (shim injected first)
P->>H: hello (trustMode, productIds)
H-->>P: hello reply (platform, consent)
H-->>P: price.result (store price of the product)
P->>SV: upload + process photo
P->>H: job.created
P->>H: purchase.request (productId, paymentRef)
H->>S: buy, bound to paymentRef
S-->>H: purchase + receipt (left unfinished)
H->>R: receipt (via the page, or to your backend)
R->>SV: verify and unlock the job
H-->>P: purchase.result
SV-->>P: job paid, links signed
P->>H: job.completed (orderCode, files)
H->>S: finish the purchase
H->>H: copy the files
P->>H: close
1. Open the page
Section titled “1. Open the page”Your app loads https://snap4.id/embed/{partnerId} (or /embed/{partnerId}/job/{jobId} to reopen a job) full
screen. Before any of the page’s scripts run, it injects the shim, which defines the bridge. Only
https://snap4.id is ever loaded in a release build.
2. Handshake
Section titled “2. Handshake”The page sends hello saying who checks your purchases and naming your product (the store product id per store you gave
Snap4ID at onboarding); your app answers at once with its own hello: platform, app version, the user’s analytics
consent, what the done screen may offer (Save / Share), and optional theme and text overrides. No answer within the
handshake time ⇒ handshake_timeout. Then your app looks up the product’s price in its store and sends it
(price.result) for the order button.
3. Capture and process
Section titled “3. Capture and process”The user takes or picks a photo inside the page (your app grants camera and file-chooser access). The page sends
job.created with the job id, processes the photo and shows the preview and the price. Navigation goes through the
bridge: stepChanged titles your header, canGoBack tells you whether the system back gesture should go to the page
(back) or close the flow.
4. Purchase
Section titled “4. Purchase”The user presses the order button: purchase.request { jobId, productId, paymentRef, storeBinding }. Your app buys
the consumable product with the store binding (App Store appAccountToken, Google Play obfuscatedProfileId), so the
receipt names the job’s payment ref. It keeps the purchase unfinished for now.
5. Check the receipt and unlock
Section titled “5. Check the receipt and unlock”- Snap4ID checks, or our verifier server: your app answers
purchase.result { status: 'succeeded', receipt }; the page posts the receipt to Snap4ID’s verifier, which checks it and unlocks the job. - Your own backend: your app sends the receipt to your backend, which checks it and calls the Partner API
unlock; then your app answerspurchase.result { status: 'succeeded' }without a receipt.
Details, prices and refunds: payments and trust.
6. Deliver
Section titled “6. Deliver”Once paid and every file has a link, the page sends job.completed { jobId, orderCode, artifacts }. That is your
signal to finish the store purchase (when the page had the receipt checked) and to copy the files. Your backend can also receive
the signed job.paid webhook. The done screen then shows the files (or hands over to your UI) and sends close.
What the files are and how to store, show and share them: receiving the files. If the app is killed anywhere in between, the next start picks up: see delivery and recovery.
