def get_context_data(self, **kwargs): """ Add data for Bpoint. """ # Override method so the bankcard and billing address forms can be # added to the context. ctx = super(PaymentDetailsView, self).get_context_data(**kwargs) method = self.checkout_session.payment_method() custom_template = self.checkout_session.custom_template() ctx['store_card'] = True user = None # only load stored cards if the user is an admin or has legitimately logged in if self.checkout_session.basket_owner() and is_payment_admin( self.request.user): user = EmailUser.objects.get( id=int(self.checkout_session.basket_owner())) elif self.request.user.is_authenticated(): user = self.request.user if user: cards = user.stored_cards.all() if cards: ctx['cards'] = cards ctx['custom_template'] = custom_template ctx['bpay_allowed'] = settings.BPAY_ALLOWED ctx['payment_method'] = method ctx['bankcard_form'] = kwargs.get('bankcard_form', forms.BankcardForm()) ctx['billing_address_form'] = kwargs.get('billing_address_form', forms.BillingAddressForm()) return ctx
def get_context_data(self, **kwargs): """ Add data for Bpoint. """ # Override method so the bankcard and billing address forms can be # added to the context. ctx = super(PaymentDetailsView, self).get_context_data(**kwargs) method = self.checkout_session.payment_method() custom_template = self.checkout_session.custom_template() ctx['store_card'] = True if self.checkout_session.basket_owner(): user = EmailUser.objects.get( id=int(self.checkout_session.basket_owner())) else: user = self.request.user cards = user.stored_cards.all() if cards: ctx['cards'] = cards ctx['custom_template'] = custom_template ctx['payment_method'] = method ctx['bankcard_form'] = kwargs.get('bankcard_form', forms.BankcardForm()) ctx['billing_address_form'] = kwargs.get('billing_address_form', forms.BillingAddressForm()) return ctx
def get_context_data(self, **kwargs): """ Add data for Bpoint. """ # Override method so the bankcard and billing address forms can be # added to the context. ctx = super(PaymentDetailsView, self).get_context_data(**kwargs) method = self.checkout_session.payment_method() custom_template = self.checkout_session.custom_template() if not self.checkout_session.checkoutWithToken(): ctx['store_card'] = True ctx['custom_template'] = custom_template ctx['payment_method'] = method ctx['bankcard_form'] = kwargs.get('bankcard_form', forms.BankcardForm()) ctx['billing_address_form'] = kwargs.get('billing_address_form', forms.BillingAddressForm()) return ctx