|
|
|
@ -278,7 +278,8 @@ class StripeUtils(object):
|
|
|
|
|
client.put("/v1/stripe_plans", json.dumps({"plans": list(stripe_plans)})) |
|
|
|
|
|
|
|
|
|
@handleStripeError |
|
|
|
|
def get_or_create_stripe_plan(self, amount, name, stripe_plan_id): |
|
|
|
|
def get_or_create_stripe_plan(self, amount, name, stripe_plan_id, |
|
|
|
|
interval=INTERVAL): |
|
|
|
|
""" |
|
|
|
|
This function checks if a StripePlan with the given |
|
|
|
|
stripe_plan_id already exists. If it exists then the function |
|
|
|
@ -290,6 +291,8 @@ class StripeUtils(object):
|
|
|
|
|
:param stripe_plan_id: The id of the Stripe plan to be |
|
|
|
|
created. Use get_stripe_plan_id_string function to |
|
|
|
|
obtain the name of the plan to be created |
|
|
|
|
:param interval: The interval for subscription {month, year}. Defaults |
|
|
|
|
to month if not provided |
|
|
|
|
:return: The StripePlan object if it exists else creates a |
|
|
|
|
Plan object in Stripe and a local StripePlan and |
|
|
|
|
returns it. Returns None in case of Stripe error |
|
|
|
@ -309,7 +312,7 @@ class StripeUtils(object):
|
|
|
|
|
logger.debug("Plan {} does not exist in Stripe, Creating") |
|
|
|
|
plan_obj = self.stripe.Plan.create( |
|
|
|
|
amount=amount, |
|
|
|
|
interval=self.INTERVAL, |
|
|
|
|
interval=interval, |
|
|
|
|
name=name, |
|
|
|
|
currency=self.CURRENCY, |
|
|
|
|
id=stripe_plan_id) |
|
|
|
|