Support for one-time payment accounts.

master
Nick Sergeant 2014-05-19 22:02:42 -04:00
parent be9ade19fc
commit b6147f92a6
4 changed files with 36 additions and 19 deletions

View File

@ -5,27 +5,30 @@
</p>
</div>
<div ng-show="user.is_pro">
<div class="def" data-title="Plan">
<div class="def" data-title="Plan" ng-show="user.stripeAccount.status != 'inactive'">
{[{ user.stripeAccount.name || 'Loading...' }]}
</div>
<div class="def" data-title="Price">
<div class="def" data-title="Plan" ng-show="user.stripeAccount.status == 'inactive'">
One-time payment
</div>
<div class="def" data-title="Price" ng-show="user.stripeAccount.status != 'inactive'">
<span ng-show="user.stripeAccount">${[{ user.stripeAccount.amount / 100 }]}.00 USD / {[{ user.stripeAccount.interval }]}</span>
<span ng-show="!user.stripeAccount">Loading...</span>
</div>
<div class="def" data-title="Card">
<div class="def" data-title="Card" ng-show="user.stripeAccount.status != 'inactive'">
<span ng-show="user.stripeAccount">xxxx-xxxx-xxxx-{[{ user.stripeAccount.last4 || 'Loading...' }]}</span>
<span ng-show="!user.stripeAccount">Loading...</span>
</div>
<div class="def" data-title="Status">
<div class="def" data-title="Status" ng-show="user.stripeAccount.status != 'inactive'">
{[{ user.stripeAccount.status || 'Loading...' }]}
</div>
<div class="def" data-title="Pro since">
<span ng-show="user.stripeAccount">{[{ user.stripeAccount.created * 1000 |date:'fullDate' }]}</span>
<span ng-show="!user.stripeAccount">Loading...</span>
</div>
<div class="def" data-title="Next bill date">
<div class="def" data-title="Next bill date" ng-show="user.stripeAccount.status != 'inactive'">
<span ng-show="user.stripeAccount">{[{ user.stripeAccount.nextBill * 1000 |date:'fullDate' }]}</span>
<span ng-show="!user.stripeAccount">Loading...</span>
</div>
<p class="alert alert-info">Need to cancel? <a href="mailto:nick@snipt.net">Email Nick</a>.</p>
<p class="alert alert-info" ng-show="user.stripeAccount.status != 'inactive'">Need to cancel? <a href="mailto:nick@snipt.net">Email Nick</a>.</p>
</div>

View File

@ -36,7 +36,7 @@
<form class="form-horizontal static-box" id="pro-signup" method="post" action="/pro/complete/">
<fieldset>
<div class="info">
Subscribe for just <span>$5/month</span> or <span>$49/year</span>.
Subscribe for just <span>$5/mo</span>, <span>$49/yr</span>, or <span>$149 once</span>.
<p class="sub">
We believe the best way to build a superior product is to charge for it.
As a paid Snipt member, you'll have unrestricted access to the app, <a href="/api/">API</a>,
@ -51,6 +51,7 @@
<select name="plan" type="text" class="input-medium" id="plan">
<option value="monthly">$5/month</option>
<option value="yearly">$49/year</option>
<option value="onetime">$149 once</option>
</select>
</div>
</div>

View File

@ -22,7 +22,7 @@
{% endif %}
<fieldset>
<div class="info">
Free for 7 days, then just <span>$5/month</span> or <span>$49/year</span>.
Free for 7 days, then just <span>$5/mo</span>, <span>$49/yr</span>, or <span>$149 once</span>.
<p class="sub">
We believe the best way to build a superior product is to charge for it.
As a paid Snipt member, you'll have unrestricted access to the app, <a href="/api/">API</a>,

View File

@ -104,19 +104,32 @@ def pro_complete(request):
token = request.POST['token']
stripe.api_key = STRIPE_SECRET_KEY
plan = 'snipt-monthly'
# One-time plan.
if request.POST['plan'] == 'onetime':
customer = stripe.Customer.create(email=request.user.email,
card=token)
try:
stripe.Charge.create(amount=14900,
currency='usd',
customer=customer.id,
description='Snipt.net')
except stripe.CardError:
return HttpResponseRedirect('/pro/?declined=true')
if request.POST['plan'] == 'monthly':
plan = 'snipt-monthly'
elif request.POST['plan'] == 'yearly':
plan = 'snipt-yearly'
# Recurring plans.
else:
try:
customer = stripe.Customer.create(card=token,
plan=plan,
email=request.user.email)
except stripe.CardError:
return HttpResponseRedirect('/pro/?declined=true')
if request.POST['plan'] == 'monthly':
plan = 'snipt-monthly'
elif request.POST['plan'] == 'yearly':
plan = 'snipt-yearly'
try:
customer = stripe.Customer.create(card=token,
plan=plan,
email=request.user.email)
except stripe.CardError:
return HttpResponseRedirect('/pro/?declined=true')
profile = request.user.profile
profile.is_pro = True