Update get_stripe_plan_id to make it compatible with excl_vat

This commit is contained in:
PCoder 2020-01-24 14:10:56 +05:30
parent 399f9ed6c9
commit ec00785068

View file

@ -1,7 +1,9 @@
import logging import logging
import re import re
import stripe import stripe
from django.conf import settings from django.conf import settings
from datacenterlight.models import StripePlan from datacenterlight.models import StripePlan
stripe.api_key = settings.STRIPE_API_PRIVATE_KEY stripe.api_key = settings.STRIPE_API_PRIVATE_KEY
@ -351,7 +353,7 @@ class StripeUtils(object):
@staticmethod @staticmethod
def get_stripe_plan_id(cpu, ram, ssd, version, app='dcl', hdd=None, def get_stripe_plan_id(cpu, ram, ssd, version, app='dcl', hdd=None,
price=None): price=None, excl_vat=True):
""" """
Returns the Stripe plan id string of the form Returns the Stripe plan id string of the form
`dcl-v1-cpu-2-ram-5gb-ssd-10gb` based on the input parameters `dcl-v1-cpu-2-ram-5gb-ssd-10gb` based on the input parameters
@ -378,13 +380,16 @@ class StripeUtils(object):
plan=dcl_plan_string plan=dcl_plan_string
) )
if price is not None: if price is not None:
stripe_plan_id_string_with_price = '{}-{}chf'.format( stripe_plan_id_string = '{}-{}chf'.format(
stripe_plan_id_string, stripe_plan_id_string,
round(price, 2) round(price, 2)
) )
return stripe_plan_id_string_with_price if excl_vat:
else: stripe_plan_id_string = '{}-{}'.format(
return stripe_plan_id_string stripe_plan_id_string,
"excl_vat"
)
return stripe_plan_id_string
@staticmethod @staticmethod
def get_vm_config_from_stripe_id(stripe_id): def get_vm_config_from_stripe_id(stripe_id):