From 83a63fc916d2cf5c8470c6be8c250c83f98eb86e Mon Sep 17 00:00:00 2001 From: Juliana Kang Date: Fri, 26 Apr 2024 10:40:08 -0400 Subject: [PATCH] refactor: DPM loading lag for successful payments redirect (#6) REV-4009 --- src/payment/PageLoading.jsx | 20 ++++++++++++ src/payment/PaymentPage.jsx | 31 +++++++++---------- src/payment/cart/CouponForm.jsx | 2 +- .../cart/__snapshots__/Cart.test.jsx.snap | 1 + .../__snapshots__/CouponForm.test.jsx.snap | 1 + .../payment-form/StripePaymentForm.jsx | 6 ++-- src/payment/payment-methods/stripe/service.js | 2 +- 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/payment/PageLoading.jsx b/src/payment/PageLoading.jsx index de61fb2b7..15e55c167 100644 --- a/src/payment/PageLoading.jsx +++ b/src/payment/PageLoading.jsx @@ -1,5 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; +import { getConfig } from '@edx/frontend-platform'; +import { logInfo } from '@edx/frontend-platform/logging'; export default class PageLoading extends Component { renderSrMessage() { @@ -15,6 +17,17 @@ export default class PageLoading extends Component { } render() { + const { shouldRedirectToReceipt, orderNumber } = this.props; + + if (shouldRedirectToReceipt) { + logInfo(`Dynamic Payment Methods payment succeeded for edX order number ${orderNumber}, redirecting to ecommerce receipt page.`); + const queryParams = `order_number=${orderNumber}&disable_back_button=${Number(true)}&dpm_enabled=${true}`; + if (getConfig().ENVIRONMENT !== 'test') { + /* istanbul ignore next */ + global.location.assign(`${getConfig().ECOMMERCE_BASE_URL}/checkout/receipt/?${queryParams}`); + } + } + return (
+ ); + } + // In all other cases, we want to render the basket content. This is used before we've loaded // anything, during loading, and after we've loaded a basket with a product in it. diff --git a/src/payment/cart/CouponForm.jsx b/src/payment/cart/CouponForm.jsx index d65ad2469..a79619a8f 100644 --- a/src/payment/cart/CouponForm.jsx +++ b/src/payment/cart/CouponForm.jsx @@ -44,7 +44,7 @@ class CouponForm extends Component { return (
- +