Error codes
Documents @snap4id-sdk/app-embed 1.0.0 · @snap4id-sdk/embed-protocol 1.0.0 · @snap4id-sdk/partner-api 1.0.0 · @snap4id-sdk/purchase-verifier 1.0.0 · protocol 1.0
Four places report a code. Your app sees the first two (onError of the React Native component, or error
messages on a native bridge); your backend sees the last two. A fatal code ends the session.
Bridge error message
Section titled “Bridge error message”Payload { code, fatal, message?, paymentRef? }, in either direction. fatal is fixed per code; message is for
logs only; paymentRef comes only with duplicate_purchase. On a fatal code the component calls
onClose({ reason: 'fatal' }).
| Code | Fatal | Sent by | Meaning | What to do |
|---|---|---|---|---|
embed_unavailable |
yes | page | Your partner embed configuration is missing, disabled or invalid (unknown partner id, unsupported locale or document). Sent right after the page hello, which then has no trustMode. |
Check the partner id; ask Snap4ID to enable embedding for it. |
handshake_timeout |
yes | page | The host never answered the page hello. |
The bridge shim was not injected at document start, or page messages are not forwarded to your code. |
unsupported_protocol |
yes | page, host | The envelope v is not 1, or the other side speaks another protocol major version. |
Update the SDK (or your native host) to the current protocol. |
job_not_found |
yes | page | A resumed job id is unknown or belongs to another partner. | Drop the job from your list. |
processing_failed |
no | page | The photo could not be processed. | Nothing to do: the user can start again in the page, and nothing was charged. |
unlock_rejected |
no | page | The purchase was refused for good (invalid receipt, wrong product or environment, transaction already used). | Do not deliver; check your store setup and the store details Snap4ID holds for you. |
duplicate_purchase |
no | page | The job was already paid with another transaction. Carries paymentRef. |
Refund this purchase. The component reports it to onError with jobId and transactionId. |
artifacts_unavailable |
no | page | The files were still not ready 30 s after payment. | Nothing to do: the page keeps waiting and delivers when they are. |
maintenance |
no | page | Snap4ID is temporarily in maintenance. | Ask the user to try again later. |
invalid_message |
no | page, host | Reply to a message that failed validation and expected an answer. | A bug in the sender: log it with the message type. |
Codes are additive: a new code is a minor protocol version. Treat an unknown non-fatal code as a log line.
Component onError
Section titled “Component onError”@snap4id-sdk/app-embed reports the bridge codes above plus its own (never sent over the bridge). onError gets
{ code, fatal, message?, paymentRef?, jobId?, transactionId? }.
| Code | Fatal | Meaning | What to do |
|---|---|---|---|
trust_mode_mismatch |
yes | onVerifyPurchase is set (your own backend checks) but your configuration has the page check purchases (Snap4ID or your verifier server), or the reverse (the page reports its trust mode in hello). |
Make the app match your setup: choose your setup. |
origin_rejected |
yes | The flow was asked to open a URL outside the origin policy. | Leave origin unset in release builds; in development use 127.0.0.1, 10.0.2.2 or a LAN address. |
configuration_invalid |
yes | The client config is invalid; the message names the field. | Fix the config. |
save_failed |
no | Saving a file failed (permission, storage). | Show your own message. |
share_failed |
no | Sharing a file failed. | Show your own message. |
purchase_callback_failed |
no | Your onPurchaseRequest, onConfirmPurchase or onVerifyPurchase threw. |
Fix the callback. A thrown purchase request counts as failed; the other two are retried. |
orphan_purchase |
no | An unfinished store purchase with no record in the component (for example, app data was cleared). It is left unfinished. | Check it in your store console; refund it if no job was delivered for it. |
storage_corrupt |
no | One of the component’s records was unreadable and set aside. | Report it to Snap4ID support with the job id. |
price_unavailable |
no | The page asked for the store price of your product and the component has none (message names the product id and platform): no id for this store, the store does not know it, or a store error. The page shows no price; the purchase still works. |
Check the product id you gave Snap4ID for this store matches your store product (and that it is active / in your StoreKit file); with your own store code, implement getPrice. |
Purchase verifier
Section titled “Purchase verifier”Snap4ID’s verifier (and our ready-made verifier server)
answers { "error": { "code" } }. The page reports a final refusal as unlock_rejected and already_paid as
duplicate_purchase; retried answers are retried by the page.
| Code | HTTP | Retried | Meaning |
|---|---|---|---|
invalid_receipt |
400 | no | Signature, certificate chain, app, purchase state, or a test receipt where none is accepted. |
binding_mismatch |
400 | no | The receipt is not bound to payment_ref, or the job is not yours. |
unknown_product |
400 | no | The product id is not among the products Snap4ID holds for you. |
environment_not_allowed |
400 | no | The store environment is refused here (for example, sandbox in production without an App Review window). |
payment_ref_mismatch |
400 | no | The payment ref was not issued for this job. |
invalid_request |
400 | no | The request body is malformed. |
unknown_partner |
400 | no | No configuration for this partner id. |
app_check_failed |
401 | no | The page could not prove it is the genuine Snap4ID page. |
origin_not_allowed |
403 | no | The request came from an origin that is not allowed. |
not_found |
404 | no | Unknown path. |
method_not_allowed |
405 | no | Wrong HTTP method for the path. |
transaction_already_used |
409 | no | The transaction already unlocked another job. Do not deliver for it. |
already_paid |
409 | no | The job was paid by another transaction: the page reports duplicate_purchase. Refund this one. |
job_not_payable |
409 | no | The job is not waiting for a store payment. |
request_too_large |
413 | no | The body is over 64 KiB. |
internal_error |
500 | yes | Configuration or key unreadable on the verifier side. |
unlock_failed |
502 | yes | Snap4ID could not be reached to unlock the job. |
Partner API
Section titled “Partner API”Answers { "error": { "code" } }. @snap4id-sdk/partner-api throws one typed error per code
(isPartnerApiError(e, code)), with error.requestId for support; the rows marked client are raised by the client
itself.
| Code | HTTP | What to do |
|---|---|---|
invalid_request |
400 | Fix the request body (the client validates it before sending). |
payment_ref_mismatch |
400 | The payment ref was not issued for this job: send the ref from the same purchase.request. |
unknown_product |
400 | Tell Snap4ID about the new product id (keep retired ones listed for 30 days). |
environment_not_allowed |
400 | Wrong store environment for this deployment, or platform and environment disagree. |
unauthorized |
401 | Key id, key, partner id or clock skew (over 5 minutes). Never retried. |
not_found |
404 | Wrong job id, or not your job. |
transaction_already_used |
409 | The transaction unlocked another job: do not deliver for it. |
already_paid |
409 | The job was paid by another transaction: refund this purchase. |
job_not_payable |
409 | The job does not wait for a store payment: do not charge. |
server_error |
client | Snap4ID answered 5XX after the client’s retries: keep the purchase and retry later. |
timeout |
client | No answer in time after retries: keep the purchase and retry later. |
network |
client | Snap4ID unreachable after retries: keep the purchase and retry later. |
aborted |
client | Your AbortSignal cancelled the call. |
invalid_response |
client | The answer did not match the contract: report it with requestId. |
unexpected_response |
client | A status / code pair outside the contract: report it with requestId. |
invalid_argument |
client | The client was called with invalid arguments (checked before sending). |
