In-app purchases
Run App Store and Google Play purchase and consume flows, then read the result from an event.
Read results from events, not the call
Awaiting a bdk.iap.* call only confirms the command was sent — the purchase result arrives later on an event. Subscribe before you call.
Every purchase and consume takes { id, type }: id is the App Store / Play product identifier, and type is "product" (one-time / consumable) or "subscription". Use the Ios / Android method for the device you're on.
The payload key is id, not product_id.
Results from the device are unverified. Treat purchaseSuccess as "the store reported a transaction", then verify the receipt server-side before granting entitlements. See Verify in-app purchases.
Buy a product on iOS
Opens the App Store purchase sheet. The result lands on purchaseSuccess, or purchaseFailed on cancel or error — both carry { platform, data }.
Buy a product on Android
Opens the Google Play purchase sheet. Results surface on the same purchaseSuccess / purchaseFailed events; the platform field tells you which store they came from.
Consume a product so it can be bought again
Use for consumables (coins, lives, refills) — a consumable can't be repurchased until it's consumed.
Consuming on the device only updates local state. The authoritative consume for Google Play happens server-side — see Verify in-app purchases.
IAP events reference
Which event answers which call. Each carries the platform ("ios" or "android") and a data object with the store's purchase details — product id, transaction id, receipt data, and result/error codes. Treat data as the raw store payload and verify it server-side. bdk.on(...) returns an unsubscribe function.
| Event | Fired by |
|---|---|
purchaseSuccess | purchaseIos / purchaseAndroid succeeded |
purchaseFailed | purchase cancelled or errored |
receiptReceived | a store receipt / token was returned |
Verify on the server
The step that actually grants entitlements. Send the data from purchaseSuccess / receiptReceived to your backend and validate it. See Verify in-app purchases for verifyIosReceipt, verifyAndroidReceipt, readAndroidReceipt, and server-side consumeAndroidPurchase.