From b8cf4c72f790b92e9683fe3447136826c964db9c Mon Sep 17 00:00:00 2001 From: Alexander Zhdanov Date: Fri, 21 May 2021 19:05:12 +0500 Subject: [PATCH 1/3] [in_app_purchase] Fix "autoConsume" param in "buyConsumable" Fixes https://github.com/flutter/flutter/issues/83035 --- .../in_app_purchase/in_app_purchase/lib/in_app_purchase.dart | 1 + 1 file changed, 1 insertion(+) 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 f8547e460b37..4553619af770 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 @@ -162,6 +162,7 @@ class InAppPurchase implements InAppPurchasePlatformAdditionProvider { }) => InAppPurchasePlatform.instance.buyConsumable( purchaseParam: purchaseParam, + autoConsume: autoConsume, ); /// Mark that purchased content has been delivered to the user. From 437ad8d0a23870aa19c97d6675e09259d11de67d Mon Sep 17 00:00:00 2001 From: Alexander Zhdanov Date: Fri, 21 May 2021 21:00:57 +0500 Subject: [PATCH 2/3] [in_app_purchase] add test for InAppPurchase.buyConsumable --- .../test/in_app_purchase_test.dart | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart b/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart index 494c3145c51d..b8c7bd89206b 100644 --- a/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart +++ b/packages/in_app_purchase/in_app_purchase/test/in_app_purchase_test.dart @@ -87,15 +87,33 @@ void main() { }); test('buyConsumable', () async { + final purchaseParam = PurchaseParam(productDetails: productDetails); final bool result = await inAppPurchase.buyConsumable( - purchaseParam: PurchaseParam( - productDetails: productDetails, - ), + purchaseParam: purchaseParam, + ); + + expect(result, true); + expect(fakePlatform.log, [ + isMethodCall('buyConsumable', arguments: { + "purchaseParam": purchaseParam, + "autoConsume": true, + }), + ]); + }); + + test('buyConsumable with autoConsume=false', () async { + final purchaseParam = PurchaseParam(productDetails: productDetails); + final bool result = await inAppPurchase.buyConsumable( + purchaseParam: purchaseParam, + autoConsume: false, ); expect(result, true); expect(fakePlatform.log, [ - isMethodCall('buyConsumable', arguments: null), + isMethodCall('buyConsumable', arguments: { + "purchaseParam": purchaseParam, + "autoConsume": false, + }), ]); }); @@ -152,7 +170,10 @@ class MockInAppPurchasePlatform extends Fake required PurchaseParam purchaseParam, bool autoConsume = true, }) { - log.add(MethodCall('buyConsumable')); + log.add(MethodCall('buyConsumable', { + "purchaseParam": purchaseParam, + "autoConsume": autoConsume, + })); return Future.value(true); } From 8b4465bcfbab51eaac55e006a55f5627cfe79602 Mon Sep 17 00:00:00 2001 From: Alexander Zhdanov Date: Tue, 25 May 2021 12:11:40 +0500 Subject: [PATCH 3/3] update version to 1.0.1 and update CHANGELOG.md --- packages/in_app_purchase/in_app_purchase/CHANGELOG.md | 4 ++++ packages/in_app_purchase/in_app_purchase/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md index c195d685a9c1..a3da5bdc8d85 100644 --- a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1 + +* Fix ignoring "autoConsume" param in "InAppPurchase.instance.buyConsumable". + ## 1.0.0 * Stable release of in_app_purchase plugin. diff --git a/packages/in_app_purchase/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/in_app_purchase/pubspec.yaml index 1668d0567469..79540c2c1070 100644 --- a/packages/in_app_purchase/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play. repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 1.0.0 +version: 1.0.1 environment: sdk: ">=2.12.0 <3.0.0"