Skip to content

Test your backend

Documents @snap4id-sdk/partner-api 1.0.0 · @snap4id-sdk/purchase-verifier 1.0.0 · @snap4id-sdk/embed-protocol 1.0.0 · protocol 1.0

For when you check purchases: in your own backend (or on our verifier server).

  • Webhook receiver. @snap4id-sdk/embed-protocol/node has the webhook signing helpers and test keys; sign a fixture body and check your receiver accepts it, rejects a tampered body with 401, and answers a repeated event_id with 2xx and no side effect.
  • Signing vectors. The SDK repository’s contracts/ holds signing test vectors for Partner API requests and webhooks: run them against any signing code of your own.
  • Receipts. verifyReceipt with policy: { deployment: 'test', acceptTestReceipts: true } accepts the fake store’s receipts, so your endpoint can be tested end to end without a store. Production code keeps deployment: 'production', acceptTestReceipts: false.
  • End to end. The SDK’s fake Snap4ID page with partner test-backend: your app sends receipts to your backend, your backend unlocks through the page’s Partner API (base URL http://127.0.0.1:8090, signed with the test partner key the page writes to .local/test-keys/partner.ed25519.private.pem in the SDK checkout, key id in .local/test-keys/key-ids.json), and the page sends signed job.paid webhooks to FAKE_SNAP4ID_WEBHOOK_URL. The SDK’s examples/partner-backend runs this way out of the box (its README).

Cases worth a test: unlock success, a repeated unlock (idempotent, same answer), already_paid recorded as a refund, a retryable failure that keeps the purchase pending, and recovery unlocking it later.