-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[in_app_purchase] Return jwsRepresentation and jsonRepresentation for StoreKit2 #9280
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
Changes from 7 commits
8c340b0
d942b58
7224cc7
a339ec7
a9a2c5e
4ab2f23
ada38e4
5f065b5
f747fda
3468ecc
b6bd713
7e9261b
2a1d2a5
221861d
7e4cae2
2d464a8
96aa1d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| ## NEXT | ||
|
|
||
| * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. | ||
| * Add `jwsRepresentation` to `SK2PurchaseDetails` as `serverVerificationData` | ||
| * Add `jsonRepresentation` to `SK2PurchaseDetails` as `localVerificationData` | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason the repo_check is failing is b/c of this - could you add lines 3-5 to a new 0.4.1 version and remove the NEXT?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I updated to 0.4.2 since 0.4.1 just got merged in recently. Hope that is okay 🙏 |
||
| ## 0.4.0 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,8 @@ extension InAppPurchasePlugin: InAppPurchase2API { | |
| case .success(let verification): | ||
| switch verification { | ||
| case .verified(let transaction): | ||
| self.sendTransactionUpdate(transaction: transaction) | ||
| self.sendTransactionUpdate( | ||
| transaction: transaction, receipt: "\(verification.jwsRepresentation)") | ||
|
||
| completion(.success(result.convertToPigeon())) | ||
| case .unverified(_, let error): | ||
| completion(.failure(error)) | ||
|
|
@@ -191,7 +192,8 @@ extension InAppPurchasePlugin: InAppPurchase2API { | |
| for await verificationResult in Transaction.updates { | ||
| switch verificationResult { | ||
| case .verified(let transaction): | ||
| self?.sendTransactionUpdate(transaction: transaction) | ||
| self?.sendTransactionUpdate( | ||
| transaction: transaction, receipt: "\(verificationResult.jwsRepresentation)") | ||
| case .unverified: | ||
| break | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,38 @@ void main() { | |
| purchaseParam: purchaseParam, autoConsume: false), | ||
| throwsA(isInstanceOf<AssertionError>())); | ||
| }); | ||
|
|
||
| test( | ||
| 'buying consumable, should get PurchaseVerificationData with serverVerificationData and localVerificationData', | ||
| () async { | ||
| final List<PurchaseDetails> details = <PurchaseDetails>[]; | ||
| final Completer<List<PurchaseDetails>> completer = | ||
| Completer<List<PurchaseDetails>>(); | ||
| final Stream<List<PurchaseDetails>> stream = | ||
| iapStoreKitPlatform.purchaseStream; | ||
|
|
||
| late StreamSubscription<List<PurchaseDetails>> subscription; | ||
|
||
| subscription = stream.listen((List<PurchaseDetails> purchaseDetailsList) { | ||
| details.addAll(purchaseDetailsList); | ||
| if (purchaseDetailsList.first.status == PurchaseStatus.purchased) { | ||
| completer.complete(details); | ||
| subscription.cancel(); | ||
| } | ||
| }); | ||
| final AppStorePurchaseParam purchaseParam = AppStorePurchaseParam( | ||
| productDetails: | ||
| AppStoreProduct2Details.fromSK2Product(dummyProductWrapper), | ||
| applicationUserName: 'appName'); | ||
| await iapStoreKitPlatform.buyConsumable(purchaseParam: purchaseParam); | ||
|
|
||
| final List<PurchaseDetails> result = await completer.future; | ||
| expect(result.length, 1); | ||
| expect(result.first.productID, dummyProductWrapper.id); | ||
| expect( | ||
| result.first.verificationData.serverVerificationData, 'receiptData'); | ||
| expect(result.first.verificationData.localVerificationData, | ||
| 'jsonRepresentation'); | ||
| }); | ||
| }); | ||
|
|
||
| group('restore purchases', () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a bit color to what are
jwsRepresentationandjsonRepresentation? Also maybe whichjwsRepresentationandjsonRepresentationsince there are several fields with identical names in the StoreKit documentation. The 2 lines seem a bit vague without the context.