Skip to content

[in_app_purchase] Fix completePurchase docs that mention a nonexistent PurchaseException - #13485

Open
Alokxyz1112 wants to merge 2 commits into
flutter:mainfrom
Alokxyz1112:iap-complete-purchase-docs
Open

Alokxyz1112 wants to merge 2 commits into
flutter:mainfrom
Alokxyz1112:iap-complete-purchase-docs

Conversation

@Alokxyz1112

@Alokxyz1112 Alokxyz1112 commented Oct 29, 2026 •

Copy link
Copy Markdown

The docs for completePurchase (in both in_app_purchase and in_app_purchase_platform_interface) say it throws a PurchaseException with an errorCode, but that type doesn't exist anywhere in the plugin. This replaces that paragraph with what the implementations actually do:

  • Android (InAppPurchaseAndroidPlatform.completePurchase) returns a BillingResultWrapper, so a failed acknowledge shows up in its responseCode.
  • iOS/macOS (InAppPurchaseStoreKitPlatform.completePurchase) calls finishTransaction / SK2Transaction.finish over Pigeon, which throws a PlatformException on error.

Added a line under ## NEXT in both CHANGELOGs since this is a doc only change.

Fixes flutter/flutter#118626

Pre-Review Checklist

Version: doc comment only change, so no version bump, just a ## NEXT entry.
Tests: exempt, this only changes doc comments.

Footnotes

  1. 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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +179 to +183
/// 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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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`.

Comment on lines +169 to +173
/// 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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[in_app_purchase] completePurchase docs say that it throws PurchaseException, which does not seem to exist

1 participant