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

[In_App_Purchase]queryPastPurchases() shouldn't block transaction updates. #2834

Merged
merged 13 commits into from
Jun 22, 2020
Merged

Conversation

LHLL
Copy link
Contributor

@LHLL LHLL commented Jun 17, 2020

Description

  1. Fix assertion error on SKPaymentQueueWrapper init.
  2. Make sure queryPastPurchases() won't block transaction updates. When the client apps calls queryPastPurchases() right after app launch, they should still receive transaction updates in the purchaseUpdatedStream for transactions with state != restored.
  3. Update fake data to match reality. Only purchased and restored transactions have a transaction identifier.

Related Issues

flutter/flutter#53534

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@LHLL LHLL changed the title Bug fix [In_App_Purchase]queryPastPurchases() shouldn't block transaction updates. Jun 17, 2020
static void enablePendingPurchases() {
_enablePendingPurchase = true;
if (Platform.isIOS) {
// Setting setTransactionObserver to prevent throwing exceptions.
AppStoreConnection.getOrCreateInstance();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just to make the getOrCreateInstance() call a little bit earlier?
Can user just subscribe purchaseUpdatedStream as early as possible as we mentioned in the doc to achieve the same?

Copy link
Contributor Author

@LHLL LHLL Jun 21, 2020

Choose a reason for hiding this comment

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

Updated

## 0.3.5

* Fix the bug that `SKPaymentQueueWrapper.transactions` doesn't return all transactions.
* `enablePendingPurchases` now works on iOS too.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -1,3 +1,8 @@
## 0.3.5
Copy link
Contributor

Choose a reason for hiding this comment

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

Because there is no public API change, this should be 0.3.4+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM modulo nits

## 0.3.4+1

* Fix the bug that `SKPaymentQueueWrapper.transactions` doesn't return all transactions.
* Fix the app crashes if `queryPastPurchases` is called in the `main()`.
Copy link
Contributor

Choose a reason for hiding this comment

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

nits:
maybe add iOS?
Also, i don't think it crashes if queryPastPurchases is called in the main().
It crashes if the InAppPurchaseConnection instance is created on main.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm! THANKS

@LHLL LHLL merged commit 104e9bf into flutter:master Jun 22, 2020
@LHLL LHLL deleted the BugFix branch June 23, 2020 19:34
agent3bood pushed a commit to agent3bood/flutter-plugins that referenced this pull request Jul 10, 2020
…ates. (flutter#2834)

* Allow all transactions except for purchasing ones to be passed back to the Flutter side.

* Restore transactions shouldn't block transaction updates
jorgefspereira pushed a commit to jorgefspereira/plugins_flutter that referenced this pull request Oct 10, 2020
…ates. (flutter#2834)

* Allow all transactions except for purchasing ones to be passed back to the Flutter side.

* Restore transactions shouldn't block transaction updates
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
…ates. (flutter#2834)

* Allow all transactions except for purchasing ones to be passed back to the Flutter side.

* Restore transactions shouldn't block transaction updates
Comment on lines +215 to +218
.add(transactions.where((SKPaymentTransactionWrapper wrapper) {
return wrapper.transactionState !=
SKPaymentTransactionStateWrapper.restored;
}).map((SKPaymentTransactionWrapper transaction) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@LHLL and @cyanglaz

Make sure queryPastPurchases() won't block transaction updates. When the client apps calls queryPastPurchases() right after app launch, they should still receive transaction updates in the purchaseUpdatedStream for transactions with state != restored.

Why did you add this filter and only give transactions that are not restored? Seems like this has resulted in a different bug, see: flutter/flutter#43957 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants