Beispiel #1
0
 def subscribe(self, user, plan):
     """ Create remote Customer instance """
     if not settings.CHEDDAR_GETTER_CREATE_USER or self.free:
         return
     authorize_CG_gateway()
     customer = create_customer(user, plan)
     sub = customer.subscription
     sub.plan = Plan.get(plan.code)
     if not self.free:
         update_subscription(sub, self.cleaned_data, user)
     customer.save()
Beispiel #2
0
 def subscribe(self, user, plan):
     """ Update remote Customer instance """
     authorize_CG_gateway()
     try:
         code = settings.CHEDDAR_GETTER_CUSTOMER_CODE_PREFIX + str(user.id)
         customer = Customer.get(code)
         new_customer = False
     except NotFound:
         if not self.free:
             customer = create_customer(user, plan)
             new_customer = True
         else:
             return
     if self.free:
         return customer.delete()
     sub = customer.subscription
     sub.plan = Plan.get(plan.code)
     update_subscription(sub, self.cleaned_data, user)
     sub.save()
     if new_customer:
         customer.save()