Last active
September 8, 2016 18:04
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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