From d005281fdbd3c0e97489c27a4c7d0b834cc0bf74 Mon Sep 17 00:00:00 2001 From: Alok Date: Thu, 29 Oct 2026 22:39:47 +0530 Subject: [PATCH 1/2] [in_app_purchase] Fix completePurchase docs that mention a nonexistent PurchaseException Fixes https://github.com/flutter/flutter/issues/118626 --- .../in_app_purchase/in_app_purchase/CHANGELOG.md | 1 + .../in_app_purchase/lib/in_app_purchase.dart | 14 +++++--------- .../CHANGELOG.md | 1 + .../lib/src/in_app_purchase_platform.dart | 14 +++++--------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md index f4479ad2329c..f12c73a14747 100644 --- a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md @@ -1,6 +1,7 @@ ## NEXT * Updates minimum supported SDK version to Flutter 3.41/Dart 3.11. +* Fixes the `completePurchase` docs, which referred to a `PurchaseException` type that does not exist. ## 3.3.1 diff --git a/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart b/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart index 3278d3f9c12f..03f749a02ccb 100644 --- a/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart +++ b/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart @@ -176,15 +176,11 @@ class InAppPurchase implements InAppPurchasePlatformAdditionProvider { /// 2. Any subsequent attempts to buy the same product ID will fail with a purchase /// error indicating a duplicate transaction is pending. /// - /// The method will throw a [PurchaseException] when the purchase could not be - /// finished. Depending on the [PurchaseException.errorCode] the developer - /// should try to complete the purchase via this method again, or retry the - /// [completePurchase] method at a later time. If the - /// [PurchaseException.errorCode] indicates you should not retry there might - /// be some issue with the app's code or the configuration of the app in the - /// respective store. The developer is responsible to fix this issue. The - /// [PurchaseException.message] field might provide more information on what - /// went wrong. + /// 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`. Future completePurchase(PurchaseDetails purchase) => InAppPurchasePlatform.instance.completePurchase(purchase); diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md index 64b57eeb67d3..b8b6b483ab42 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/CHANGELOG.md @@ -1,6 +1,7 @@ ## NEXT * Updates minimum supported SDK version to Flutter 3.41/Dart 3.11. +* Fixes the `completePurchase` docs, which referred to a `PurchaseException` type that does not exist. ## 1.4.1 diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart index 88ab488387f2..235f48681938 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart @@ -166,15 +166,11 @@ abstract class InAppPurchasePlatform extends PlatformInterface { /// > On Android, If you do not call [completePurchase] for a transaction on Android, Google Play /// > will automatically refund and revoke the purchase after 3 days. /// - /// The method will throw a [PurchaseException] when the purchase could not be - /// finished. Depending on the [PurchaseException.errorCode] the developer - /// should try to complete the purchase via this method again, or retry the - /// [completePurchase] method at a later time. If the - /// [PurchaseException.errorCode] indicates you should not retry there might - /// be some issue with the app's code or the configuration of the app in the - /// respective store. The developer is responsible to fix this issue. The - /// [PurchaseException.message] field might provide more information on what - /// went wrong. + /// 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`. Future completePurchase(PurchaseDetails purchase) => throw UnimplementedError('completePurchase() has not been implemented.'); From d4f7bd9a66b7e60477f7f24cf0a69c5616dfefa4 Mon Sep 17 00:00:00 2001 From: Alok Yadav <171165016+Alokxyz1112@users.noreply.github.com> Date: Fri, 30 Oct 2026 01:36:40 +0530 Subject: [PATCH 2/2] Clarify that Android completePurchase failures are not thrown through the app-facing API --- .../in_app_purchase/lib/in_app_purchase.dart | 10 ++++++---- .../lib/src/in_app_purchase_platform.dart | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart b/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart index 03f749a02ccb..3e8d846d34a6 100644 --- a/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart +++ b/packages/in_app_purchase/in_app_purchase/lib/in_app_purchase.dart @@ -177,10 +177,12 @@ class InAppPurchase implements InAppPurchasePlatformAdditionProvider { /// error indicating a duplicate transaction is pending. /// /// 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`. + /// errors are platform specific. On Android a failed acknowledgement is not + /// thrown, so the returned `Future` still completes normally. To read + /// the result, call `completePurchase` on `InAppPurchaseAndroidPlatform` from + /// `in_app_purchase_android` directly, which returns a `BillingResultWrapper` + /// whose `responseCode` reports the failure. On iOS and macOS a failure + /// reported by StoreKit is thrown as a `PlatformException`. Future completePurchase(PurchaseDetails purchase) => InAppPurchasePlatform.instance.completePurchase(purchase); diff --git a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart index 235f48681938..2c0e660d230b 100644 --- a/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/in_app_purchase_platform.dart @@ -167,10 +167,12 @@ abstract class InAppPurchasePlatform extends PlatformInterface { /// > will automatically refund and revoke the purchase after 3 days. /// /// 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`. + /// errors are platform specific. On Android a failed acknowledgement is not + /// thrown, so the returned `Future` still completes normally. To read + /// the result, call `completePurchase` on `InAppPurchaseAndroidPlatform` from + /// `in_app_purchase_android` directly, which returns a `BillingResultWrapper` + /// whose `responseCode` reports the failure. On iOS and macOS a failure + /// reported by StoreKit is thrown as a `PlatformException`. Future completePurchase(PurchaseDetails purchase) => throw UnimplementedError('completePurchase() has not been implemented.');