Add stripe_subscription_id field to MembershipOrder
This commit is contained in:
parent
10bc05f700
commit
f226c551a8
2 changed files with 23 additions and 0 deletions
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -129,6 +129,7 @@ class MembershipOrder(Ordereable, models.Model):
|
||||||
membership = models.ForeignKey(Membership)
|
membership = models.ForeignKey(Membership)
|
||||||
start_date = models.DateField()
|
start_date = models.DateField()
|
||||||
end_date = models.DateField()
|
end_date = models.DateField()
|
||||||
|
stripe_subscription_id = models.CharField(max_length=100, null=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def current_membership_dates(cls, user):
|
def current_membership_dates(cls, user):
|
||||||
|
@ -172,10 +173,12 @@ class MembershipOrder(Ordereable, models.Model):
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data):
|
def create(cls, data):
|
||||||
stripe_charge = data.pop('stripe_charge', None)
|
stripe_charge = data.pop('stripe_charge', None)
|
||||||
|
stripe_subscription_id = data.pop('stripe_subscription_id', None)
|
||||||
instance = cls.objects.create(**data)
|
instance = cls.objects.create(**data)
|
||||||
instance.stripe_charge_id = stripe_charge.id
|
instance.stripe_charge_id = stripe_charge.id
|
||||||
instance.last4 = stripe_charge.source.last4
|
instance.last4 = stripe_charge.source.last4
|
||||||
instance.cc_brand = stripe_charge.source.brand
|
instance.cc_brand = stripe_charge.source.brand
|
||||||
|
instance.stripe_subscription_id = stripe_subscription_id
|
||||||
instance.save()
|
instance.save()
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue