Payments and trust
Documents @snap4id-sdk/app-embed 1.0.0 · @snap4id-sdk/embed-protocol 1.0.0 · @snap4id-sdk/purchase-verifier 1.0.0 · @snap4id-sdk/partner-api 1.0.0 · protocol 1.0
The user pays you in your app through the App Store or Google Play; you are the merchant of record. Snap4ID releases the files only after the purchase is proven: the unlock.
The binding
Section titled “The binding”Every purchase.request carries a fresh paymentRef (UUID v4). Your app passes it into the store purchase, App Store
appAccountToken or Google Play obfuscatedProfileId (both equal storeBinding in the request). The store signs it
into the receipt, so the receipt proves which job it paid for. A receipt not bound to the ref is refused
(binding_mismatch).
Who checks the purchase
Section titled “Who checks the purchase”Whichever option you choose, a server does the same two steps. It is never done in the app: an app can be modified, and a check inside it would prove nothing.
- Validate the receipt, offline, against your store details. App Store: the StoreKit JWS chains to Apple’s
root certificate, and names your bundle id, one of your products,
appAccountToken= the payment ref, and is not revoked. Google Play:originalJsonverifies with your Play licensing public key, and names your package, one of your products,obfuscatedProfileId= the payment ref, a completed purchase. In both, the store environment must be one you accept. - Ask Snap4ID to unlock the job:
POST /api/v1/partner/jobs/{jobId}/unlock, naming the payment ref, product, transaction id and environment (plus the price; the receipt is attached for audit only), signed with an Ed25519 key registered for your partner id. Snap4ID does not check the receipt again: the signature is what it trusts.
| Snap4ID checks | You check: our verifier server | You check: your own backend | |
|---|---|---|---|
| Receives the receipt | Snap4ID’s verifier, from the page | your verifier server, from the page | your backend, from your app |
| Validates it with | the store details you sent Snap4ID | the store details in your server’s configuration | your code; our verifier library does the checks |
| Calls unlock | Snap4ID’s verifier | your verifier server | your backend |
| Signs that call with | a key Snap4ID holds for your partner id | your Ed25519 key (on your server; public half registered with Snap4ID) | your Ed25519 key (in your secret manager; public half registered with Snap4ID) |
| Snap4ID configures | your store details and product ids | your product ids, your public key, your server’s URL | your product ids, your public key |
| Your code | none | none: configuration only | an endpoint |
| Set up | Snap4ID checks purchases | our verifier server | your own backend |
On every unlock, whoever calls, Snap4ID checks the signature (an active key of your partner), that the job is yours,
that the payment ref was issued for this job, that the product is one of yours, that the environment is allowed and
matches the platform, that the transaction never unlocked another job, and that the job is not already
paid (already_paid: refund that purchase).
Your choice is part of your partner configuration at Snap4ID. The page reports it in hello; the React Native
component compares it with your app (onVerifyPurchase present ⇒ your own backend) and fails with
trust_mode_mismatch if they differ.
Confirm after unlock
Section titled “Confirm after unlock”A consumable store purchase that is finished before the job is unlocked can be lost: if the app is killed in between, the store no longer returns it and nobody can prove the payment. So the purchase stays unfinished until the unlock is known:
- Snap4ID or your verifier server checks: when
job.completedarrives for the job; - your own backend checks: when your backend answered that it unlocked the job.
Then finish (acknowledge / consume) it, once. Libraries that finish purchases on their own (RevenueCat by default) break this: use observer mode, or the component’s built-in store.
Prices
Section titled “Prices”The page shows the store’s localized price for the product on its order button. The product is your in-app purchase
item; Snap4ID has its id per store from your onboarding, so the page names it and your app only looks up its price in
the store (price.result). On iOS the
verifier reads the charged price from the signed transaction; Google Play receipts carry no price, so the host
reports the store price it knows (purchase.result.price).
Duplicates and refunds
Section titled “Duplicates and refunds”If a job is already paid and another purchase arrives for it (for example an “Ask to Buy” approved after the user
bought again), the unlock answers already_paid. The extra purchase is finished so the store stops returning it, and
reported as duplicate_purchase (with paymentRef, plus jobId / transactionId when your app bought it).
Refund it. A transaction that already unlocked another job is refused (transaction_already_used).
Store environments
Section titled “Store environments”Production accepts production receipts only. For App Review, which buys with sandbox receipts against production,
Snap4ID can accept sandbox until a date you agree; it expires by itself. Xcode StoreKit-configuration receipts and
the SDK’s fake receipts are never accepted in production. See test.
