|
|
@ -37,6 +37,7 @@ class User :
|
|
|
|
if customer :
|
|
|
|
if customer :
|
|
|
|
customer = [item for item in customer if item.email == uid]
|
|
|
|
customer = [item for item in customer if item.email == uid]
|
|
|
|
customer = customer[0]
|
|
|
|
customer = customer[0]
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Insure the product is the one we are looking for ...
|
|
|
|
# Insure the product is the one we are looking for ...
|
|
|
|
args = dict(self.store)
|
|
|
|
args = dict(self.store)
|
|
|
@ -90,11 +91,13 @@ class User :
|
|
|
|
|
|
|
|
|
|
|
|
def post(self,**args):
|
|
|
|
def post(self,**args):
|
|
|
|
document = dict(self.me,**{})
|
|
|
|
document = dict(self.me,**{})
|
|
|
|
|
|
|
|
|
|
|
|
args = dict(self.store)
|
|
|
|
args = dict(self.store)
|
|
|
|
args['create'] = True
|
|
|
|
args['create'] = True
|
|
|
|
|
|
|
|
|
|
|
|
writer = CouchdbWriter(**args)
|
|
|
|
writer = CouchdbWriter(**args)
|
|
|
|
writer.set(document)
|
|
|
|
writer.set(document)
|
|
|
|
|
|
|
|
|
|
|
|
# writer.close()
|
|
|
|
# writer.close()
|
|
|
|
def get_key(self,uid):
|
|
|
|
def get_key(self,uid):
|
|
|
|
reader = CouchdbReader(**self.store)
|
|
|
|
reader = CouchdbReader(**self.store)
|
|
|
@ -142,6 +145,26 @@ class User :
|
|
|
|
if not customer :
|
|
|
|
if not customer :
|
|
|
|
customer = self.stripe.Customer.create(email=uid)
|
|
|
|
customer = self.stripe.Customer.create(email=uid)
|
|
|
|
self.update(_id=customer.id,emails=[uid])
|
|
|
|
self.update(_id=customer.id,emails=[uid])
|
|
|
|
|
|
|
|
elif not self.me['subscriptions']:
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# We have a customer and subscription information that goes with it
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
mysub = {"plans":[]}
|
|
|
|
|
|
|
|
for rows in customer.subscriptions.data :
|
|
|
|
|
|
|
|
lsub = rows.items()
|
|
|
|
|
|
|
|
myplans = [ item[1]for item in lsub if 'plan' in item and item[1]['product'] == self.me['info']['id'] and item[1]['active'] ]
|
|
|
|
|
|
|
|
if myplans :
|
|
|
|
|
|
|
|
for plan in myplans :
|
|
|
|
|
|
|
|
plan['metadata'] = str(plan['metadata'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.me['subscriptions'] = {plan['nickname']: dict(plan)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print customer.subscriptions.data[0].items()]
|
|
|
|
|
|
|
|
# self.post(uid=customer.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# else:
|
|
|
|
# else:
|
|
|
|
# customer = customer
|
|
|
|
# customer = customer
|
|
|
@ -157,7 +180,7 @@ class User :
|
|
|
|
info = {sub.plan.nickname:sub.plan}
|
|
|
|
info = {sub.plan.nickname:sub.plan}
|
|
|
|
self.update(subscriptions=info)
|
|
|
|
self.update(subscriptions=info)
|
|
|
|
|
|
|
|
|
|
|
|
self.post()
|
|
|
|
self.post(uid=customer.id)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# keep a copy of this on our servers ...
|
|
|
|
# keep a copy of this on our servers ...
|
|
|
|
#
|
|
|
|
#
|
|
|
|