Skip to content

Instantly share code, notes, and snippets.

@chozabu
Last active September 8, 2016 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chozabu/63f515be722234ea801f00b0cb639bee to your computer and use it in GitHub Desktop.
Save chozabu/63f515be722234ea801f00b0cb639bee to your computer and use it in GitHub Desktop.
Notes to self: The minor work I needed to do in app space to use djstripe.
from djstripe.contrib.rest_framework.views import SubscriptionRestView
class CustomSubscriptionRestView(SubscriptionRestView):
'''
This route expects data in this format \n
{
"stripe_token": "token-from-stripe.js",
"plan": "plan-name-from-settings.py"
}
'''
def post(self, request, format=None):
response = super(CustomSubscriptionRestView, self).post(request, format)
if response.status_code == status.HTTP_201_CREATED:
user = request.user
user.is_stripe_verified = True
user.re_calc_verifications()
user.save()
return response
class SubscriptionListView(APIView):
'''
This route gives a list of stripe plans - the plains main key should be passed to the subscribe view
'''
def get(self, request):
return Response(settings.DJSTRIPE_PLANS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment