From 5fe6007ad2f7de82e8b3d515e05ef3d8125b06d4 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 17 Aug 2017 18:21:53 +0200 Subject: [PATCH] Refactored code and added app as a parameter in get_stripe_plan_id --- utils/stripe_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/stripe_utils.py b/utils/stripe_utils.py index f0bcf264..53262816 100644 --- a/utils/stripe_utils.py +++ b/utils/stripe_utils.py @@ -1,7 +1,9 @@ +import logging + import stripe from django.conf import settings + from datacenterlight.models import StripePlan -import logging stripe.api_key = settings.STRIPE_API_PRIVATE_KEY logger = logging.getLogger(__name__) @@ -220,7 +222,7 @@ class StripeUtils(object): return charge @staticmethod - def get_stripe_plan_id_string(cpu, ram, ssd, version): + def get_stripe_plan_id(cpu, ram, ssd, version, app): """ Returns the stripe plan id string of the form `dcl-v1-cpu-2-ram-5gb-ssd-10gb` based on the input parameters @@ -231,5 +233,5 @@ class StripeUtils(object): :return: A string of the form `dcl-v1-cpu-2-ram-5gb-ssd-10gb` """ dcl_plan_string = 'cpu-{cpu}-ram-{ram}gb-ssd-{ssd}gb'.format(cpu=cpu, ram=ram, ssd=ssd) - stripe_plan_id_string = '{app}-v{version}-{plan}'.format(app='dcl', version=version, plan=dcl_plan_string) + stripe_plan_id_string = '{app}-v{version}-{plan}'.format(app=app, version=version, plan=dcl_plan_string) return stripe_plan_id_string