From e9aaffee1ad42aa7055e538f22d19a2fb5b1a578 Mon Sep 17 00:00:00 2001 From: cyanglaz Date: Wed, 6 May 2020 12:20:41 -0700 Subject: [PATCH 1/2] fix --- packages/in_app_purchase/CHANGELOG.md | 4 +++ packages/in_app_purchase/README.md | 28 ++++++++++++++++++- .../in_app_purchase_connection.dart | 3 +- packages/in_app_purchase/pubspec.yaml | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/packages/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/CHANGELOG.md index 647ff0bec4c1..c50133d6899c 100644 --- a/packages/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.3+1 + +* Update documentations for `InAppPurchase.completePurchase` and update README. + ## 0.3.3 * Introduce `SKPaymentQueueWrapper.transactions`. diff --git a/packages/in_app_purchase/README.md b/packages/in_app_purchase/README.md index c366e149bd8d..071e2dd3599e 100644 --- a/packages/in_app_purchase/README.md +++ b/packages/in_app_purchase/README.md @@ -120,6 +120,24 @@ once they're marked as consumed and fails to return them here. For restoring these across devices you'll need to persist them on your own server and query that as well. +### Listening to purchase updates + +You should always start listening to purchase update as early as possible to be able +to catch all purchase updates, including the ones from the previous app session. +To listen to the update: + +```dart + Stream purchaseUpdated = + InAppPurchaseConnection.instance.purchaseUpdatedStream; + _subscription = purchaseUpdated.listen((purchaseDetailsList) { + _listenToPurchaseUpdated(purchaseDetailsList); + }, onDone: () { + _subscription.cancel(); + }, onError: (error) { + // handle error here. + }); +``` + ### Making a purchase Both storefronts handle consumable and non-consumable products differently. If @@ -134,11 +152,19 @@ if (_isConsumable(productDetails)) { } else { InAppPurchaseConnection.instance.buyNonConsumable(purchaseParam: purchaseParam); } - // From here the purchase flow will be handled by the underlying storefront. // Updates will be delivered to the `InAppPurchaseConnection.instance.purchaseUpdatedStream`. ``` +### Complete a purchase + +The `InAppPurchaseConnection.purchaseUpdatedStream` will send purchase updates after +you initiate the purchase flow using `InAppPurchaseConnection.buyConsumable` or `InAppPurchaseConnection.buyNonConsumable`. +After delivering the content to the user, you need to call `InAppPurchaseConnection.completePurchase` to tell the `GooglePlay` +and `AppStore` that the purchase has been finished. + +WARNING! Fail to call `InAppPurchaseConnection.completePurchase` and get a successful response within 3 days of the purchase will result a refund. + ## Development This plugin uses diff --git a/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart b/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart index 4c4953d1ce98..2079f69dce6c 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase/in_app_purchase_connection.dart @@ -109,8 +109,7 @@ abstract class InAppPurchaseConnection { /// [PurchaseDetails.status] and update your UI accordingly. When the /// [PurchaseDetails.status] is [PurchaseStatus.purchased] or /// [PurchaseStatus.error], you should deliver the content or handle the - /// error. On iOS, you also need to call [completePurchase] to finish the - /// purchasing process. + /// error, then call [completePurchase] to finish the purchasing process. /// /// This method does return whether or not the purchase request was initially /// sent successfully. diff --git a/packages/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/pubspec.yaml index ac8971e74903..b2ee79718846 100644 --- a/packages/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/pubspec.yaml @@ -1,7 +1,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. homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase -version: 0.3.3 +version: 0.3.3+1 dependencies: async: ^2.0.8 From 2c6d1585f3d8af781c0c0c4a2ebe7110d2a6dd07 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 6 May 2020 16:23:28 -0700 Subject: [PATCH 2/2] Update packages/in_app_purchase/README.md Co-authored-by: Michael Klimushyn --- packages/in_app_purchase/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/in_app_purchase/README.md b/packages/in_app_purchase/README.md index 071e2dd3599e..f3a34a667c70 100644 --- a/packages/in_app_purchase/README.md +++ b/packages/in_app_purchase/README.md @@ -163,7 +163,7 @@ you initiate the purchase flow using `InAppPurchaseConnection.buyConsumable` or After delivering the content to the user, you need to call `InAppPurchaseConnection.completePurchase` to tell the `GooglePlay` and `AppStore` that the purchase has been finished. -WARNING! Fail to call `InAppPurchaseConnection.completePurchase` and get a successful response within 3 days of the purchase will result a refund. +WARNING! Failure to call `InAppPurchaseConnection.completePurchase` and get a successful response within 3 days of the purchase will result a refund. ## Development