Merge pull request #558 from ente-io/upgrade_in_app_purchase
Upgrade in_app_purchase
This commit is contained in:
commit
af01393f2d
9 changed files with 55 additions and 52 deletions
|
@ -100,7 +100,7 @@ PODS:
|
|||
- GoogleUtilities/Logger
|
||||
- image_editor (1.0.0):
|
||||
- Flutter
|
||||
- in_app_purchase (0.0.1):
|
||||
- in_app_purchase_storekit (0.0.1):
|
||||
- Flutter
|
||||
- libwebp (1.2.3):
|
||||
- libwebp/demux (= 1.2.3)
|
||||
|
@ -190,7 +190,7 @@ DEPENDENCIES:
|
|||
- flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`)
|
||||
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
|
||||
- image_editor (from `.symlinks/plugins/image_editor/ios`)
|
||||
- in_app_purchase (from `.symlinks/plugins/in_app_purchase/ios`)
|
||||
- in_app_purchase_storekit (from `.symlinks/plugins/in_app_purchase_storekit/ios`)
|
||||
- local_auth (from `.symlinks/plugins/local_auth/ios`)
|
||||
- motionphoto (from `.symlinks/plugins/motionphoto/ios`)
|
||||
- move_to_background (from `.symlinks/plugins/move_to_background/ios`)
|
||||
|
@ -266,8 +266,8 @@ EXTERNAL SOURCES:
|
|||
:path: ".symlinks/plugins/fluttertoast/ios"
|
||||
image_editor:
|
||||
:path: ".symlinks/plugins/image_editor/ios"
|
||||
in_app_purchase:
|
||||
:path: ".symlinks/plugins/in_app_purchase/ios"
|
||||
in_app_purchase_storekit:
|
||||
:path: ".symlinks/plugins/in_app_purchase_storekit/ios"
|
||||
local_auth:
|
||||
:path: ".symlinks/plugins/local_auth/ios"
|
||||
motionphoto:
|
||||
|
@ -330,7 +330,7 @@ SPEC CHECKSUMS:
|
|||
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
||||
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
||||
image_editor: eab82a302a6623a866da5145b7c4c0ee8a4ffbb4
|
||||
in_app_purchase: 3e2155afa9d03d4fa32d9e62d567885080ce97d6
|
||||
in_app_purchase_storekit: d7fcf4646136ec258e237872755da8ea6c1b6096
|
||||
libwebp: 60305b2e989864154bd9be3d772730f08fc6a59c
|
||||
local_auth: 1740f55d7af0a2e2a8684ce225fe79d8931e808c
|
||||
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
|
||||
|
|
|
@ -286,7 +286,7 @@
|
|||
"${BUILT_PRODUCTS_DIR}/flutter_sodium/flutter_sodium.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/image_editor/image_editor.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/in_app_purchase/in_app_purchase.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/in_app_purchase_storekit/in_app_purchase_storekit.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/motionphoto/motionphoto.framework",
|
||||
|
@ -339,7 +339,7 @@
|
|||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_sodium.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_editor.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/in_app_purchase.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/in_app_purchase_storekit.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/motionphoto.framework",
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:background_fetch/background_fetch.dart';
|
|||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:photos/app.dart';
|
||||
|
@ -128,7 +127,6 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
|||
} else {
|
||||
AppLifecycleService.instance.onAppInForeground('init via: $via');
|
||||
}
|
||||
InAppPurchaseConnection.enablePendingPurchases();
|
||||
CryptoUtil.init();
|
||||
await NotificationService.instance.init();
|
||||
await Network.instance.init();
|
||||
|
|
|
@ -38,12 +38,11 @@ class BillingService {
|
|||
Future<BillingPlans> _future;
|
||||
|
||||
Future<void> init() async {
|
||||
InAppPurchaseConnection.enablePendingPurchases();
|
||||
// if (Platform.isIOS && kDebugMode) {
|
||||
// await FlutterInappPurchase.instance.initConnection;
|
||||
// FlutterInappPurchase.instance.clearTransactionIOS();
|
||||
// }
|
||||
InAppPurchaseConnection.instance.purchaseUpdatedStream.listen((purchases) {
|
||||
InAppPurchase.instance.purchaseStream.listen((purchases) {
|
||||
if (_isOnSubscriptionPage) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,11 +53,11 @@ class BillingService {
|
|||
purchase.verificationData.serverVerificationData,
|
||||
).then((response) {
|
||||
if (response != null) {
|
||||
InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
InAppPurchase.instance.completePurchase(purchase);
|
||||
}
|
||||
});
|
||||
} else if (Platform.isIOS && purchase.pendingCompletePurchase) {
|
||||
InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
InAppPurchase.instance.completePurchase(purchase);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -289,7 +289,9 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
RichText(
|
||||
text: TextSpan(
|
||||
text: "Manage family",
|
||||
style: Theme.of(context).textTheme.overline,
|
||||
style: Theme.of(context).textTheme.bodyMedium.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
|
|
@ -132,7 +132,9 @@ class SubFaqWidget extends StatelessWidget {
|
|||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "Questions?",
|
||||
style: Theme.of(context).textTheme.overline,
|
||||
style: Theme.of(context).textTheme.bodyMedium.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -60,9 +60,8 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
}
|
||||
|
||||
void _setupPurchaseUpdateStreamListener() {
|
||||
_purchaseUpdateSubscription = InAppPurchaseConnection
|
||||
.instance.purchaseUpdatedStream
|
||||
.listen((purchases) async {
|
||||
_purchaseUpdateSubscription =
|
||||
InAppPurchase.instance.purchaseStream.listen((purchases) async {
|
||||
if (!_dialog.isShowing()) {
|
||||
await _dialog.show();
|
||||
}
|
||||
|
@ -74,7 +73,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
purchase.productID,
|
||||
purchase.verificationData.serverVerificationData,
|
||||
);
|
||||
await InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
await InAppPurchase.instance.completePurchase(purchase);
|
||||
String text = "Thank you for subscribing!";
|
||||
if (!widget.isOnboarding) {
|
||||
final isUpgrade = _hasActiveSubscription &&
|
||||
|
@ -121,7 +120,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
return;
|
||||
}
|
||||
} else if (Platform.isIOS && purchase.pendingCompletePurchase) {
|
||||
await InAppPurchaseConnection.instance.completePurchase(purchase);
|
||||
await InAppPurchase.instance.completePurchase(purchase);
|
||||
await _dialog.hide();
|
||||
} else if (purchase.status == PurchaseStatus.error) {
|
||||
await _dialog.hide();
|
||||
|
@ -294,7 +293,9 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
RichText(
|
||||
text: TextSpan(
|
||||
text: "Manage family",
|
||||
style: Theme.of(context).textTheme.overline,
|
||||
style: Theme.of(context).textTheme.bodyMedium.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
@ -389,14 +390,13 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
showErrorDialog(
|
||||
context,
|
||||
"Sorry",
|
||||
"you cannot downgrade to this plan",
|
||||
"You cannot downgrade to this plan",
|
||||
);
|
||||
return;
|
||||
}
|
||||
await _dialog.show();
|
||||
final ProductDetailsResponse response =
|
||||
await InAppPurchaseConnection.instance
|
||||
.queryProductDetails({productID});
|
||||
await InAppPurchase.instance.queryProductDetails({productID});
|
||||
if (response.notFoundIDs.isNotEmpty) {
|
||||
_logger.severe(
|
||||
"Could not find products: " + response.notFoundIDs.toString(),
|
||||
|
@ -410,34 +410,15 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|||
_currentSubscription.productID != freeProductID &&
|
||||
_currentSubscription.productID != plan.androidID;
|
||||
if (isCrossGradingOnAndroid) {
|
||||
final existingProductDetailsResponse =
|
||||
await InAppPurchaseConnection.instance
|
||||
.queryProductDetails({_currentSubscription.productID});
|
||||
if (existingProductDetailsResponse.notFoundIDs.isNotEmpty) {
|
||||
_logger.severe(
|
||||
"Could not find existing products: " +
|
||||
response.notFoundIDs.toString(),
|
||||
);
|
||||
await _dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
return;
|
||||
}
|
||||
final subscriptionChangeParam = ChangeSubscriptionParam(
|
||||
oldPurchaseDetails: PurchaseDetails(
|
||||
purchaseID: null,
|
||||
productID: _currentSubscription.productID,
|
||||
verificationData: null,
|
||||
transactionDate: null,
|
||||
),
|
||||
);
|
||||
await InAppPurchaseConnection.instance.buyNonConsumable(
|
||||
purchaseParam: PurchaseParam(
|
||||
productDetails: response.productDetails[0],
|
||||
changeSubscriptionParam: subscriptionChangeParam,
|
||||
),
|
||||
await _dialog.hide();
|
||||
showErrorDialog(
|
||||
context,
|
||||
"Could not update subscription",
|
||||
"Please contact support@ente.io and we will be happy to help!",
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
await InAppPurchaseConnection.instance.buyNonConsumable(
|
||||
await InAppPurchase.instance.buyNonConsumable(
|
||||
purchaseParam: PurchaseParam(
|
||||
productDetails: response.productDetails[0],
|
||||
),
|
||||
|
|
23
pubspec.lock
23
pubspec.lock
|
@ -601,7 +601,28 @@ packages:
|
|||
name: in_app_purchase
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.2"
|
||||
version: "3.0.7"
|
||||
in_app_purchase_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: in_app_purchase_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.3+5"
|
||||
in_app_purchase_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: in_app_purchase_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
in_app_purchase_storekit:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: in_app_purchase_storekit
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.2+2"
|
||||
intl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -68,7 +68,7 @@ dependencies:
|
|||
image: ^3.0.2
|
||||
image_editor: ^1.0.0
|
||||
implicitly_animated_reorderable_list: ^0.4.0
|
||||
in_app_purchase: ^0.5.2
|
||||
in_app_purchase: ^3.0.7
|
||||
intl: ^0.17.0
|
||||
like_button: ^2.0.2
|
||||
loading_animations: ^2.1.0
|
||||
|
|
Loading…
Reference in a new issue