Skip to content

Purchase verifier

Documents @snap4id-sdk/purchase-verifier 1.0.0

The receipt checks of Snap4ID’s verifier, published as @snap4id-sdk/purchase-verifier: as a library for your own backend and as the ready-made verifier server. Snap4ID’s verifier runs at https://snap4.id/verifier. The page calls the HTTP API itself; you call it only when testing your own verifier server.

Method Path
POST /v1/receipts (also /verifier/v1/receipts) verify and unlock
GET /v1/health (also /verifier/v1/health) 200 { "status": "ok", "deployment": "production" | "test" }

Called by the page with Content-Type: application/json and an X-Firebase-AppCheck token; at most 64 KiB.

Field Type Required Description
partner_id string yes Your partner id
job_id string (job id) yes The job being paid
payment_ref string (UUID v4) yes The paymentRef of the purchase.request
receipt Receipt yes app-store, play (or fake on a test deployment)
price Money The host-reported store price (Google Play)
{
"partner_id": "your-partner-id",
"job_id": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"payment_ref": "3b241101-e2bb-4255-8caf-4136c566a962",
"receipt": { "kind": "app-store", "jws": "eyJ…" },
"price": { "amount_minor": 1999, "currency": "PLN" }
}

Success 200 { "status": "paid" } (also for a repeat of the same transaction). Errors { "error": { "code" } } (all codes also in error codes):

Status Code Meaning
400 invalid_receipt signature, chain, app, state, or a test receipt refused
400 binding_mismatch receipt not bound to payment_ref, or the job is not this partner’s
400 unknown_product product not in the partner configuration
400 environment_not_allowed environment refused in this deployment
400 payment_ref_mismatch ref not issued for this job
400 invalid_request, unknown_partner bad body; no configuration for the partner
401 app_check_failed missing / invalid App Check token (or your auth hook refused)
403 origin_not_allowed Origin not in the allow-list
409 transaction_already_used the transaction unlocked another job
409 already_paid paid by another transaction: the page reports duplicate_purchase; refund
409 job_not_payable job not waiting for a store payment
413 request_too_large body over 64 KiB
500 internal_error configuration or key unreadable; retried
502 unlock_failed Snap4ID unreachable; retried

Checks run in order: origin → path / method → authentication → size → body → partner configuration → receipt → unlock key → unlock. CORS: exact allowed origins, POST, GET, headers content-type, x-firebase-appcheck, no credentials.

Your store details in one JSON document: <partner_id>.config.json on a verifier server, config for verifyReceipt on your backend. When Snap4ID checks purchases, Snap4ID writes it from what you send.

{
"partner_id": "your-partner-id",
"apps": {
"ios": { "bundle_id": "pl.example.app", "product_ids": ["pl.example.app.idphoto"] },
"android": {
"package_name": "pl.example.app",
"product_ids": ["pl.example.app.idphoto"],
"play_public_key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA…"
}
},
"allowed_environments": ["production"],
"sandbox_in_prod_until": "2026-12-15T00:00:00Z"
}
Field Rule
partner_id ^[a-z0-9][a-z0-9-]{1,31}$
apps ios and / or android, at least one
apps.ios.bundle_id, apps.android.package_name reverse-DNS app id
apps.*.product_ids non-empty, unique; keep retired ids for 30 days
apps.android.play_public_key base64 RSA public key from the Play Console
allowed_environments of production, sandbox, xcode, test; production deployments refuse xcode / test
sandbox_in_prod_until optional ISO 8601 date-time; sandbox accepted in production until then

Every object is strict: unknown fields make the configuration invalid. JSON Schemas ship in the package under schema/.

Key record <partner_id>.key.json: { "key_id": "<from Snap4ID>", "private_key_pem": "<Ed25519 PKCS#8 PEM>" }.

Export Purpose
verifyReceipt(input, options) offline check: { ok: true, purchase } or { ok: false, code }
choosePrice(storePrice, hostPrice) the price fields of an unlock (signed store price wins)
verifyAndUnlock(request, deps) configuration lookup, verifyReceipt, price, Partner API unlock, answer mapping
createReceiptHandler(deps) framework-neutral HTTP handler (paths, CORS, auth hook, size limit, logging)
createMemoryConfigSource, createFileConfigSource, withCache configuration sources
parseRuntimeConfig(env) deployment policy; refuses an unsafe production setup
PartnerConfigSchema, UnlockKeyRecordSchema, VerificationRequestSchema the formats