Verify purchases
Verify in-app purchases server-side from any Node service.
Before granting access
Create your products in App Store Connect and Google Play Console and configure them for your own app build. BDK Preview does not use your store products; test purchases in your own build with the stores’ test accounts.
A matching product id or isValid: true alone must never grant access. Bind each verified transaction to the authenticated account. Check the app and product identity, current purchase state and revocation, and prevent replay or reuse across accounts. Track subscription expiry separately from one-time entitlements; a one-time unlock does not have a subscription expiry.
The helpers below verify or read receipt data. They do not implement a complete entitlement service. verifyIosReceipt does not verify StoreKit 2 JWS transactions. Full StoreKit 2 and Google Play verification recipes are coming; follow the stores’ current verification guidance before granting access.
Verify a Google Play purchase
Confirm a purchase token with Google Play. Authenticate with a service account or access token, passed in the call or via BDK_GOOGLE_PLAY_SERVICE_ACCOUNT_JSON / BDK_GOOGLE_PLAY_ACCESS_TOKEN. Returns { isValid, payload, errorMessage, raw }.
Check a subscription before granting
isValid: true only means the token was accepted — not that the user owns the product. Use readAndroidReceipt(input) to read purchase state, acknowledgement state, and expiry before granting anything.
The expiry check below is for a subscription. It is not a one-time-product unlock recipe. Verification also needs authenticated account binding, the expected app and product, transaction replay protection and current revocation/refund handling. Do not grant access merely because a receipt parses or a product ID matches.
Never grant an entitlement off isValid alone. An expired or unacknowledged purchase can still report isValid: true.
Verify one-time products separately
A one-time product does not use subscription expiry. Verify its current purchase state with the store on your backend and bind it to the authenticated user. Do not copy the subscription expiry condition for an unlock. A newly paid purchase may still need acknowledgement; handle that as part of the store-specific fulfillment flow, not as proof of a different customer’s entitlement. Use the store’s current verification guidance for signed transactions; the receipt helper is not a StoreKit 2 JWS verifier.
Consume a one-time product
Mark a consumable product as consumed so it can be purchased again.
Verify an App Store receipt
Validate an iOS receipt with Apple. Pass the base64 receipt, and your sharedSecret (or set BDK_IOS_INAPP_SHARED_SECRET). A production receipt that Apple flags as sandbox is retried against the sandbox endpoint automatically; set useSandboxFallback: false to opt out. Returns { isValid, resultData, errorData, raw } — resultData holds Apple's full response on success, errorData the failure reason.
Read an App Store entitlement
isValid: true means Apple accepted the receipt, not that the entitlement is live. Pass the verification's resultData to readIosReceipt(input) to pull the latest purchase for a product — its purchase, original-purchase, and expiry timestamps — before granting.
Verify inside an Express route
These are plain async functions, so they drop into any handler — Express, a Next API route, a Firebase Function, or any Node service.
See every native feature with its demo on thebdk.com.