Teams pricing.
parent
3105811517
commit
5cac8f3fde
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('teams', '0004_auto_20150930_1526'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='team',
|
||||
name='stripe_id',
|
||||
field=models.CharField(max_length=100, null=True, blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='team',
|
||||
name='name',
|
||||
field=models.CharField(max_length=30),
|
||||
),
|
||||
]
|
|
@ -4,12 +4,13 @@ from snipts.utils import slugify_uniquely
|
|||
|
||||
|
||||
class Team(models.Model):
|
||||
user = models.OneToOneField(User, blank=True, null=True)
|
||||
owner = models.ForeignKey(User, related_name='owner')
|
||||
name = models.CharField(max_length=30)
|
||||
email = models.EmailField(max_length=255)
|
||||
slug = models.SlugField(max_length=255, blank=True)
|
||||
members = models.ManyToManyField(User, related_name='member', blank=True)
|
||||
name = models.CharField(max_length=30)
|
||||
owner = models.ForeignKey(User, related_name='owner')
|
||||
slug = models.SlugField(max_length=255, blank=True)
|
||||
stripe_id = models.CharField(max_length=100, null=True, blank=True)
|
||||
user = models.OneToOneField(User, blank=True, null=True)
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True, editable=False)
|
||||
modified = models.DateTimeField(auto_now=True, editable=False)
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if request.GET.declined %}
|
||||
<div class="alert alert-error" style="margin: 30px;">
|
||||
<strong>{{ request.GET.declined }}</strong> You have not been charged. Please try again.
|
||||
</div>
|
||||
{% endif %}
|
||||
<form class="form-horizontal static-box" id="pro-signup" method="post" action="/for-teams/complete/">
|
||||
<fieldset>
|
||||
<div class="info">
|
||||
|
@ -39,10 +44,81 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="name">Payment plan:</label>
|
||||
<div class="controls">
|
||||
<select name="plan" type="text" class="input-medium" id="plan">
|
||||
<option value="snipt-teams-25-monthly">$49/month</option>
|
||||
<option value="snipt-teams-25-annual">$588/year</option>
|
||||
<option value="snipt-teams-100-monthly">$149/month</option>
|
||||
<option value="snipt-teams-100-annual">$1788/year</option>
|
||||
<option value="snipt-teams-250-monthly">$299/month</option>
|
||||
<option value="snipt-teams-250-annual">$3588/year</option>
|
||||
<option value="snipt-teams-unlimited-monthly">$499/month</option>
|
||||
<option value="snipt-teams-unlimited-monthly">$499/year</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="name">Name on card:</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-xlarge" id="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="number">Card number:</label>
|
||||
<div class="controls cards">
|
||||
<input type="text" class="input-xlarge" id="number" />
|
||||
<img src="{{ STATIC_URL }}img/card-visa.png" alt="Visa" />
|
||||
<img src="{{ STATIC_URL }}img/card-mastercard.png" alt="MasterCard" />
|
||||
<img src="{{ STATIC_URL }}img/card-discover.png" alt="Discover" />
|
||||
<img src="{{ STATIC_URL }}img/card-american-express.png" alt="American Express" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="exp-month">Expiration date:</label>
|
||||
<div class="controls">
|
||||
<select id="exp-month" class="span2 exp-month">
|
||||
<option value="">----</option>
|
||||
<option value="01">01 - January</option>
|
||||
<option value="02">02 - February</option>
|
||||
<option value="03">03 - March</option>
|
||||
<option value="04">04 - April</option>
|
||||
<option value="05">05 - May</option>
|
||||
<option value="06">06 - June</option>
|
||||
<option value="07">07 - July</option>
|
||||
<option value="08">08 - August</option>
|
||||
<option value="09">09 - September</option>
|
||||
<option value="10">10 - October</option>
|
||||
<option value="11">11 - November</option>
|
||||
<option value="12">12 - December</option>
|
||||
</select>
|
||||
<select id="exp-year" class="span2">
|
||||
<option value="">----</option>
|
||||
<option value="2014">2014</option>
|
||||
<option value="2015">2015</option>
|
||||
<option value="2016">2016</option>
|
||||
<option value="2017">2017</option>
|
||||
<option value="2018">2018</option>
|
||||
<option value="2019">2019</option>
|
||||
<option value="2020">2020</option>
|
||||
<option value="2021">2021</option>
|
||||
<option value="2022">2022</option>
|
||||
<option value="2022">2023</option>
|
||||
<option value="2022">2024</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="cvc">Security code (CVC):</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-min span1" id="cvc">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="form-actions">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-success">Create team »</button>
|
||||
<button type="submit" class="btn btn-success">Start free trial and create team »</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import os
|
||||
import stripe
|
||||
import uuid
|
||||
|
||||
from annoying.decorators import render_to
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpResponseBadRequest
|
||||
from django.http import HttpResponseRedirect, HttpResponseBadRequest
|
||||
from django.shortcuts import get_object_or_404
|
||||
from teams.models import Team
|
||||
|
||||
|
@ -28,9 +31,26 @@ def team_members(request, username):
|
|||
def for_teams_complete(request):
|
||||
if request.method == 'POST' and request.user.is_authenticated():
|
||||
|
||||
token = request.POST['token']
|
||||
stripe.api_key = os.environ.get('STRIPE_SECRET_KEY',
|
||||
settings.STRIPE_SECRET_KEY)
|
||||
|
||||
plan = request.POST['plan']
|
||||
|
||||
try:
|
||||
customer = stripe.Customer.create(card=token,
|
||||
plan=plan,
|
||||
email=request.user.email)
|
||||
except stripe.CardError, e:
|
||||
error_message = e.json_body['error']['message']
|
||||
return HttpResponseRedirect('/for-teams/?declined=%s' %
|
||||
error_message or
|
||||
'Your card was declined.')
|
||||
|
||||
team = Team(name=request.POST['name'],
|
||||
email=request.POST['email'],
|
||||
owner=request.user)
|
||||
team.stripe_id = customer.id
|
||||
team.save()
|
||||
|
||||
user = User.objects.create_user(team.slug,
|
||||
|
|
Loading…
Reference in New Issue