Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

fix: Passing paypal variable through to checkout if set #4169

Merged
merged 9 commits into from
Jul 5, 2024
9 changes: 8 additions & 1 deletion ecommerce/coupons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def get(self, request, *args, **kwargs):
"""Get method for coupon redemption page."""
return super(CouponOfferView, self).get(request, *args, **kwargs)


class CouponRedeemView(EdxOrderPlacementMixin, APIView):
permission_classes = (LoginRedirectIfUnauthenticated,)

Expand Down Expand Up @@ -303,7 +302,15 @@ def get(self, request): # pylint: disable=too-many-statements
# and should not display the payment form before making that determination.
# TODO: It would be cleaner if the user could be redirected to their final destination up front.
redirect_url = get_payment_microfrontend_or_basket_url(self.request) + "?coupon_redeem_redirect=1"

# Check for the paypal_redirect=1 parameter from the ecommerece checkout and add it to the redirect URL if present
paypal_redirect = request.GET.get('paypal_redirect')

if paypal_redirect:
redirect_url += "&paypal_redirect=1"

redirect_url = add_stripe_flag_to_url(redirect_url, self.request)

return HttpResponseRedirect(redirect_url)


Expand Down
6 changes: 6 additions & 0 deletions ecommerce/extensions/basket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ def _redirect_response_to_basket_or_payment(self, request, invalid_code=None):
redirect_url = get_payment_microfrontend_or_basket_url(request)
redirect_url = add_utm_params_to_url(redirect_url, list(self.request.GET.items()))
grmartin marked this conversation as resolved.
Show resolved Hide resolved
redirect_url = add_invalid_code_message_to_url(redirect_url, invalid_code)

# Check for the paypal_redirect=1 parameter from the ecommerece checkout and add it to the redirect URL if present
paypal_redirect = request.GET.get('paypal_redirect')

if paypal_redirect:
redirect_url += "?paypal_redirect=1"
redirect_url = add_stripe_flag_to_url(redirect_url, request)

return HttpResponseRedirect(redirect_url, status=303)
Expand Down
Loading