Working on Stripe account details.
parent
e57fd05796
commit
3a1d8ca8c0
|
@ -4,5 +4,6 @@ from accounts import views
|
|||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^stats/$', views.stats, name='account-stats'),
|
||||
url(r'^stripe-account-details/$', views.stripe_account_details, name='stripe-account-details'),
|
||||
url(r'^', views.account, name='account-detail'),
|
||||
)
|
||||
|
|
|
@ -1,13 +1,38 @@
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponseRedirect
|
||||
from annoying.decorators import render_to
|
||||
from annoying.decorators import ajax_request, render_to
|
||||
from snipts.models import Snipt
|
||||
|
||||
import stripe
|
||||
|
||||
from settings_local import STRIPE_SECRET_KEY
|
||||
|
||||
|
||||
@login_required
|
||||
@render_to('account.html')
|
||||
def account(request):
|
||||
return {}
|
||||
|
||||
|
||||
@login_required
|
||||
@ajax_request
|
||||
def stripe_account_details(request):
|
||||
|
||||
if request.user.profile.stripe_id is None:
|
||||
return {}
|
||||
else:
|
||||
stripe.api_key = STRIPE_SECRET_KEY
|
||||
customer = stripe.Customer.retrieve(request.user.profile.stripe_id)
|
||||
return {
|
||||
'last4': customer.active_card.last4,
|
||||
'created': customer.created,
|
||||
'email': customer.email,
|
||||
'amount': customer.subscription.plan.amount,
|
||||
'interval': customer.subscription.plan.interval,
|
||||
'name': customer.subscription.plan.name,
|
||||
'status': customer.subscription.status,
|
||||
}
|
||||
|
||||
|
||||
@login_required
|
||||
@render_to('stats.html')
|
||||
def stats(request):
|
||||
|
|
|
@ -264,7 +264,7 @@ class PrivateUserProfileResource(ModelResource):
|
|||
class Meta:
|
||||
queryset = UserProfile.objects.all()
|
||||
resource_name = 'profile'
|
||||
excludes = ['is_pro', 'stripe_id']
|
||||
excludes = ['is_pro']
|
||||
validation = UserProfileValidation()
|
||||
include_absolute_url = False
|
||||
allowed_methods = ['get', 'put']
|
||||
|
|
Loading…
Reference in New Issue