You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import store
|
|
import stripe
|
|
import json
|
|
import os
|
|
import pandas as pd
|
|
|
|
def copyright(**_args):
|
|
return [store.__name__,store.__version__]
|
|
def init (**_args):
|
|
_path = _args['config']['system']['source']['store']
|
|
if not store.isready() :
|
|
if os.path.exists(_path) :
|
|
f = open(_path)
|
|
_info = json.loads(f.read())
|
|
f.close()
|
|
store.init(_info['secret'])
|
|
return "1"
|
|
else:
|
|
return "0"
|
|
else:
|
|
return "1"
|
|
def plans (**_args) :
|
|
"""
|
|
This function will return plans associated with a product
|
|
"""
|
|
if not store.isready() :
|
|
print (['Initializing Store'])
|
|
init(**_args)
|
|
|
|
_plans = store.get.plans('healthcareio')
|
|
_df = {}
|
|
columns = [_plan['nickname'] for _plan in _plans if _plan['active']]
|
|
pricing = [ '/'.join([str(_plan['unit_amount']/100),_plan['recurring']['interval']]) if _plan['unit_amount'] else 'FREE' for _plan in _plans if _plan['active']]
|
|
_features = [json.loads(_plan['metadata']['features']) for _plan in _plans if _plan['active']]
|
|
|
|
_key = list(set(['community','free']) & set(columns))[0]
|
|
_features = pd.DataFrame(_features).T
|
|
_features.columns = columns
|
|
_features = _features.sort_values(by=[_key],ascending=False)
|
|
|
|
_lrow = pd.DataFrame([dict(zip(columns,pricing))],index=[''])
|
|
_df = pd.concat([_features,_lrow])
|
|
return _df.to_json()
|
|
# _df[_plan['nickname']] = _features.values
|
|
# _df.index = list(_features.keys())
|
|
# print (pd.DataFrame(_df))
|
|
# return json.dumps([_plan for _plan in .. if _plan['active'] == True])
|