Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c5d6291f2d |
2 changed files with 16 additions and 3 deletions
|
@ -30,6 +30,14 @@ class Subscription {
|
|||
return expiryTime > DateTime.now().microsecondsSinceEpoch;
|
||||
}
|
||||
|
||||
bool isPastDue() {
|
||||
return expiryTime < DateTime.now().microsecondsSinceEpoch &&
|
||||
expiryTime >=
|
||||
DateTime.now()
|
||||
.subtract(const Duration(days: 30))
|
||||
.microsecondsSinceEpoch;
|
||||
}
|
||||
|
||||
bool isYearlyPlan() {
|
||||
return 'year' == period;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,11 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
userDetails.hasPaidAddon();
|
||||
_hasActiveSubscription = _currentSubscription!.isValid();
|
||||
_isStripeSubscriber = _currentSubscription!.paymentProvider == stripe;
|
||||
|
||||
if (_isStripeSubscriber && _currentSubscription!.isPastDue()) {
|
||||
_redirectToPaymentPortal();
|
||||
}
|
||||
|
||||
return _filterStripeForUI().then((value) {
|
||||
_hasLoadedData = true;
|
||||
setState(() {});
|
||||
|
@ -254,7 +259,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
singleBorderRadius: 4,
|
||||
alignCaptionedTextToLeft: true,
|
||||
onTap: () async {
|
||||
_onStripSupportedPaymentDetailsTap();
|
||||
_redirectToPaymentPortal();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -295,9 +300,9 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
|||
);
|
||||
}
|
||||
|
||||
// _onStripSupportedPaymentDetailsTap action allows the user to update
|
||||
// _redirectToPaymentPortal action allows the user to update
|
||||
// their stripe payment details
|
||||
void _onStripSupportedPaymentDetailsTap() async {
|
||||
void _redirectToPaymentPortal() async {
|
||||
final String paymentProvider = _currentSubscription!.paymentProvider;
|
||||
switch (_currentSubscription!.paymentProvider) {
|
||||
case stripe:
|
||||
|
|
Loading…
Add table
Reference in a new issue