Commit f2caa3b
feat: add cross-platform subscriptionBillingIssue event (#99)
## Summary
Unifies StoreKit 2's `Message.Reason.billingIssue` (iOS 18+ / Mac
Catalyst 18+) and Google Play Billing's `Purchase.isSuspended` (Play
Billing 8.1+) into a single cross-platform event —
`subscriptionBillingIssue`. Apps now get one listener that fires on
either platform when a user's active subscription needs attention due to
a payment problem.
Every downstream library, both example apps, the react-native-iap
`useIAP` hook, a feature docs page, and a Horizon no-op unit test land
in this PR.
## What's in this PR
### Schema (`packages/gql`)
- New `IapEvent.SubscriptionBillingIssue` enum value in `type.graphql`.
- New `subscriptionBillingIssue: Purchase!` field on `Subscription` in
`event.graphql`.
- All generated types regenerated: `Types.swift`, `Types.kt`,
`types.ts`, `types.dart`, `types.gd`, and all 5 downstream library type
mirrors.
### iOS (`packages/apple`)
- `subscriptionBillingIssueListener` added to `OpenIapModuleProtocol`,
`OpenIapModule`, `OpenIapModule+ObjC`, and `IapState`.
- `startMessageListener()` spins up a `StoreKit.Message.messages` loop
on init. Gated to iOS 18+ / Mac Catalyst 18+ (where
`Message.Reason.billingIssue` exists). macOS / tvOS / watchOS / visionOS
are silent no-ops (Message API not available on those platforms).
- On `.billingIssue`, batches a single `StoreKit.Product.products(for:)`
call for all current auto-renewable entitlements, then iterates each
subscription's full status array, emitting one event per subscription
whose renewal state is `.inBillingRetryPeriod` or `.inGracePeriod`.
### Android Play flavor (`packages/google/.../play`)
- `addSubscriptionBillingIssueListener` /
`removeSubscriptionBillingIssueListener` implemented with thread-safe
`CopyOnWriteArraySet` + `ConcurrentHashMap.newKeySet()` so add/remove on
the main thread is safe against iteration from `Dispatchers.IO`.
- Emission hook runs both in `getAvailablePurchases` (always queries
`includeSuspended=true` so suspended purchases reach the notifier even
when the caller opted not to include them in the returned list) and in
`onPurchasesUpdated` (push path, parity with iOS).
- Deduplicated per session by `purchaseToken`.
### Android Horizon flavor (`packages/google/.../horizon`) — explicit
no-op + automated guarantee
- Both `add`/`remove` are implemented as no-ops with `Log.w` warnings.
Horizon Billing Compatibility SDK targets Play Billing 7.0 which does
not expose `isSuspended`. The listener interface exists for API parity
but never fires on Horizon.
- **`SubscriptionBillingIssueHorizonNoOpTest`** (Robolectric) asserts
the callback is never invoked, guarding against accidental Play-flavor
logic leaking into Horizon. Runs on CI via
`:openiap:testHorizonDebugUnitTest`.
### Downstream library bridges
| Library | What landed |
|---------|-------------|
| **react-native-iap** | Nitro spec
(`add/removeSubscriptionBillingIssueListener`), regenerated nitrogen
bridge, Swift + Kotlin implementations, public
`subscriptionBillingIssueListener()` JS API, **`useIAP({
onSubscriptionBillingIssue })` hook callback** |
| **expo-iap** | `OpenIapEvent.SubscriptionBillingIssue` enum,
`EventPayloads` mapping, `subscriptionBillingIssueListener()` JS API,
Kotlin event emission via `ExpoIapHelper.setupListeners`, Swift event
emission via `ExpoIapHelper.setupListeners` |
| **flutter_inapp_purchase** | Dart `subscriptionBillingIssueListener`
`Stream<Purchase>` on `FlutterInappPurchase`, Android method-channel
forwarding, iOS method-channel forwarding |
| **godot-iap** | GDScript `subscription_billing_issue(purchase)`
signal, Android AAR `SignalInfo` + listener registration, iOS
GDExtension `@Signal` + listener registration |
| **kmp-iap** | `subscriptionBillingIssueListener: Flow<Purchase>` in
`commonMain`, Android backing `MutableSharedFlow` + emission inside
`getAvailablePurchasesHandler`, iOS backing flow + cinterop subscription
via `openIapModule.addSubscriptionBillingIssueListener` |
### Example apps (manual-test ready)
- **`packages/apple/Example`** — `SubscriptionFlowScreen` renders an
orange "Subscription needs attention" banner with a `Fix payment method`
button that calls `OpenIapModule.shared.deepLinkToSubscriptions(nil)`.
Listener registered in `setupIapProvider`, torn down on screen dispose.
- **`packages/google/Example`** — Compose LazyColumn gains an analogous
banner registered via `DisposableEffect(iapStore)`, dispatching
`iapStore.deepLinkToSubscriptions` with the failing purchase's SKU +
package name. `OpenIapStore` now exposes
`add/removeSubscriptionBillingIssueListener` pass-through so Compose
callers don't have to reach the underlying `OpenIapProtocol`.
### Documentation
- **Feature page**:
`packages/docs/src/pages/docs/features/subscription-billing-issue.tsx` —
new `/docs/features/subscription-billing-issue` route + sidebar entry.
Platform-behavior table with min versions, recommended UX, per-language
usage snippets (RN/expo, Flutter, Godot, KMP), deduping semantics.
- **Release notes**: `packages/docs/src/pages/docs/updates/releases.tsx`
entry for 2026-04-16.
- **Sandbox E2E guide**:
`knowledge/internal/sandbox-subscription-billing-issue.md` —
step-by-step for iOS 18 sandbox (billing issue toggle / remove payment
method) and Play 8.1+ sandbox (remove payment method / Play Console test
suspensions). Includes a per-library smoke matrix using
`libraries-versions.jsonc "local"` mode.
- **External API docs drift fixes**:
`knowledge/external/storekit2-api.md` (Message API,
eligibleWinBackOfferIDs, Transaction iOS 18.4 fields, iOS 17.4
correction), `google-billing-api.md` (External Payments 8.3+),
`horizon-api.md` (accessToken field + hyphenation).
- **llms**: `knowledge/_claude-context/context.md` +
`packages/docs/public/llms{,-full}.txt` recompiled.
## Verification (every target compiled locally before push)
| Target | Command | Result |
|--------|---------|--------|
| apple package | `swift build` + `swift test` (87 tests) | OK |
| google Play | `gradlew :openiap:compilePlayDebugKotlin` | OK |
| google Horizon | `gradlew :openiap:compileHorizonDebugKotlin` | OK |
| google Horizon test | `gradlew :openiap:testHorizonDebugUnitTest` | OK
(Robolectric no-op assertion passes) |
| google Example | `gradlew :example:compilePlayDebugKotlin` | OK |
| react-native-iap | `yarn specs` + `yarn tsc --noEmit -p
tsconfig.build.json` | OK |
| expo-iap | `bun run tsc --noEmit` | OK |
| flutter_inapp_purchase | `flutter analyze` | OK |
| kmp-iap | `gradlew :library:compileCommonMainKotlinMetadata
compileDebugKotlinAndroid` | OK |
| docs | `tsc --noEmit` + `prettier --check` | OK |
CI is green across all workflows.
## Release plan
All five downstream libraries pick this up as a **minor** version bump
(new feature, additive, non-breaking). Version bumps + releases happen
per-library after merge through their usual release workflows.
## Test plan
- [x] Regenerate types in all 5 downstream libraries and confirm compile
still green (rn-iap + expo-iap typecheck, flutter analyze, kmp-iap
compile, apple swift test — all green locally and on CI).
- [x] Horizon flavor exposes the listener as an explicit no-op:
automated by `SubscriptionBillingIssueHorizonNoOpTest` (Robolectric). CI
runs `:openiap:testHorizonDebugUnitTest`.
- [x] Horizon + Play flavors both compile with the new public API.
- [x] `deepLinkToSubscriptions` flow resolves on both platforms
(existing API, unchanged; referenced from the new feature page and wired
in both example app banners).
- [ ] Live iOS 18 sandbox billing-issue message — manual run by release
QA. Procedure documented in
`knowledge/internal/sandbox-subscription-billing-issue.md`.
- [ ] Live Play 8.1+ sandbox suspended subscription — manual run by
release QA. Same document, Android section.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Cross-platform "subscription billing issue" event: notifies when
active subscriptions need user attention (iOS 18+, Play Billing 8.1+).
Exposed across Expo, React Native, Flutter, Godot, KMP and examples
include a user-facing "Subscription needs attention" banner and listener
APIs.
* **Documentation**
* New feature guide, API listener usage, recommended UX (deep-linking to
subscription management), sandbox QA workflow, and release-note entry.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 0cffffd commit f2caa3b
75 files changed
Lines changed: 5124 additions & 607 deletions
File tree
- knowledge
- _claude-context
- external
- internal
- libraries
- expo-iap
- android/src/main/java/expo/modules/iap
- ios
- src
- flutter_inapp_purchase
- android/src/main/kotlin/io/github/hyochan/flutter_inapp_purchase
- ios/Classes
- lib
- test
- godot-iap
- addons/godot-iap
- android/src/main/java/dev/hyo/godotiap
- ios-gdextension/Sources/GodotIap
- kmp-iap/library/src
- androidMain/kotlin/io/github/hyochan/kmpiap
- androidUnitTest/kotlin/io/github/hyochan/kmpiap
- commonMain/kotlin/io/github/hyochan/kmpiap
- openiap
- iosMain/kotlin/io/github/hyochan/kmpiap
- react-native-iap
- android/src/main/java/com/margelo/nitro/iap
- example/ios
- example.xcodeproj
- exampleTests
- ios
- src
- __tests__
- hooks
- hooks
- specs
- packages
- apple
- Example/OpenIapExample/Screens
- Sources
- Helpers
- Models
- Tests/OpenIapTests
- docs
- public
- src/pages
- docs
- features
- updates
- google
- Example/src/main/java/dev/hyo/martie/screens
- openiap
- src
- horizon/java/dev/hyo/openiap
- main/java/dev/hyo/openiap
- helpers
- listener
- store
- play/java/dev/hyo/openiap
- testHorizon/java/dev/hyo/openiap
- testPlay/java/dev/hyo/openiap
- gql/src
- generated
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
378 | 430 | | |
379 | 431 | | |
380 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
196 | | - | |
| 195 | + | |
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
| 199 | + | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
226 | 234 | | |
227 | 235 | | |
228 | 236 | | |
| |||
272 | 280 | | |
273 | 281 | | |
274 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
275 | 302 | | |
276 | 303 | | |
277 | 304 | | |
| |||
283 | 310 | | |
284 | 311 | | |
285 | 312 | | |
286 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
287 | 368 | | |
288 | 369 | | |
289 | 370 | | |
| |||
Lines changed: 136 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
0 commit comments