def get(self, request, *args, **kwargs): basket = request.basket try: properties = { 'cart_id': basket.id, 'products': [ translate_basket_line_for_segment(line) for line in basket.all_lines() ], } track_segment_event(request.site, request.user, 'Cart Viewed', properties) properties = {'checkout_id': basket.order_number, 'step': 1} track_segment_event(request.site, request.user, 'Checkout Step Viewed', properties) except Exception: # pylint: disable=broad-except logger.exception( 'Failed to fire Cart Viewed event for basket [%d]', basket.id) if has_enterprise_offer(basket) and basket.total_incl_tax == Decimal( 0): return redirect('checkout:free-checkout') else: return super(BasketSummaryView, self).get(request, *args, **kwargs)
def get_redirect_url(self, *args, **kwargs): request = self.request site = request.site basket = Basket.get_basket(request.user, site) if not basket.is_empty: # Need to re-apply the voucher to the basket. Applicator().apply(basket, request.user, request) if basket.total_incl_tax != Decimal(0): raise BasketNotFreeError( 'Basket [{}] is not free. User affected [{}]'.format( basket.id, basket.owner.id)) order = self.place_free_order(basket) if has_enterprise_offer(basket): # Skip the receipt page and redirect to the LMS # if the order is free due to an Enterprise-related offer. program_uuid = get_program_uuid(order) if program_uuid: url = get_lms_program_dashboard_url(program_uuid) else: course_run_id = order.lines.all()[:1].get( ).product.course.id url = get_lms_courseware_url(course_run_id) else: receipt_path = get_receipt_page_url( order_number=order.number, site_configuration=order.site.siteconfiguration) url = site.siteconfiguration.build_lms_url(receipt_path) else: # If a user's basket is empty redirect the user to the basket summary # page which displays the appropriate message for empty baskets. url = reverse('basket:summary') return url
def verify_enterprise_needs(self, basket): failed_enterprise_consent_code = self.request.GET.get( CONSENT_FAILED_PARAM) if failed_enterprise_consent_code: messages.error( self.request, _("Could not apply the code '{code}'; it requires data sharing consent." ).format(code=failed_enterprise_consent_code)) if has_enterprise_offer(basket) and basket.total_incl_tax == Decimal( 0): raise RedirectException(response=absolute_redirect( self.request, 'checkout:free-checkout'), )
def get(self, request, *args, **kwargs): basket = request.basket try: properties = { 'cart_id': basket.id, 'products': [ translate_basket_line_for_segment(line) for line in basket.all_lines() ], } track_segment_event(request.site, request.user, 'Cart Viewed', properties) properties = {'checkout_id': basket.order_number, 'step': 1} track_segment_event(request.site, request.user, 'Checkout Step Viewed', properties) except Exception: # pylint: disable=broad-except logger.exception( 'Failed to fire Cart Viewed event for basket [%d]', basket.id) if has_enterprise_offer(basket) and basket.total_incl_tax == Decimal( 0): return redirect('checkout:free-checkout') else: # lumsx is giving a thirdparty method for payment rather than a gateway so had to make a minimal # processor and integerate the API, if client side processor matches with the site configurations # than move forward towards API configuration_helpers = request.site.siteconfiguration.edly_client_theme_branding_settings custom_processor_name = configuration_helpers.get( 'PAYMENT_PROCESSOR_NAME') if custom_processor_name == self.request.site.siteconfiguration.client_side_payment_processor: # return LumsxpayExecutionView.get_voucher_api(request) return redirect_to_referrer(self.request, 'lumsxpay:execute') return super(BasketSummaryView, self).get(request, *args, **kwargs)