2016-04-28 17:42:01 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.conf import settings
|
|
|
|
import stripe
|
|
|
|
stripe.api_key = settings.STRIPE_API_PRIVATE_KEY
|
|
|
|
|
|
|
|
PAYMENT_PLANS = [
|
|
|
|
('spontaneous', {'amount': 3500,
|
|
|
|
'interval': "month",
|
|
|
|
'name': "The Spontaneous",
|
|
|
|
'currency': "chf",
|
|
|
|
'id': "spontaneus"
|
|
|
|
}),
|
|
|
|
('committed', {
|
2017-06-29 14:34:40 +00:00
|
|
|
'amount': 36000,
|
|
|
|
'interval': 'year',
|
|
|
|
'name': 'The Committed',
|
|
|
|
'currency': 'chf',
|
|
|
|
'id': 'committed'
|
2016-04-28 17:42:01 +00:00
|
|
|
})
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "Record payment plans for Digital Glarus on stripe"
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
for payment_plan, data in PAYMENT_PLANS:
|
|
|
|
try:
|
2017-06-29 14:34:40 +00:00
|
|
|
stripe.Plan.create(**data)
|
2016-04-28 17:42:01 +00:00
|
|
|
except stripe.InvalidRequestError as e:
|
|
|
|
print(e)
|