Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[in_app_purchase] fix "autoConsume" param in "buyConsumable" #3957

Merged
merged 4 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/in_app_purchase/in_app_purchase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2

* Fix ignoring "autoConsume" param in "InAppPurchase.instance.buyConsumable".

## 1.0.1

* Migrate maven repository from jcenter to mavenCentral.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/in_app_purchase/in_app_purchase/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
version: 1.0.2

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, <Matcher>[
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, <Matcher>[
isMethodCall('buyConsumable', arguments: null),
isMethodCall('buyConsumable', arguments: {
"purchaseParam": purchaseParam,
"autoConsume": false,
}),
]);
});

Expand Down Expand Up @@ -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);
}

Expand Down