@lookiero/checkout 9.9.0-beta.2 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fake-dependencies/@lookiero/payments-front/index.d.ts +6 -8
- package/dist/fake-dependencies/@lookiero/payments-front/index.js +4 -7
- package/dist/index.js +2 -2
- package/dist/src/ExpoRoot.js +12 -16
- package/dist/src/infrastructure/ui/Root.d.ts +2 -0
- package/dist/src/infrastructure/ui/Root.js +4 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.d.ts +0 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.js +0 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.d.ts +0 -1
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.js +0 -1
- package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.d.ts +2 -3
- package/dist/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.js +26 -17
- package/dist/src/infrastructure/ui/hooks/useQueryBus.d.ts +9 -0
- package/dist/src/infrastructure/ui/hooks/useQueryBus.js +10 -0
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.d.ts +1 -1
- package/dist/src/infrastructure/ui/hooks/useSubmitCheckout.js +55 -22
- package/dist/src/infrastructure/ui/i18n/i18n.d.ts +0 -1
- package/dist/src/infrastructure/ui/i18n/i18n.js +0 -1
- package/dist/src/infrastructure/ui/views/App.js +6 -5
- package/dist/src/infrastructure/ui/views/checkout/Checkout.js +2 -5
- package/dist/src/infrastructure/ui/views/checkout/Checkout.style.d.ts +0 -3
- package/dist/src/infrastructure/ui/views/checkout/Checkout.style.js +0 -3
- package/dist/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.js +2 -2
- package/dist/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.js +7 -7
- package/dist/src/projection/customer/customer.d.ts +0 -2
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/fake-dependencies/@lookiero/payments-front/index.tsx +9 -32
- package/index.ts +2 -2
- package/package.json +7 -7
- package/src/ExpoRoot.tsx +31 -36
- package/src/infrastructure/ui/Root.tsx +30 -17
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.ts +0 -1
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +1 -0
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.ts +0 -1
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +1 -0
- package/src/infrastructure/ui/hooks/usePaymentInstrumentEvents.ts +60 -18
- package/src/infrastructure/ui/hooks/useQueryBus.test.tsx +23 -0
- package/src/infrastructure/ui/hooks/useQueryBus.tsx +27 -0
- package/src/infrastructure/ui/hooks/useSubmitCheckout.test.ts +58 -0
- package/src/infrastructure/ui/hooks/useSubmitCheckout.ts +77 -33
- package/src/infrastructure/ui/i18n/i18n.ts +0 -1
- package/src/infrastructure/ui/views/App.tsx +13 -5
- package/src/infrastructure/ui/views/checkout/Checkout.style.ts +0 -3
- package/src/infrastructure/ui/views/checkout/Checkout.tsx +3 -12
- package/src/infrastructure/ui/views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal.tsx +2 -2
- package/src/infrastructure/ui/views/checkout/components/paymentInstrument/PaymentInstrument.tsx +8 -8
- package/src/projection/customer/customer.ts +0 -2
- package/dist/pact.config.d.ts +0 -21
- package/dist/pact.config.js +0 -16
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/bookedProductsVariants/httpBookedProductsVariantsForCheckoutItemView.pact.js +0 -55
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkout/httpCheckoutByIdView.pact.js +0 -116
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.pact.js +0 -56
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.pact.js +0 -51
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.pact.js +0 -51
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkout/httpIsSizeChangeEnabledByCheckoutIdView.pact.js +0 -51
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +0 -13
- package/dist/src/infrastructure/projection/checkout/react/useViewIsCheckoutAccessibleByCustomerId.js +0 -19
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkoutBooking/httpCheckoutBookingByIdView.pact.js +0 -56
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.pact.js +0 -57
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/checkoutQuestion/httpCheckoutQuestionsByCheckoutIdView.pact.js +0 -55
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/payment/httpPaymentFlowPayloadByCheckoutIdView.pact.js +0 -120
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/pricing/httpPricingByCheckoutIdView.pact.js +0 -55
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.d.ts +0 -1
- package/dist/src/infrastructure/projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView.pact.js +0 -55
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.d.ts +0 -22
- package/dist/src/infrastructure/ui/components/layouts/layout/Layout.js +0 -1
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.d.ts +0 -7
- package/dist/src/infrastructure/ui/components/layouts/layout/components/footer/Footer.js +0 -5
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.d.ts +0 -7
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.js +0 -6
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.d.ts +0 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/components/header/Header.style.js +0 -20
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.d.ts +0 -4
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.js +0 -43
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.d.ts +0 -12
- package/dist/src/infrastructure/ui/components/layouts/layout/dummyLayout/DummyLayout.style.js +0 -14
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.d.ts +0 -7
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.js +0 -21
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.d.ts +0 -8
- package/dist/src/infrastructure/ui/components/templates/header/defaultHeader/DefaultHeader.style.js +0 -12
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +0 -12
- package/dist/src/infrastructure/ui/hooks/useNewFeedbackExperiment.js +0 -64
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.d.ts +0 -10
- package/dist/src/infrastructure/ui/i18n/fetchTranslations.js +0 -17
- package/dist/src/infrastructure/ui/i18n/translationEndpoint.d.ts +0 -20
- package/dist/src/infrastructure/ui/i18n/translationEndpoint.js +0 -27
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +0 -10
- package/dist/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +0 -27
- package/dist/src/infrastructure/ui/views/App.style.d.ts +0 -6
- package/dist/src/infrastructure/ui/views/App.style.js +0 -8
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.d.ts +0 -7
- package/dist/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.style.js +0 -11
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.d.ts +0 -12
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.js +0 -64
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.d.ts +0 -12
- package/dist/src/infrastructure/ui/views/item/components/returnQuestionsForm/ReturnQuestionsForm.style.js +0 -16
- package/dist/src/infrastructure/ui/views/return/Return.style.d.ts +0 -40
- package/dist/src/infrastructure/ui/views/return/Return.style.js +0 -44
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.d.ts +0 -14
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.js +0 -28
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.d.ts +0 -7
- package/dist/src/infrastructure/ui/views/summary/components/stickyPricing/StickyPricing.style.js +0 -11
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +0 -26
- package/dist/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +0 -21
- package/dist/src/projection/shared/country.d.ts +0 -14
- package/dist/src/projection/shared/country.js +0 -15
- package/dist/src/projection/shared/customer.d.ts +0 -9
- package/dist/src/projection/shared/customer.js +0 -1
- package/dist/src/projection/shared/locale.d.ts +0 -12
- package/dist/src/projection/shared/locale.js +0 -13
- package/dist/src/projection/shared/order.d.ts +0 -6
- package/dist/src/projection/shared/order.js +0 -1
- package/dist/src/projection/shared/price.d.ts +0 -11
- package/dist/src/projection/shared/price.js +0 -1
- package/dist/src/projection/shared/size.d.ts +0 -21
- package/dist/src/projection/shared/size.js +0 -4
- package/dist/src/projection/shared/subscription.d.ts +0 -2
- package/dist/src/projection/shared/subscription.js +0 -1
- package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.d.ts +0 -15
- package/dist/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.js +0 -16
- package/dist/src/shared/ui/components/atoms/error/Error.d.ts +0 -11
- package/dist/src/shared/ui/components/atoms/error/Error.js +0 -6
- package/dist/src/shared/ui/components/atoms/field/Field.d.ts +0 -14
- package/dist/src/shared/ui/components/atoms/field/Field.js +0 -29
- package/dist/src/shared/ui/components/atoms/field/Field.style.d.ts +0 -16
- package/dist/src/shared/ui/components/atoms/field/Field.style.js +0 -19
- package/dist/src/shared/ui/components/molecules/inputField/InputField.d.ts +0 -24
- package/dist/src/shared/ui/components/molecules/inputField/InputField.js +0 -28
- package/dist/src/shared/ui/components/molecules/inputField/InputField.style.d.ts +0 -29
- package/dist/src/shared/ui/components/molecules/inputField/InputField.style.js +0 -37
|
@@ -7,57 +7,34 @@ import {
|
|
|
7
7
|
RefAttributes,
|
|
8
8
|
useImperativeHandle,
|
|
9
9
|
} from "react";
|
|
10
|
-
import { PaymentPayload } from "@lookiero/payments-front";
|
|
11
10
|
|
|
12
11
|
const setPaymentsBridge = () => void 0;
|
|
13
12
|
const PaymentsQueryProvider: FC<PropsWithChildren> = ({ children }) => children;
|
|
14
13
|
const PaymentInstrumentSelect: FC = () => null;
|
|
15
|
-
|
|
14
|
+
interface StartLegacyBoxCheckoutCallbackArgs {
|
|
15
|
+
readonly status: string;
|
|
16
|
+
readonly final: boolean;
|
|
17
|
+
}
|
|
16
18
|
interface StartLegacyBoxCheckoutFunction {
|
|
17
|
-
(paymentFlowPayload: unknown): void;
|
|
19
|
+
(paymentFlowPayload: unknown, callback: (params: StartLegacyBoxCheckoutCallbackArgs) => Promise<void>): void;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
21
|
interface PaymentFlowRef {
|
|
21
22
|
readonly startLegacyBoxCheckout: StartLegacyBoxCheckoutFunction;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
24
|
const paymentFlowRef: PaymentFlowRef = {
|
|
25
|
-
startLegacyBoxCheckout: async () => {
|
|
25
|
+
startLegacyBoxCheckout: async (_paymentFlowPayload, callback) => {
|
|
26
|
+
await callback({ status: "EXECUTED", final: true });
|
|
27
|
+
},
|
|
26
28
|
};
|
|
27
|
-
|
|
28
29
|
const PaymentFlow: ForwardRefExoticComponent<RefAttributes<PaymentFlowRef>> = forwardRef<PaymentFlowRef, unknown>(
|
|
29
30
|
(_props, ref) => {
|
|
30
31
|
useImperativeHandle(ref, () => paymentFlowRef, []);
|
|
31
32
|
return null;
|
|
32
33
|
},
|
|
33
34
|
);
|
|
34
|
-
|
|
35
35
|
PaymentFlow.displayName = "PaymentFlow";
|
|
36
|
-
|
|
37
|
-
interface UsePaymentStatusManagerResult {
|
|
38
|
-
isLoading: boolean;
|
|
39
|
-
consumePayload: (callback: (payload: PaymentPayload) => void) => void;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const paymentStatusManagerResult: UsePaymentStatusManagerResult = {
|
|
43
|
-
isLoading: false,
|
|
44
|
-
consumePayload: (callback) => callback({ success: true } as PaymentPayload),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const usePaymentStatusManager: (section: Section) => UsePaymentStatusManagerResult = () => paymentStatusManagerResult;
|
|
48
|
-
|
|
49
36
|
enum Section {
|
|
50
37
|
BOX_CHECKOUT = "box-checkout",
|
|
51
38
|
}
|
|
52
|
-
|
|
53
39
|
export type { PaymentFlowRef };
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
PaymentsQueryProvider,
|
|
57
|
-
PaymentInstrumentSelect,
|
|
58
|
-
PaymentFlow,
|
|
59
|
-
Section,
|
|
60
|
-
setPaymentsBridge,
|
|
61
|
-
paymentFlowRef,
|
|
62
|
-
usePaymentStatusManager,
|
|
63
|
-
};
|
|
40
|
+
export { PaymentsQueryProvider, PaymentInstrumentSelect, PaymentFlow, Section, setPaymentsBridge, paymentFlowRef };
|
package/index.ts
CHANGED
|
@@ -44,14 +44,14 @@ const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken, translations, sent
|
|
|
44
44
|
const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
|
|
45
45
|
const I18n = i18n({
|
|
46
46
|
fetchTranslation: fetchTranslations({ translations }),
|
|
47
|
-
|
|
47
|
+
domain: "CheckoutI18n",
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
const firstAvailableCheckoutByCustomerId: FirstAvailableCheckoutByCustomerIdFunction = ({ customerId }) =>
|
|
51
51
|
queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId: customerId as string }));
|
|
52
52
|
|
|
53
53
|
return {
|
|
54
|
-
root: root({ Messaging, I18n, getAuthToken, sentry, kameleoon }),
|
|
54
|
+
root: root({ Messaging, I18n, queryBus, getAuthToken, sentry, kameleoon }),
|
|
55
55
|
firstAvailableCheckoutByCustomerId,
|
|
56
56
|
};
|
|
57
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "9.9.0
|
|
3
|
+
"version": "9.9.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": "false",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"@lookiero/sty-psp-ab-testing": "^0.3",
|
|
25
25
|
"@lookiero/sty-psp-expo-config": "^0.2",
|
|
26
26
|
"@lookiero/sty-psp-http": "^2.0",
|
|
27
|
-
"@lookiero/sty-psp-i18n": "^0.
|
|
27
|
+
"@lookiero/sty-psp-i18n": "^0.3",
|
|
28
28
|
"@lookiero/sty-psp-locale": "^0.4",
|
|
29
29
|
"@lookiero/sty-psp-logging": "^0.5",
|
|
30
|
-
"@lookiero/sty-psp-notifications": "^0.
|
|
30
|
+
"@lookiero/sty-psp-notifications": "^0.7",
|
|
31
31
|
"@lookiero/sty-psp-react-native": "^0.3",
|
|
32
32
|
"@lookiero/sty-psp-segment": "^0.1",
|
|
33
33
|
"@lookiero/sty-psp-storage": "^0.2",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@cypress/webpack-preprocessor": "^6.0.2",
|
|
47
47
|
"@lookiero/eslint-config-sty-psp": "*",
|
|
48
48
|
"@lookiero/event": "^0.3",
|
|
49
|
-
"@lookiero/payments-front": "
|
|
49
|
+
"@lookiero/payments-front": "6.0.3",
|
|
50
50
|
"@lookiero/sty-psp-jest-config": "*",
|
|
51
51
|
"@lookiero/sty-psp-prettier-config": "*",
|
|
52
52
|
"@lookiero/sty-psp-scripts": "*",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"@lookiero/aurora-fonts": ">=2",
|
|
75
75
|
"@lookiero/aurora-iconfont": ">=3",
|
|
76
76
|
"@lookiero/event": "^0.3",
|
|
77
|
-
"@lookiero/i18n": ">=
|
|
78
|
-
"@lookiero/i18n-react": ">=
|
|
79
|
-
"@lookiero/payments-front": "
|
|
77
|
+
"@lookiero/i18n": ">=1",
|
|
78
|
+
"@lookiero/i18n-react": ">=1",
|
|
79
|
+
"@lookiero/payments-front": "6.0.3",
|
|
80
80
|
"apollo-boost": "0.4.4",
|
|
81
81
|
"expo": ">=51",
|
|
82
82
|
"expo-font": ">=12",
|
package/src/ExpoRoot.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PortalProvider } from "@gorhom/portal";
|
|
2
1
|
import { useFonts } from "expo-font";
|
|
3
2
|
import "expo/build/Expo.fx";
|
|
4
3
|
import React, { FC, useCallback, useState } from "react";
|
|
@@ -36,8 +35,6 @@ const customer: Customer = {
|
|
|
36
35
|
customerId: "d3c2354b-9811-46d4-b2ba-5fba012ed94d",
|
|
37
36
|
country: Country.ES,
|
|
38
37
|
segment: Segment.WOMEN,
|
|
39
|
-
email: "email@example.com",
|
|
40
|
-
name: "Adèle Léonce Émilie",
|
|
41
38
|
};
|
|
42
39
|
|
|
43
40
|
const sentryConfig: SentryEnvironment = {
|
|
@@ -54,7 +51,7 @@ const apiUrl =
|
|
|
54
51
|
? "/local-to-dev"
|
|
55
52
|
: "/checkout/api";
|
|
56
53
|
const authToken =
|
|
57
|
-
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
54
|
+
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjU2NDg3OTAsImV4cCI6MTc0MjM2OTcyNywiZGlzcGxheU5hbWUiOiJUZXN0aW5nIiwiY291bnRyeV9jb2RlIjoiRVMiLCJhY2Nlc3NWaWEiOiJlbWFpbCIsInN1YnNjcmlwdGlvblN0YXJ0aW5nRGF0ZSI6IjIwMjQtMTEtMDgiLCJpbXBlcnNvbmF0ZWQiOmZhbHNlLCJ1dWlkIjoiNzRjYjRmNzYtM2YxNC00OTgzLTgxYTYtMmVlMmE5YTI3NWQ0IiwiaWF0IjoxNzM5OTUwNTI3fQ.ajNczGc6YhM23--PsqlAoDrp_GN87TnHEBOYyg2hoWM";
|
|
58
55
|
const getAuthToken = () => Promise.resolve(authToken);
|
|
59
56
|
|
|
60
57
|
const externalTranslationsUrl =
|
|
@@ -95,7 +92,6 @@ setPaymentsBridge({
|
|
|
95
92
|
useFeatureFlags: () => ({}),
|
|
96
93
|
locale: () => Promise.resolve("es-ES"),
|
|
97
94
|
scrollView: ScrollView,
|
|
98
|
-
hostUrl: "",
|
|
99
95
|
});
|
|
100
96
|
|
|
101
97
|
const kameleoonConfig: KameleoonEnvironment = {
|
|
@@ -103,17 +99,18 @@ const kameleoonConfig: KameleoonEnvironment = {
|
|
|
103
99
|
experiments: {},
|
|
104
100
|
};
|
|
105
101
|
|
|
106
|
-
const { Component: Messaging } =
|
|
102
|
+
const { Component: Messaging, queryBus } =
|
|
107
103
|
process.env.EXPO_PUBLIC_APP_VARIANT === "test"
|
|
108
104
|
? checkoutMockBootstrap()
|
|
109
105
|
: checkoutBootstrap({ apiUrl: () => apiUrl, getAuthToken });
|
|
110
106
|
const I18n = i18n({
|
|
111
107
|
fetchTranslation: fetchTranslations({ translations }),
|
|
112
|
-
|
|
108
|
+
domain: "CheckoutI18n",
|
|
113
109
|
});
|
|
114
110
|
const Root = root({
|
|
115
111
|
Messaging,
|
|
116
112
|
I18n,
|
|
113
|
+
queryBus,
|
|
117
114
|
getAuthToken,
|
|
118
115
|
development: false,
|
|
119
116
|
sentry: () => (process.env.EXPO_PUBLIC_APP_VARIANT === "test" ? ({} as SentryEnvironment) : sentryConfig),
|
|
@@ -132,37 +129,35 @@ const ExpoRoot: FC = () => {
|
|
|
132
129
|
const onNotAccessible = useCallback(() => setIsAccessible(false), []);
|
|
133
130
|
|
|
134
131
|
return fontsLoaded ? (
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
{isAccessible === false && <Text heading={true}>Checkout is not accessible!</Text>}
|
|
132
|
+
<PaymentsQueryProvider>
|
|
133
|
+
<EventProvider>
|
|
134
|
+
<Aurora>
|
|
135
|
+
{isAccessible === false && <Text heading={true}>Checkout is not accessible!</Text>}
|
|
140
136
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
137
|
+
<Router>
|
|
138
|
+
<Routes>
|
|
139
|
+
<Route
|
|
140
|
+
path="/checkout/*"
|
|
141
|
+
element={
|
|
142
|
+
<Root
|
|
143
|
+
basePath="/checkout"
|
|
144
|
+
customer={customer}
|
|
145
|
+
layout={DummyLayout}
|
|
146
|
+
locale={locale}
|
|
147
|
+
order={order}
|
|
148
|
+
subscription={subscription}
|
|
149
|
+
useRedirect={useRedirect}
|
|
150
|
+
onNotAccessible={onNotAccessible}
|
|
151
|
+
/>
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
158
154
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
</PortalProvider>
|
|
155
|
+
<Route element={<Navigate to="/checkout" replace />} path="*" />
|
|
156
|
+
</Routes>
|
|
157
|
+
</Router>
|
|
158
|
+
</Aurora>
|
|
159
|
+
</EventProvider>
|
|
160
|
+
</PaymentsQueryProvider>
|
|
166
161
|
) : null;
|
|
167
162
|
};
|
|
168
163
|
|
|
@@ -3,6 +3,7 @@ import React, { ComponentType, useCallback } from "react";
|
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
4
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
5
5
|
import { I18n } from "@lookiero/i18n-react";
|
|
6
|
+
import { QueryBus } from "@lookiero/messaging";
|
|
6
7
|
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
7
8
|
import { Locale } from "@lookiero/sty-psp-locale";
|
|
8
9
|
import { SentryEnvironment, SentryLoggerFunctionArgs, sentryLogger, sentryLoggerHOC } from "@lookiero/sty-psp-logging";
|
|
@@ -11,11 +12,13 @@ import { Customer } from "../../projection/customer/customer";
|
|
|
11
12
|
import { Order } from "../../projection/order/order";
|
|
12
13
|
import { Subscription } from "../../projection/subscription/subscription";
|
|
13
14
|
import { KameleoonEnvironment } from "../ab-testing/kameleoonEnvironment";
|
|
15
|
+
import { QueryBusProvider } from "./hooks/useQueryBus";
|
|
14
16
|
import { Routing } from "./routing/Routing";
|
|
15
17
|
|
|
16
18
|
interface RootFunctionArgs {
|
|
17
19
|
readonly Messaging: MessagingRoot;
|
|
18
20
|
readonly I18n: I18n;
|
|
21
|
+
readonly queryBus: QueryBus;
|
|
19
22
|
readonly development?: boolean;
|
|
20
23
|
readonly sentry: () => SentryEnvironment;
|
|
21
24
|
readonly getAuthToken: () => Promise<string>;
|
|
@@ -39,7 +42,15 @@ interface RootProps {
|
|
|
39
42
|
readonly useRoutes?: typeof reactRouterUseRoutes;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
const root: RootFunction = ({
|
|
45
|
+
const root: RootFunction = ({
|
|
46
|
+
Messaging,
|
|
47
|
+
I18n,
|
|
48
|
+
queryBus,
|
|
49
|
+
getAuthToken,
|
|
50
|
+
development,
|
|
51
|
+
sentry,
|
|
52
|
+
kameleoon: kameleoonConfig,
|
|
53
|
+
}) => {
|
|
43
54
|
const logger = sentryLogger(sentry);
|
|
44
55
|
const kameleoon = kameleoonConfig();
|
|
45
56
|
|
|
@@ -60,22 +71,24 @@ const root: RootFunction = ({ Messaging, I18n, getAuthToken, development, sentry
|
|
|
60
71
|
|
|
61
72
|
return (
|
|
62
73
|
<Messaging includeReactQueryDevTools={Platform.OS === "web"}>
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
<QueryBusProvider queryBus={queryBus}>
|
|
75
|
+
<Routing
|
|
76
|
+
I18n={I18n}
|
|
77
|
+
basePath={basePath}
|
|
78
|
+
customer={customer}
|
|
79
|
+
getAuthToken={getAuthToken}
|
|
80
|
+
kameleoon={kameleoon}
|
|
81
|
+
layout={layout}
|
|
82
|
+
locale={locale}
|
|
83
|
+
order={order}
|
|
84
|
+
subscription={subscription}
|
|
85
|
+
useRedirect={useRedirect}
|
|
86
|
+
useRoutes={useRoutes}
|
|
87
|
+
onCheckoutSubmitted={onCheckoutSubmitted}
|
|
88
|
+
onI18nError={development ? undefined : handleOnI18nError}
|
|
89
|
+
onNotAccessible={onNotAccessible}
|
|
90
|
+
/>
|
|
91
|
+
</QueryBusProvider>
|
|
79
92
|
</Messaging>
|
|
80
93
|
);
|
|
81
94
|
};
|
|
@@ -1,33 +1,75 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useEffect } from "react";
|
|
2
|
+
import { useEvent } from "@lookiero/event";
|
|
3
|
+
import { Logger } from "@lookiero/sty-psp-logging";
|
|
4
|
+
import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp-notifications";
|
|
5
|
+
import { MESSAGING_CONTEXT_ID } from "../../delivery/baseBootstrap";
|
|
6
|
+
import { I18nMessages } from "../i18n/i18n";
|
|
7
|
+
|
|
8
|
+
const PAYMENT_ERROR = "ERROR";
|
|
9
|
+
const PAYMENT_SUCCESS = "PAYMENT_INSTRUMENT_UPDATED";
|
|
10
|
+
|
|
11
|
+
interface Message {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
}
|
|
14
|
+
interface OnSuccessFunctionArgs {
|
|
15
|
+
readonly message: Message;
|
|
16
|
+
}
|
|
17
|
+
interface OnSuccessFunction {
|
|
18
|
+
(args: OnSuccessFunctionArgs): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Toaster {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
}
|
|
24
|
+
interface Error {
|
|
25
|
+
readonly toaster?: Toaster;
|
|
26
|
+
}
|
|
27
|
+
interface OnErrorFunctionArgs {
|
|
28
|
+
readonly error: Error;
|
|
29
|
+
}
|
|
30
|
+
interface OnErrorFunction {
|
|
31
|
+
(args: OnErrorFunctionArgs): void;
|
|
32
|
+
}
|
|
3
33
|
|
|
4
34
|
interface UsePaymentInstrumentEventsFunctionArgs {
|
|
5
|
-
readonly
|
|
6
|
-
readonly onError: (payload: PaymentPayload) => void;
|
|
35
|
+
readonly logger: Logger;
|
|
7
36
|
}
|
|
8
37
|
|
|
9
38
|
interface UsePaymentInstrumentEventsFunction {
|
|
10
39
|
(args: UsePaymentInstrumentEventsFunctionArgs): void;
|
|
11
40
|
}
|
|
12
41
|
|
|
13
|
-
const usePaymentInstrumentEvents: UsePaymentInstrumentEventsFunction = ({
|
|
14
|
-
const
|
|
42
|
+
const usePaymentInstrumentEvents: UsePaymentInstrumentEventsFunction = ({ logger }) => {
|
|
43
|
+
const { subscribe, unsubscribe } = useEvent();
|
|
15
44
|
|
|
16
|
-
|
|
17
|
-
const { isLoading, consumePayload } = refreshStatus;
|
|
45
|
+
const [createNotification] = useCreateToastNotification({ contextId: MESSAGING_CONTEXT_ID, logger });
|
|
18
46
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
47
|
+
const onSuccess: OnSuccessFunction = useCallback(
|
|
48
|
+
({ message }) => createNotification({ bodyI18nKey: message.id, level: NotificationLevel.SUCCESS }),
|
|
49
|
+
[createNotification],
|
|
50
|
+
);
|
|
22
51
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
52
|
+
const onError: OnErrorFunction = useCallback(
|
|
53
|
+
({ error }) => {
|
|
54
|
+
if (error.toaster) {
|
|
55
|
+
createNotification({
|
|
56
|
+
bodyI18nKey: error.toaster.id || I18nMessages.CHECKOUT_TOAST_PAYMENT_ERROR,
|
|
57
|
+
level: NotificationLevel.ERROR,
|
|
58
|
+
});
|
|
28
59
|
}
|
|
29
|
-
}
|
|
30
|
-
|
|
60
|
+
},
|
|
61
|
+
[createNotification],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
subscribe({ event: PAYMENT_ERROR }, onError);
|
|
66
|
+
subscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
unsubscribe({ event: PAYMENT_ERROR }, onError);
|
|
70
|
+
unsubscribe({ event: PAYMENT_SUCCESS }, onSuccess);
|
|
71
|
+
};
|
|
72
|
+
}, [subscribe, unsubscribe, createNotification, onError, onSuccess]);
|
|
31
73
|
};
|
|
32
74
|
|
|
33
75
|
export { usePaymentInstrumentEvents };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
|
+
import { mockFn } from "jest-mock-extended";
|
|
3
|
+
import React, { FC } from "react";
|
|
4
|
+
import { QueryBus } from "@lookiero/messaging";
|
|
5
|
+
import { QueryBusProvider, useQueryBus as sut } from "./useQueryBus";
|
|
6
|
+
|
|
7
|
+
const mockQueryBus = mockFn<QueryBus>();
|
|
8
|
+
|
|
9
|
+
interface WrapperProps {
|
|
10
|
+
readonly children: JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Wrapper: FC<WrapperProps> = ({ children }) => (
|
|
14
|
+
<QueryBusProvider queryBus={mockQueryBus}>{children}</QueryBusProvider>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
describe("useQueryBus hook", () => {
|
|
18
|
+
it("returns the QueryBusProvider provided queryBus", async () => {
|
|
19
|
+
const { result } = renderHook(() => sut(), { wrapper: Wrapper });
|
|
20
|
+
|
|
21
|
+
await waitFor(() => expect(result.current).toEqual(mockQueryBus));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { createContext, FC, ReactNode, useContext } from "react";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
import { QueryBus } from "@lookiero/messaging";
|
|
4
|
+
|
|
5
|
+
const QueryBusContext = createContext<QueryBus>(null as unknown as QueryBus);
|
|
6
|
+
|
|
7
|
+
interface QueryBusProviderProps {
|
|
8
|
+
readonly children: ReactNode;
|
|
9
|
+
readonly queryBus: QueryBus;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const QueryBusProvider: FC<QueryBusProviderProps> = ({ children, queryBus }) => (
|
|
13
|
+
<QueryBusContext.Provider value={queryBus}>{children}</QueryBusContext.Provider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const useQueryBus = () => {
|
|
17
|
+
const queryBus = useContext(QueryBusContext);
|
|
18
|
+
|
|
19
|
+
invariant(
|
|
20
|
+
queryBus,
|
|
21
|
+
"Your are trying to use the useQueryBus hook without wrapping your app with the <QueryBusProvider>.",
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return queryBus;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { useQueryBus, QueryBusProvider };
|
|
@@ -6,9 +6,11 @@ import { PaymentFlowRef } from "@lookiero/payments-front";
|
|
|
6
6
|
import { ChargeStatus } from "@lookiero/payments-front/build/infrastructure/CheckoutAPI";
|
|
7
7
|
import { Logger } from "@lookiero/sty-psp-logging";
|
|
8
8
|
import { NotificationLevel, useCreateToastNotification } from "@lookiero/sty-psp-notifications";
|
|
9
|
+
import { CheckoutBookingProjection } from "../../../projection/checkoutBooking/checkoutBooking";
|
|
9
10
|
import { useSubmitCheckout } from "../../domain/checkout/react/useSubmitCheckout";
|
|
10
11
|
import { useBlockCheckoutBooking } from "../../domain/checkoutBooking/react/useBlockCheckoutBooking";
|
|
11
12
|
import { paymentFlowPayload as mockPaymentFlowPayload } from "../../projection/payment/paymentFlowPayload.mock";
|
|
13
|
+
import { useQueryBus } from "./useQueryBus";
|
|
12
14
|
import { useSubmitCheckout as sut } from "./useSubmitCheckout";
|
|
13
15
|
|
|
14
16
|
const checkoutId = "9c450400-0cd7-44a4-b0e3-e0002a9bf8df";
|
|
@@ -18,6 +20,7 @@ const errorChargeStatuses = Object.values(ChargeStatus).filter((status) => statu
|
|
|
18
20
|
const logger = mock<Logger>();
|
|
19
21
|
|
|
20
22
|
jest.mock("@lookiero/sty-psp-notifications");
|
|
23
|
+
jest.mock("./useQueryBus");
|
|
21
24
|
jest.mock("../../domain/checkout/react/useSubmitCheckout");
|
|
22
25
|
jest.mock("../../domain/checkoutBooking/react/useBlockCheckoutBooking");
|
|
23
26
|
|
|
@@ -38,6 +41,7 @@ describe("useSubmitCheckout custom hook", () => {
|
|
|
38
41
|
},
|
|
39
42
|
};
|
|
40
43
|
|
|
44
|
+
(useQueryBus as jest.Mock).mockReturnValue(() => ({ isExpired: false }) as CheckoutBookingProjection);
|
|
41
45
|
(useBlockCheckoutBooking as jest.Mock).mockReturnValue([mockBlockCheckoutBooking, CommandStatus.SUCCESS]);
|
|
42
46
|
(useCreateToastNotification as jest.Mock).mockReturnValue([mockCreateToastNotification, CommandStatus.SUCCESS]);
|
|
43
47
|
(useSubmitCheckout as jest.Mock).mockReturnValue([mockSubmitCheckout, CommandStatus.SUCCESS]);
|
|
@@ -86,6 +90,7 @@ describe("useSubmitCheckout custom hook", () => {
|
|
|
86
90
|
},
|
|
87
91
|
};
|
|
88
92
|
|
|
93
|
+
(useQueryBus as jest.Mock).mockReturnValue(() => ({ isExpired: false }) as CheckoutBookingProjection);
|
|
89
94
|
(useBlockCheckoutBooking as jest.Mock).mockReturnValue([mockBlockCheckoutBooking, CommandStatus.SUCCESS]);
|
|
90
95
|
(useCreateToastNotification as jest.Mock).mockReturnValue([mockCreateToastNotification, CommandStatus.SUCCESS]);
|
|
91
96
|
(useSubmitCheckout as jest.Mock).mockReturnValue([mockSubmitCheckout, CommandStatus.SUCCESS]);
|
|
@@ -126,6 +131,7 @@ describe("useSubmitCheckout custom hook", () => {
|
|
|
126
131
|
},
|
|
127
132
|
};
|
|
128
133
|
|
|
134
|
+
(useQueryBus as jest.Mock).mockReturnValue(() => ({ isExpired: false }) as CheckoutBookingProjection);
|
|
129
135
|
(useBlockCheckoutBooking as jest.Mock).mockReturnValue([mockBlockCheckoutBooking, CommandStatus.ERROR]);
|
|
130
136
|
(useCreateToastNotification as jest.Mock).mockReturnValue([mockCreateToastNotification, CommandStatus.IDLE]);
|
|
131
137
|
(useSubmitCheckout as jest.Mock).mockReturnValue([mockSubmitCheckout, CommandStatus.IDLE]);
|
|
@@ -166,6 +172,7 @@ describe("useSubmitCheckout custom hook", () => {
|
|
|
166
172
|
},
|
|
167
173
|
};
|
|
168
174
|
|
|
175
|
+
(useQueryBus as jest.Mock).mockReturnValue(() => ({ isExpired: false }) as CheckoutBookingProjection);
|
|
169
176
|
(useBlockCheckoutBooking as jest.Mock).mockReturnValue([mockBlockCheckoutBooking, CommandStatus.SUCCESS]);
|
|
170
177
|
(useCreateToastNotification as jest.Mock).mockReturnValue([mockCreateToastNotification, CommandStatus.SUCCESS]);
|
|
171
178
|
(useSubmitCheckout as jest.Mock).mockReturnValue([mockSubmitCheckout, CommandStatus.IDLE]);
|
|
@@ -212,6 +219,7 @@ describe("useSubmitCheckout custom hook", () => {
|
|
|
212
219
|
},
|
|
213
220
|
};
|
|
214
221
|
|
|
222
|
+
(useQueryBus as jest.Mock).mockReturnValue(() => ({ isExpired: false }) as CheckoutBookingProjection);
|
|
215
223
|
(useBlockCheckoutBooking as jest.Mock).mockReturnValue([mockBlockCheckoutBooking, CommandStatus.SUCCESS]);
|
|
216
224
|
(useSubmitCheckout as jest.Mock).mockReturnValue([mockSubmitCheckout, CommandStatus.ERROR]);
|
|
217
225
|
(useCreateToastNotification as jest.Mock).mockReturnValue([mockCreateToastNotification, CommandStatus.SUCCESS]);
|
|
@@ -236,4 +244,54 @@ describe("useSubmitCheckout custom hook", () => {
|
|
|
236
244
|
expect(mockOnError).toHaveBeenCalled();
|
|
237
245
|
});
|
|
238
246
|
});
|
|
247
|
+
|
|
248
|
+
test("returns submitCheckout error as the status right after calling 'submitCheckout' if CheckoutBooking isExpired", async () => {
|
|
249
|
+
const mockBlockCheckoutBooking = jest.fn();
|
|
250
|
+
const mockSubmitCheckout = jest.fn();
|
|
251
|
+
const mockCreateToastNotification = jest.fn();
|
|
252
|
+
const mockOnError = jest.fn();
|
|
253
|
+
const mockOnSuccess = jest.fn();
|
|
254
|
+
const mockPaymentFlowRef: RefObject<PaymentFlowRef> = {
|
|
255
|
+
current: {
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
257
|
+
startLegacyBoxCheckout: jest.fn().mockImplementation((_payload, callback) => {
|
|
258
|
+
callback({ status: ChargeStatus.EXECUTED, final: true });
|
|
259
|
+
}),
|
|
260
|
+
startCheckout: jest.fn(),
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
(useQueryBus as jest.Mock).mockReturnValue(() => ({ isExpired: true }) as CheckoutBookingProjection);
|
|
265
|
+
(useBlockCheckoutBooking as jest.Mock).mockReturnValue([mockBlockCheckoutBooking, CommandStatus.SUCCESS]);
|
|
266
|
+
(useCreateToastNotification as jest.Mock).mockReturnValue([mockCreateToastNotification, CommandStatus.SUCCESS]);
|
|
267
|
+
(useSubmitCheckout as jest.Mock).mockReturnValue([mockSubmitCheckout, CommandStatus.SUCCESS]);
|
|
268
|
+
|
|
269
|
+
const { result } = renderHook(() =>
|
|
270
|
+
sut({
|
|
271
|
+
checkoutId,
|
|
272
|
+
checkoutBookingId,
|
|
273
|
+
paymentFlowRef: mockPaymentFlowRef,
|
|
274
|
+
onError: mockOnError,
|
|
275
|
+
onSuccess: mockOnSuccess,
|
|
276
|
+
logger,
|
|
277
|
+
}),
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
await act(async () => {
|
|
281
|
+
const [submitCheckout] = result.current;
|
|
282
|
+
await submitCheckout({ paymentFlowPayload: mockPaymentFlowPayload, sizeChangeEnabled: true });
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
await waitFor(() => {
|
|
286
|
+
const [, status] = result.current;
|
|
287
|
+
|
|
288
|
+
expect(mockBlockCheckoutBooking).toHaveBeenCalled();
|
|
289
|
+
expect(mockCreateToastNotification).not.toHaveBeenCalled();
|
|
290
|
+
expect(mockSubmitCheckout).not.toHaveBeenCalled();
|
|
291
|
+
|
|
292
|
+
expect(status).toBe("error");
|
|
293
|
+
expect(mockOnSuccess).not.toHaveBeenCalled();
|
|
294
|
+
expect(mockOnError).toHaveBeenCalled();
|
|
295
|
+
});
|
|
296
|
+
});
|
|
239
297
|
});
|