You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add onError callback to useIAP and pass subscriptionProductReplacementParams (#3128)
## Summary
- Add `onError` callback to `UseIapOptions` for handling non-purchase
errors (fetchProducts, getAvailablePurchases, getActiveSubscriptions,
restorePurchases)
- Fix `subscriptionProductReplacementParams` not being passed to native
module in `requestPurchase` for Android subscription replacements
- Add comprehensive tests for both fixes
- Update documentation (use-iap.md, llms.txt, llms-full.txt)
- Remove unused `shouldAutoSyncPurchases` from docs
## Test plan
- [x] Run `yarn typecheck` - passes
- [x] Run `yarn lint` - passes
- [x] Run `yarn test` - all 187 tests pass
- [x] Added tests for `onError` callback (7 new tests)
- [x] Added tests for `subscriptionProductReplacementParams` (3 new
tests)
## Related Issues
Fixes related to expo-iap#303 and expo-iap#304
🤖 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**
* Added an onError callback option to surface non-purchase operation
errors (e.g., product fetches, availability checks).
* Added support for Android subscription replacement parameters to
enable custom upgrade/downgrade behavior in purchase requests.
* **Documentation**
* API docs updated with the new onError option, examples showing onError
and purchase-error handling, and guidance for the Android subscription
replacement parameter.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
-**Description**: Called when non-purchase operations fail (e.g., `fetchProducts`, `getAvailablePurchases`, `getActiveSubscriptions`, `restorePurchases`). Use this callback to handle errors from query operations that are not related to the purchase flow itself.
- **Auto-connects**: Calls `initConnection()` on mount, `endConnection()` on unmount
137
137
- **Void-returning methods**: `fetchProducts`, `requestPurchase`, `getAvailablePurchases` return `Promise<void>` and update internal state
138
138
- **Use callbacks**: Always handle purchases via `onPurchaseSuccess` and `onPurchaseError`
139
+
- **Error handling**: Use `onPurchaseError` for purchase-related errors and `onError` for non-purchase errors (fetchProducts, getAvailablePurchases, etc.)
0 commit comments