From f226c551a88bfd18832251ddc66e3b62b50a5a2b Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Dec 2017 00:06:21 +0100 Subject: [PATCH] Add stripe_subscription_id field to MembershipOrder --- ..._membershiporder_stripe_subscription_id.py | 20 +++++++++++++++++++ digitalglarus/models.py | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 digitalglarus/migrations/0025_membershiporder_stripe_subscription_id.py diff --git a/digitalglarus/migrations/0025_membershiporder_stripe_subscription_id.py b/digitalglarus/migrations/0025_membershiporder_stripe_subscription_id.py new file mode 100644 index 00000000..127d5ff8 --- /dev/null +++ b/digitalglarus/migrations/0025_membershiporder_stripe_subscription_id.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2017-12-23 22:56 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('digitalglarus', '0024_bookingcancellation'), + ] + + operations = [ + migrations.AddField( + model_name='membershiporder', + name='stripe_subscription_id', + field=models.CharField(max_length=100, null=True), + ), + ] diff --git a/digitalglarus/models.py b/digitalglarus/models.py index 16d6b639..9cae88ed 100644 --- a/digitalglarus/models.py +++ b/digitalglarus/models.py @@ -129,6 +129,7 @@ class MembershipOrder(Ordereable, models.Model): membership = models.ForeignKey(Membership) start_date = models.DateField() end_date = models.DateField() + stripe_subscription_id = models.CharField(max_length=100, null=True) @classmethod def current_membership_dates(cls, user): @@ -172,10 +173,12 @@ class MembershipOrder(Ordereable, models.Model): @classmethod def create(cls, data): stripe_charge = data.pop('stripe_charge', None) + stripe_subscription_id = data.pop('stripe_subscription_id', None) instance = cls.objects.create(**data) instance.stripe_charge_id = stripe_charge.id instance.last4 = stripe_charge.source.last4 instance.cc_brand = stripe_charge.source.brand + instance.stripe_subscription_id = stripe_subscription_id instance.save() return instance