|
@@ -32,7 +32,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|
.instance.purchaseUpdatedStream
|
|
.instance.purchaseUpdatedStream
|
|
.listen((event) async {
|
|
.listen((event) async {
|
|
for (final e in event) {
|
|
for (final e in event) {
|
|
- if (e.status == PurchaseStatus.purchased) {
|
|
|
|
|
|
+ if (e.status == PurchaseStatus.purchased && e.pendingCompletePurchase) {
|
|
final dialog = createProgressDialog(context, "verifying purchase...");
|
|
final dialog = createProgressDialog(context, "verifying purchase...");
|
|
await dialog.show();
|
|
await dialog.show();
|
|
try {
|
|
try {
|
|
@@ -40,6 +40,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|
e.productID, e.verificationData.serverVerificationData);
|
|
e.productID, e.verificationData.serverVerificationData);
|
|
} catch (e) {
|
|
} catch (e) {
|
|
_logger.warning("Could not complete payment ", e);
|
|
_logger.warning("Could not complete payment ", e);
|
|
|
|
+ await dialog.hide();
|
|
showErrorDialog(
|
|
showErrorDialog(
|
|
context,
|
|
context,
|
|
"payment failed",
|
|
"payment failed",
|
|
@@ -47,11 +48,10 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|
(Platform.isAndroid ? "PlayStore" : "AppStore") +
|
|
(Platform.isAndroid ? "PlayStore" : "AppStore") +
|
|
" support if you were charged");
|
|
" support if you were charged");
|
|
return;
|
|
return;
|
|
- } finally {
|
|
|
|
- await dialog.hide();
|
|
|
|
}
|
|
}
|
|
await InAppPurchaseConnection.instance.completePurchase(e);
|
|
await InAppPurchaseConnection.instance.completePurchase(e);
|
|
Bus.instance.fire(UserAuthenticatedEvent());
|
|
Bus.instance.fire(UserAuthenticatedEvent());
|
|
|
|
+ await dialog.hide();
|
|
Navigator.pop(context);
|
|
Navigator.pop(context);
|
|
AwesomeDialog(
|
|
AwesomeDialog(
|
|
context: context,
|
|
context: context,
|
|
@@ -123,8 +123,8 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|
final ProductDetailsResponse response =
|
|
final ProductDetailsResponse response =
|
|
await InAppPurchaseConnection.instance
|
|
await InAppPurchaseConnection.instance
|
|
.queryProductDetails(_kIds);
|
|
.queryProductDetails(_kIds);
|
|
- await dialog.hide();
|
|
|
|
if (response.notFoundIDs.isNotEmpty) {
|
|
if (response.notFoundIDs.isNotEmpty) {
|
|
|
|
+ await dialog.hide();
|
|
showGenericErrorDialog(context);
|
|
showGenericErrorDialog(context);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -133,6 +133,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
|
|
PurchaseParam(productDetails: productDetails[0]);
|
|
PurchaseParam(productDetails: productDetails[0]);
|
|
await InAppPurchaseConnection.instance
|
|
await InAppPurchaseConnection.instance
|
|
.buyNonConsumable(purchaseParam: purchaseParam);
|
|
.buyNonConsumable(purchaseParam: purchaseParam);
|
|
|
|
+ await dialog.hide();
|
|
},
|
|
},
|
|
child: SubscriptionPlanWidget(plan: plan),
|
|
child: SubscriptionPlanWidget(plan: plan),
|
|
),
|
|
),
|