parent
7c17aef037
commit
b4e7acc5db
@ -0,0 +1,46 @@
|
||||
import store
|
||||
import json
|
||||
import os
|
||||
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 signup(**_args):
|
||||
"""
|
||||
This function creates or pulls a customer's key from the backend (stripe)
|
||||
"""
|
||||
if not store.isready() :
|
||||
__init__(**_args)
|
||||
_email = _args['email']
|
||||
_customer = store.get.customer(_email)
|
||||
_user = {}
|
||||
if not _customer :
|
||||
#
|
||||
# Create/add a new user information to the backend
|
||||
_customer = store.set.customer(_email,'')
|
||||
plans = store.get.plans('healthcareio')
|
||||
plans = [plan for plan in plans if plan.amount == 0]
|
||||
plan = plans[0]
|
||||
#
|
||||
# signup to free plan
|
||||
store.set.subscribe(_customer.id,plan.id)
|
||||
if _customer :
|
||||
_customer = _customer[0]
|
||||
_user['email'] = _email
|
||||
_user['token'] = _customer['id']
|
||||
|
||||
return json.dumps(_user)
|
||||
|
||||
def upgrade (**_args):
|
||||
pass
|
||||
|
||||
Loading…
Reference in new issue