Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.4+6

* Ensure that purchases correctly indicate whether they are acknowledged or not. The `PurchaseDetails.pendingCompletePurchase` field now correctly indicates if the purchase still needs to be completed.

## 0.1.4+5

* Add `implements` to pubspec.
Expand All @@ -9,7 +13,7 @@

## 0.1.4+3

- Updated installation instructions in README.
* Updated installation instructions in README.

## 0.1.4+2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,19 @@ class GooglePlayPurchaseDetails extends PurchaseDetails {
required this.billingClientPurchase,
required PurchaseStatus status,
}) : super(
productID: productID,
purchaseID: purchaseID,
transactionDate: transactionDate,
verificationData: verificationData,
status: status) {
this.status = status;
productID: productID,
purchaseID: purchaseID,
transactionDate: transactionDate,
verificationData: verificationData,
status: status,
) {
this.pendingCompletePurchase = !billingClientPurchase.isAcknowledged;
}

/// Points back to the [PurchaseWrapper] which was used to generate this
/// [GooglePlayPurchaseDetails] object.
final PurchaseWrapper billingClientPurchase;

late PurchaseStatus _status;

/// The status that this [PurchaseDetails] is currently on.
PurchaseStatus get status => _status;
set status(PurchaseStatus status) {
_pendingCompletePurchase = status == PurchaseStatus.purchased;
_status = status;
}

bool _pendingCompletePurchase = false;
bool get pendingCompletePurchase => _pendingCompletePurchase;

/// Generate a [PurchaseDetails] object based on an Android [Purchase] object.
factory GooglePlayPurchaseDetails.fromPurchase(PurchaseWrapper purchase) {
final GooglePlayPurchaseDetails purchaseDetails = GooglePlayPurchaseDetails(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_android
description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.1.4+5
version: 0.1.4+6

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ void main() {
expect(parsed, equals(expected));
});

test('toPurchaseDetails() should return correct PurchaseDetail object', () {
test('fromPurchase() should return correct PurchaseDetail object', () {
final GooglePlayPurchaseDetails details =
GooglePlayPurchaseDetails.fromPurchase(dummyPurchase);

expect(details.purchaseID, dummyPurchase.orderId);
expect(details.productID, dummyPurchase.sku);
expect(details.transactionDate, dummyPurchase.purchaseTime.toString());
Expand All @@ -84,6 +85,25 @@ void main() {
expect(details.verificationData.serverVerificationData,
dummyPurchase.purchaseToken);
expect(details.billingClientPurchase, dummyPurchase);
expect(details.pendingCompletePurchase, false);
});

test(
'fromPurchase() should return set pendingCompletePurchase to true for unacknowledged purchase',
() {
final GooglePlayPurchaseDetails details =
GooglePlayPurchaseDetails.fromPurchase(dummyUnacknowledgedPurchase);

expect(details.purchaseID, dummyPurchase.orderId);
expect(details.productID, dummyPurchase.sku);
expect(details.transactionDate, dummyPurchase.purchaseTime.toString());
expect(details.verificationData, isNotNull);
expect(details.verificationData.source, kIAPSource);
expect(details.verificationData.localVerificationData,
dummyPurchase.originalJson);
expect(details.verificationData.serverVerificationData,
dummyPurchase.purchaseToken);
expect(details.billingClientPurchase, dummyUnacknowledgedPurchase);
expect(details.pendingCompletePurchase, true);
});
});
Expand Down