Skip to content

[in_app_purchase_storekit] Add support for purchase and transactions #7574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Oct 7, 2024

Conversation

LouiseHsu
Copy link
Contributor

@LouiseHsu LouiseHsu commented Sep 3, 2024

This PR contains the preliminary implementations for handling purchases and transactions

Of note, as of StoreKit 2, the result of a call to a purchase will only return a Transaction when the purchase is successful. If the status of purchase is pending, or cancelled, nothing will be returned.

This is in contrast to StoreKit 1, where developers could check the state of a Transaction with TransactionState. This means that migrating to StoreKit 2 will require developers to update their handling of transactions accordingly.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@LouiseHsu LouiseHsu changed the title pigeon stuff [in_app_purchase_storekit] Add support for purchase and transactions Sep 4, 2024
@LouiseHsu LouiseHsu marked this pull request as ready for review September 27, 2024 18:34
@@ -27,6 +27,10 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI {
// This property is optional, as it requires self to exist to be initialized.
public var paymentQueueHandler: FLTPaymentQueueHandlerProtocol?

// This should be an Task, but Task is on available >= iOS 13
var updateListenerTask: Any?
Copy link
Contributor

Choose a reason for hiding this comment

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

can you try out that getter trick discussed yesterday?

}
case .pending:
completion(
.failure(
Copy link
Contributor

Choose a reason for hiding this comment

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

reduce indentation by combining these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the formatter uncombines these

Copy link
Contributor

Choose a reason for hiding this comment

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

strange. it's clearly less than 100 characters. how's your code like before the formatter?

@MainActor in
do {
let transactionsMsgs = await rawTransactions().map {
$0.convertToPigeon()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use keypath

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Keypath can’t be used on instance methods"

Copy link
Contributor

Choose a reason for hiding this comment

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

oh you are right

}

/// Helper function to cast updateListenerTask to a task
func getUpdateListenerTask() -> Task<(), Never> {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use a getter (rather than a function) in the class definition (rather than extension). And make updateListenerTask private.

@testable import in_app_purchase_storekit

@available(iOS 15.0, macOS 12.0, *)
class StoreKit2TranslatorTests: XCTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

final class

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

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

LGTM after the nits

@LouiseHsu LouiseHsu added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2024
@auto-submit auto-submit bot merged commit 2203d08 into flutter:main Oct 7, 2024
76 checks passed
private var _updateListenerTask: Any?

@available(iOS 13.0, *)
var getListenerTaskAsTask: Task<(), Never> {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can change it in next PR - getter shouldn't have a get prefix. It should be just var updateListenerTask: Task<(), Never>

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 8, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 8, 2024
flutter/packages@bb00d34...8fbf4cd

2024-10-08 engine-flutter-autoroll@skia.org Manual roll Flutter from 0975e61 to ec2e12b (54 revisions) (flutter/packages#7815)
2024-10-08 engine-flutter-autoroll@skia.org Manual roll Flutter from 6bba08c to 0975e61 (1 revision) (flutter/packages#7814)
2024-10-08 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.1.7 to 4.2.1 (flutter/packages#7813)
2024-10-08 10687576+bparrishMines@users.noreply.github.com [interactive_media_ads] Adds remaining methods for internal wrapper of the iOS native `IMAAdsRenderingSettings` (flutter/packages#7745)
2024-10-08 stuartmorgan@google.com [url_launcher] Remove incorrect SMS instructions (flutter/packages#7807)
2024-10-08 engine-flutter-autoroll@skia.org Manual roll Flutter from ead6b0d to 6bba08c (37 revisions) (flutter/packages#7809)
2024-10-07 jtanium@gmail.com [webview_flutter_wkwebview] Support NTLM for authentication (flutter/packages#7670)
2024-10-07 stuartmorgan@google.com Revert "[in_app_purchase_storekit] Add support for purchase and transactions" (flutter/packages#7810)
2024-10-07 louisehsu@google.com [in_app_purchase_storekit] Add support for purchase and transactions (flutter/packages#7574)
2024-10-07 engine-flutter-autoroll@skia.org Manual roll Flutter from fa402c8 to ead6b0d (14 revisions) (flutter/packages#7806)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit that referenced this pull request Oct 17, 2024
…7574 (#7812)

This PR contains the preliminary implementations for handling [purchases](https://developer.apple.com/documentation/storekit/product/3791971-purchase) and [transactions](https://developer.apple.com/documentation/storekit/transaction) 

Of note, as of StoreKit 2, the [result of a call to a purchase will only return a Transaction](https://developer.apple.com/documentation/storekit/product/purchaseresult) when the purchase is successful. If the status of purchase is pending, or cancelled, nothing will be returned. 

This is in contrast to StoreKit 1, where developers could check the state of a Transaction with [TransactionState](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411275-transactionstate). This means that migrating to StoreKit 2 will require developers to update their handling of transactions accordingly. 

Relands #7574
auto-submit bot pushed a commit that referenced this pull request Oct 17, 2024
auto-submit bot pushed a commit that referenced this pull request Oct 17, 2024
…7887)

This PR contains the preliminary implementations for handling [purchases](https://developer.apple.com/documentation/storekit/product/3791971-purchase) and [transactions](https://developer.apple.com/documentation/storekit/transaction) 

Of note, as of StoreKit 2, the [result of a call to a purchase will only return a Transaction](https://developer.apple.com/documentation/storekit/product/purchaseresult) when the purchase is successful. If the status of purchase is pending, or cancelled, nothing will be returned. 

This is in contrast to StoreKit 1, where developers could check the state of a Transaction with [TransactionState](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411275-transactionstate). This means that migrating to StoreKit 2 will require developers to update their handling of transactions accordingly. 

Relands #7574
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: in_app_purchase platform-ios platform-macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants