diff --git a/helper.py b/helper.py index d1a5dd4..65a5155 100644 --- a/helper.py +++ b/helper.py @@ -1,5 +1,8 @@ import logging +import parsedatetime + +from datetime import datetime from stripe_utils import StripeUtils @@ -64,3 +67,21 @@ def calculate_charges(specification, data): feature_detail['unit']['value'] ) return one_time_charge, recurring_charge + + +def is_order_valid(order_timestamp, renewal_period): + """ + Sample Code Usage + + >> current_datetime, status = cal.parse('Now') + >> current_datetime = datetime(*current_datetime[:6]) + + >> print('Is order valid: ', is_order_valid(current_datetime, '1 month')) + >> True + """ + cal = parsedatetime.Calendar() + + renewal_datetime, status = cal.parse(renewal_period) + renewal_datetime = datetime(*renewal_datetime[:6]) + + return order_timestamp <= renewal_datetime diff --git a/requirements.txt b/requirements.txt index cb4f2a8..0f5d0d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +done stripe flask Flask-RESTful