Support non-subscriptions in billing.
parent
ab7e9be51d
commit
95f56abcfe
|
@ -22,17 +22,24 @@ def stripe_account_details(request):
|
||||||
else:
|
else:
|
||||||
stripe.api_key = STRIPE_SECRET_KEY
|
stripe.api_key = STRIPE_SECRET_KEY
|
||||||
customer = stripe.Customer.retrieve(request.user.profile.stripe_id)
|
customer = stripe.Customer.retrieve(request.user.profile.stripe_id)
|
||||||
return {
|
|
||||||
|
data = {
|
||||||
'last4': customer.active_card.last4,
|
'last4': customer.active_card.last4,
|
||||||
'created': customer.created,
|
'created': customer.created,
|
||||||
'email': customer.email,
|
'email': customer.email,
|
||||||
'amount': customer.subscription.plan.amount,
|
|
||||||
'interval': customer.subscription.plan.interval,
|
|
||||||
'name': customer.subscription.plan.name,
|
|
||||||
'status': customer.subscription.status,
|
|
||||||
'nextBill': customer.subscription.current_period_end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if customer.subscription:
|
||||||
|
data['amount'] = customer.subscription.plan.amount
|
||||||
|
data['interval'] = customer.subscription.plan.interval
|
||||||
|
data['name'] = customer.subscription.plan.name
|
||||||
|
data['status'] = customer.subscription.status
|
||||||
|
data['nextBill'] = customer.subscription.current_period_end
|
||||||
|
else:
|
||||||
|
data['status'] = 'inactive'
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@render_to('stats.html')
|
@render_to('stats.html')
|
||||||
|
|
Loading…
Reference in New Issue