-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Use case
The in_app_purchase plugin has some some issues when it comes to error handling. Some are documentation issues, others are problems in the code.
There is no good way to catch errors universally for the completePurchase() method in InAppPurchase. On iOS, it throws a PlatformException (or a MissingPluginException since it just calls invokeMethod on a MethodChannel) and on Android it returns a Future<BillingResultWrapper> (though the return type for the platform-independent method is a Future<void>). The documentation for said method says it returns a PurchaseException, when that doesn't even exist (the closest thing I can find is a InAppPurchaseException.
With regards to the restorePurchases() method, it doesn't even document that it can throw an exception (which I think is against the Effective Dart style guide?). On Android, it can throw an InAppPurchaseException and on iOS it can throw an SKError.
Proposal
My proposal is to ensure that all methods are appropriately documented with the exceptions they can throw, namely InAppPurchaseException. I also think there is a good opportunity here to make more specific errors and have InAppPurchaseException become a sealed class instead of having to handle platform-specific error codes.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status