Verify purchases
Verify in-app purchases server-side from any Node service.
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 entitlement 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.
Never grant an entitlement off isValid alone. An expired or unacknowledged purchase can still report isValid: true.
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.