Repository navigation
[in_app_purchase] Fix completePurchase docs that mention a nonexistent PurchaseException - #13485
Alokxyz1112 wants to merge 2 commits into
Conversation
…t PurchaseException Fixes flutter/flutter#118626
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for completePurchase in both in_app_purchase and in_app_purchase_platform_interface to remove references to the non-existent PurchaseException and explain platform-specific error handling. The review feedback suggests clarifying that because completePurchase returns Future<void> in the unified API, Android failures are silent and the BillingResultWrapper is only accessible when using the platform-specific implementation directly.
| /// There is no shared exception type for a failed [completePurchase] call, so | ||
| /// errors are platform specific. On Android the returned future completes with | ||
| /// a `BillingResultWrapper` from `in_app_purchase_android`, and a failure is | ||
| /// reported through its `responseCode` instead of being thrown. On iOS and | ||
| /// macOS a failure reported by StoreKit is thrown as a `PlatformException`. |
There was a problem hiding this comment.
Since InAppPurchase.completePurchase returns Future<void>, the returned future for the unified API does not actually complete with a BillingResultWrapper for the caller to inspect. This is only true if they are using the platform-specific InAppPurchaseAndroidPlatform directly. For the unified API, failures on Android are silent (the future completes without throwing). Let's clarify this in the documentation to avoid confusing developers who might expect to be able to access the BillingResultWrapper or its responseCode from the returned Future<void>.
/// There is no shared exception type for a failed [completePurchase] call, so
/// errors are platform specific. On Android, the underlying platform implementation
/// returns a `BillingResultWrapper` (accessible when using `InAppPurchaseAndroidPlatform`
/// directly), but when using this unified `InAppPurchase` API, the returned `Future<void>`
/// completes without throwing an exception. On iOS and macOS, a failure reported
/// by StoreKit is thrown as a `PlatformException`.| /// There is no shared exception type for a failed [completePurchase] call, so | ||
| /// errors are platform specific. On Android the returned future completes with | ||
| /// a `BillingResultWrapper` from `in_app_purchase_android`, and a failure is | ||
| /// reported through its `responseCode` instead of being thrown. On iOS and | ||
| /// macOS a failure reported by StoreKit is thrown as a `PlatformException`. |
There was a problem hiding this comment.
Since InAppPurchasePlatform.completePurchase returns Future<void>, the returned future for the unified API does not actually complete with a BillingResultWrapper for the caller to inspect. This is only true if they are using the platform-specific InAppPurchaseAndroidPlatform directly. For the unified API, failures on Android are silent (the future completes without throwing). Let's clarify this in the documentation to avoid confusing developers who might expect to be able to access the BillingResultWrapper or its responseCode from the returned Future<void>.
/// There is no shared exception type for a failed [completePurchase] call, so
/// errors are platform specific. On Android, the underlying platform implementation
/// returns a `BillingResultWrapper` (accessible when using `InAppPurchaseAndroidPlatform`
/// directly), but when using this unified `InAppPurchasePlatform` API, the returned
/// `Future<void>` completes without throwing an exception. On iOS and macOS, a
/// failure reported by StoreKit is thrown as a `PlatformException`.… the app-facing API
The docs for
completePurchase(in bothin_app_purchaseandin_app_purchase_platform_interface) say it throws aPurchaseExceptionwith anerrorCode, but that type doesn't exist anywhere in the plugin. This replaces that paragraph with what the implementations actually do:InAppPurchaseAndroidPlatform.completePurchase) returns aBillingResultWrapper, so a failed acknowledge shows up in itsresponseCode.InAppPurchaseStoreKitPlatform.completePurchase) callsfinishTransaction/SK2Transaction.finishover Pigeon, which throws aPlatformExceptionon error.Added a line under
## NEXTin both CHANGELOGs since this is a doc only change.Fixes flutter/flutter#118626
Pre-Review Checklist
[shared_preferences]///).Version: doc comment only change, so no version bump, just a
## NEXTentry.Tests: exempt, this only changes doc comments.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2