-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[In_app_purchases] migrate to Play Billing Library 2.0. #2287
Changes from 1 commit
e4c9796
d47ae9c
a10b0ea
7fec09a
1d41afc
4549dc0
37df4a4
b0b69e5
4959ffb
a44756f
fb8655e
e815b17
61c5771
d63cc13
3b3c67e
e610421
a3239f7
215086f
33576c7
a3a576c
6f2c821
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -366,12 +366,14 @@ class _MyAppState extends State<MyApp> { | |||
| } else { | ||||
| if (purchaseDetails.status == PurchaseStatus.error) { | ||||
| handleError(purchaseDetails.error); | ||||
| return; | ||||
|
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. Also on iOS completePurchase() needs to be called for status == PurchaseStatus.error. With this change this will be broken. Please refer to completePurchase documentation. plugins/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart Line 197 in ed7620c
|
||||
| } else if (purchaseDetails.status == PurchaseStatus.purchased) { | ||||
| bool valid = await _verifyPurchase(purchaseDetails); | ||||
| if (valid) { | ||||
| deliverProduct(purchaseDetails); | ||||
| } else { | ||||
| _handleInvalidPurchase(purchaseDetails); | ||||
| return; | ||||
|
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. I am guessing this will have the same impact as line 374. |
||||
| } | ||||
| } | ||||
| if (Platform.isAndroid) { | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,8 @@ import 'package:json_annotation/json_annotation.dart'; | |
| part 'enum_converters.g.dart'; | ||
|
|
||
| /// Serializer for [BillingResponse]. | ||
| /// | ||
| /// Use these in `@JsonSerializable()` classes by annotating them with | ||
| /// `@BillingResponseConverter()`. | ||
| // Use these in `@JsonSerializable()` classes by annotating them with | ||
|
||
| // `@BillingResponseConverter()`. | ||
| class BillingResponseConverter implements JsonConverter<BillingResponse, int> { | ||
| const BillingResponseConverter(); | ||
|
|
||
|
|
@@ -24,9 +23,8 @@ class BillingResponseConverter implements JsonConverter<BillingResponse, int> { | |
| } | ||
|
|
||
| /// Serializer for [SkuType]. | ||
| /// | ||
| /// Use these in `@JsonSerializable()` classes by annotating them with | ||
| /// `@SkuTypeConverter()`. | ||
| // Use these in `@JsonSerializable()` classes by annotating them with | ||
| // `@SkuTypeConverter()`. | ||
| class SkuTypeConverter implements JsonConverter<SkuType, String> { | ||
| const SkuTypeConverter(); | ||
|
|
||
|
|
@@ -47,9 +45,8 @@ class _SerializedEnums { | |
| } | ||
|
|
||
| /// Serializer for [PurchaseStateWrapper]. | ||
| /// | ||
| /// Use these in `@JsonSerializable()` classes by annotating them with | ||
| /// `@PurchaseStateConverter()`. | ||
| // Use these in `@JsonSerializable()` classes by annotating them with | ||
| // `@PurchaseStateConverter()`. | ||
| class PurchaseStateConverter | ||
| implements JsonConverter<PurchaseStateWrapper, int> { | ||
| const PurchaseStateConverter(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,12 +131,12 @@ class PurchaseDetails { | |
| if (_platform == _kPlatformIOS) { | ||
| if (status == PurchaseStatus.purchased || | ||
| status == PurchaseStatus.error) { | ||
| pendingCompletePurchase = true; | ||
| _pendingCompletePurchase = true; | ||
| } | ||
| } | ||
| if (_platform == _kPlatformAndroid) { | ||
| if (status == PurchaseStatus.purchased) { | ||
| pendingCompletePurchase = true; | ||
| _pendingCompletePurchase = true; | ||
| } | ||
| } | ||
| _status = status; | ||
|
|
@@ -157,11 +157,13 @@ class PurchaseDetails { | |
| /// This is null on Android. | ||
| final PurchaseWrapper billingClientPurchase; | ||
|
|
||
| /// The developer has to call [InAppPurchaseConnection.completePurchase] if the value is `true`. | ||
| /// The developer has to call [InAppPurchaseConnection.completePurchase] if the value is `true` | ||
| /// and the product has been delivered to the user. | ||
| /// | ||
| /// The initial value is `false`. | ||
| /// * See also [InAppPurchaseConnection.completePurchase] for more details on completing purchases. | ||
| bool pendingCompletePurchase = false; | ||
| bool get pendingCompletePurchase => _pendingCompletePurchase; | ||
| bool _pendingCompletePurchase = false; | ||
|
|
||
| // The platform that the object is created on. | ||
| // | ||
|
|
@@ -190,9 +192,9 @@ class PurchaseDetails { | |
| ? (transaction.transactionTimeStamp * 1000).toInt().toString() | ||
| : null, | ||
| this.skPaymentTransaction = transaction, | ||
| this.billingClientPurchase = null { | ||
| this.status = SKTransactionStatusConverter() | ||
| .toPurchaseStatus(transaction.transactionState); | ||
| this.billingClientPurchase = null, | ||
| _status = SKTransactionStatusConverter() | ||
| .toPurchaseStatus(transaction.transactionState) { | ||
| _platform = _kPlatformIOS; | ||
|
||
| } | ||
|
|
||
|
|
@@ -206,9 +208,9 @@ class PurchaseDetails { | |
| source: IAPSource.GooglePlay), | ||
| this.transactionDate = purchase.purchaseTime.toString(), | ||
| this.skPaymentTransaction = null, | ||
| this.billingClientPurchase = purchase { | ||
| this.status = | ||
| PurchaseStateConverter().toPurchaseStatus(purchase.purchaseState); | ||
| this.billingClientPurchase = purchase, | ||
| _status = | ||
| PurchaseStateConverter().toPurchaseStatus(purchase.purchaseState) { | ||
| _platform = _kPlatformAndroid; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| author: Flutter Team <[email protected]> | ||
| homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase | ||
| version: 0.2.2+2 | ||
| version: 0.3.0 | ||
|
|
||
|
|
||
| dependencies: | ||
|
|
||
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.
nit: