Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AD-233 #390

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface State {
saveInAddressBook: boolean
errorCode: string
errorFieldCodes: string[]
orderNumber: string
}

interface ComponentProps {
Expand Down Expand Up @@ -78,7 +79,8 @@ class Payment extends React.Component<Props, State> {
redirectTo3DS: false,
saveInAddressBook: false,
errorCode: this.props.errorCode ? this.props.errorCode : "",
errorFieldCodes: []
errorFieldCodes: [],
orderNumber: ""
}
this.paymentRef = React.createRef();
this.threeDSRef = React.createRef();
Expand Down Expand Up @@ -178,6 +180,7 @@ class Payment extends React.Component<Props, State> {
if (responseData.is3DSRedirect) {
await this.mount3DSComponent(responseData.paymentsAction)
} else {
this.setState({orderNumber: responseData.orderNumber})
this.setState({redirectToNextStep: true})
}
} else {
Expand Down Expand Up @@ -253,9 +256,13 @@ class Payment extends React.Component<Props, State> {
return <></>
}

private getThankYouPageURL(): string {
return routes.thankYouPage + "/" + this.state.orderNumber
}

render() {
if (this.state.redirectToNextStep) {
return <Navigate to={routes.thankYouPage}/>
if (this.state.redirectToNextStep && isNotEmpty(this.state.orderNumber)) {
return <Navigate to={this.getThankYouPageURL()}/>
}

return (
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import {CartDataAction, cartDataInitialState, cartDataReducer} from "./cartDataR
import {BillingAddressAction, billingAddressReducer} from "./billingAddressReducer";
import {AdyenConfigAction, adyenConfigInitialState, adyenConfigReducer} from "./adyenConfigReducer";
import {AdyenConfigData} from "../types/adyenConfigData";
import {PlaceOrderData} from "../types/placeOrderData";
import {PlaceOrderDataAction, placeOrderDataInitialState, placeOrderDataReducer} from "./placeOrderDataReducer";
import {LoadingAction, loadingReducer, loadingStateInitialState} from "./loadingReducer";
import {LoadingState} from "../types/loadingState";
import {NotificationAction, notificationReducer, notificationInitialState} from "./notificationReducer";
import {NotificationAction, notificationInitialState, notificationReducer} from "./notificationReducer";

export const initialState: AppState = {
shippingAddress: addressInitialState,
Expand All @@ -29,7 +27,6 @@ export const initialState: AppState = {
cartData: cartDataInitialState,
billingAddress: addressInitialState,
adyenConfig: adyenConfigInitialState,
placeOrderData: placeOrderDataInitialState,
loadingState: loadingStateInitialState,
notifications: notificationInitialState
}
Expand All @@ -44,7 +41,6 @@ export const rootReducer: Reducer<AppState, RootAction, AppState> = function (ap
cartData: cartDataReducer(appState.cartData, action),
billingAddress: billingAddressReducer(appState.billingAddress, action),
adyenConfig: adyenConfigReducer(appState.adyenConfig, action),
placeOrderData: placeOrderDataReducer(appState.placeOrderData, action),
loadingState: loadingReducer(appState.loadingState, action),
notifications: notificationReducer(appState.notifications, action)
}
Expand All @@ -58,7 +54,6 @@ export interface AppState {
cartData: CartData,
billingAddress: AddressModel,
adyenConfig: AdyenConfigData,
placeOrderData: PlaceOrderData,
loadingState: LoadingState,
notifications: Notification[],
}
Expand All @@ -71,7 +66,6 @@ export type RootAction =
| CartDataAction
| BillingAddressAction
| AdyenConfigAction
| PlaceOrderDataAction
| LoadingAction
| NotificationAction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {routes} from "./routes";
import CheckoutStepWrapper from "../CheckoutStepWrapper";
import {ShippingMethodStep} from "../components/steps/ShippingMethodStep";
import {ThankYouPageUrlWrapper} from "../components/thank-you-page/ThankYouPageUrlWrapper";
import ThankYouPageStoreWrapper from "../components/thank-you-page/ThankYouPageStoreWrapper";
import {TranslationWrapper} from "../components/common/TranslationWrapper";
import NotificationWrapper from "../components/common/NotificationWrapper";
import {CheckoutSteps} from "../types/checkoutStepsEnum";
Expand Down Expand Up @@ -36,11 +35,6 @@ export const router = createBrowserRouter([
element: <TranslationWrapper><NotificationWrapper
checkoutStep={CheckoutSteps.PAYMENT_METHOD}><CheckoutStepWrapper><PaymentStep/></CheckoutStepWrapper></NotificationWrapper></TranslationWrapper>,
},
{
path: routes.thankYouPage,
element: <TranslationWrapper><NotificationWrapper
checkoutStep={CheckoutSteps.THANK_YOU_PAGE}><ThankYouPageStoreWrapper/></NotificationWrapper></TranslationWrapper>,
},
{
path: routes.thankYouPage + "/:orderCode",
element: <TranslationWrapper><NotificationWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {AxiosError, AxiosResponse} from "axios";
import {CSRFToken, urlContextPath} from "../util/baseUrlUtil";
import {AdyenAddressForm, AdyenPaymentForm} from "../types/paymentForm";
import {AddressModel} from "../reducers/types";
import {store} from "../store/store";
import {CardState} from "../types/paymentState";
import {PaymentAction} from "@adyen/adyen-web/dist/types/types";
import {ErrorResponse} from "../types/errorResponse";
Expand All @@ -14,6 +13,7 @@ export interface PaymentResponse {
paymentsAction?: PaymentAction,
error?: string,
errorFieldCodes?: string[]
orderNumber?: string
}

export class PaymentService {
Expand All @@ -25,13 +25,13 @@ export class PaymentService {
}
})
.then((response: AxiosResponse<any>): PaymentResponse => {
let placeOrderData = (response.data);
store.dispatch({type: "placeOrderData/setPlaceOrderData", payload: placeOrderData})
let placeOrderData = response.data;

return {
success: true,
is3DSRedirect: response.data.redirectTo3DS,
paymentsAction: response.data.paymentsAction
is3DSRedirect: placeOrderData.redirectTo3DS,
paymentsAction: placeOrderData.paymentsAction,
orderNumber: placeOrderData.orderNumber
}
})
.catch((errorResponse: AxiosError<ErrorResponse>): PaymentResponse | void => {
Expand Down
Loading