浏览代码

Stripe: Hide renew button if the subscription has expired

Neeraj Gupta 3 年之前
父节点
当前提交
a4814690b2
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      lib/ui/payment/stripe_subscription_page.dart

+ 5 - 2
lib/ui/payment/stripe_subscription_page.dart

@@ -152,7 +152,8 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
       widgets.add(SubFaqWidget());
       widgets.add(SubFaqWidget());
     }
     }
 
 
-    if (_currentSubscription.paymentProvider == kStripe) {
+    // only active subscription can be renewed/canceled
+    if (_hasActiveSubscription && _isStripeSubscriber) {
       widgets.add(_stripeRenewOrCancelButton());
       widgets.add(_stripeRenewOrCancelButton());
     }
     }
 
 
@@ -301,7 +302,9 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
               if (isActive) {
               if (isActive) {
                 return;
                 return;
               }
               }
-              if (_currentSubscription.paymentProvider != kStripe &&
+              // prompt user to cancel their active subscription form other
+              // payment providers
+              if (!_isStripeSubscriber &&
                   _hasActiveSubscription &&
                   _hasActiveSubscription &&
                   _currentSubscription.productID != kFreeProductID) {
                   _currentSubscription.productID != kFreeProductID) {
                 showErrorDialog(context, "sorry",
                 showErrorDialog(context, "sorry",