forked from uncloud/uncloud
in between commit to update for cc tests
This commit is contained in:
parent
8dd4b712fb
commit
df4c0c3060
6 changed files with 108 additions and 7 deletions
|
|
@ -1,3 +1,7 @@
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic.base import TemplateView
|
||||
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.db import transaction
|
||||
from django.contrib.auth import get_user_model
|
||||
|
|
@ -43,6 +47,25 @@ class OrderViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
def get_queryset(self):
|
||||
return Order.objects.filter(owner=self.request.user)
|
||||
|
||||
|
||||
class RegisterCard(LoginRequiredMixin, TemplateView):
|
||||
login_url = '/login/'
|
||||
|
||||
# This is not supposed to be "static" --
|
||||
# the idea is to be able to switch the provider when needed
|
||||
template_name = "uncloud_pay/stripe.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
customer_id = uncloud_stripe.get_customer_id_for(self.request.user)
|
||||
setup_intent = uncloud_stripe.create_setup_intent(customer_id)
|
||||
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['client_secret'] = setup_intent.client_secret
|
||||
context['username'] = self.request.user
|
||||
context['stripe_pk'] = uncloud_stripe.public_api_key
|
||||
return context
|
||||
|
||||
|
||||
class PaymentMethodViewSet(viewsets.ModelViewSet):
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue