@lookiero/checkout 0.3.11 → 0.3.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -46,7 +46,7 @@
46
46
  "@lookiero/data-sources": "^0.3",
47
47
  "@lookiero/event": "^0.3",
48
48
  "@lookiero/locale": "^0.3",
49
- "@lookiero/payments-front": "^0.16.3",
49
+ "@lookiero/payments-front": "^0.16.5",
50
50
  "apollo-boost": "0.4.4",
51
51
  "graphql": "14.5.8",
52
52
  "graphql-tag": "2.12.6",
@@ -66,7 +66,7 @@
66
66
  "@lookiero/data-sources": "^0.3",
67
67
  "@lookiero/event": "^0.3",
68
68
  "@lookiero/locale": "^0.3",
69
- "@lookiero/payments-front": "^0.16.3",
69
+ "@lookiero/payments-front": "^0.16.5",
70
70
  "@pact-foundation/pact": "^10.1.4",
71
71
  "@pact-foundation/pact-node": "^10.17.6",
72
72
  "@testing-library/react": "^13.4.0",
@@ -19,6 +19,9 @@ const authToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIwOTUxNjAsImV4
19
19
  const translationsUrl = Platform.OS !== "web" ? "https://web2.ps.dev.aws.lookiero.es/checkout/i18n" : __DEV__ ? "/local-to-i18n" : "/i18n";
20
20
  const translationsApiKey = "f2AfMGaPCZGVbAFWz_OV4GWhBDG_NbZJ";
21
21
  const translations = (locale) => `${translationsUrl}/${locale}?key=${translationsApiKey}&no-folding=true`;
22
+ const useRedirect = () => ({
23
+ returnUrl: "https://web2.dev.aws.lookiero.es/user/",
24
+ });
22
25
  setPaymentsBridge({
23
26
  getToken: () => Promise.resolve(authToken),
24
27
  stripeKey: "pk_test_6dwdUfkUm7AaUH3oSje9H0kk",
@@ -88,7 +91,7 @@ const ExpoRoot = () => {
88
91
  React.createElement(Aurora, { useStack: false },
89
92
  isAccessible === false && React.createElement(Text, { heading: true }, "Checkout is not accessible!"),
90
93
  React.createElement(Router, null,
91
- React.createElement(Root, { basePath: "", customerId: "cf7c641f-0e5c-4850-ae07-276747edfd0b", locale: "es", onNotAccessible: onNotAccessible }))),
94
+ React.createElement(Root, { basePath: "", customerId: "cf7c641f-0e5c-4850-ae07-276747edfd0b", locale: "es", useRedirect: useRedirect, onNotAccessible: onNotAccessible }))),
92
95
  React.createElement(StatusBar, null))) : null;
93
96
  };
94
97
  export { ExpoRoot };
@@ -17,6 +17,7 @@ interface RootProps {
17
17
  readonly locale?: string;
18
18
  readonly customerId: string | undefined;
19
19
  readonly onNotAccessible: () => void;
20
+ readonly useRedirect: () => Record<string, string>;
20
21
  }
21
22
  declare const root: RootFunction;
22
23
  export type { RootProps };
@@ -3,10 +3,10 @@ import { Platform } from "react-native";
3
3
  import { Routing } from "./routing/Routing";
4
4
  const root = ({ Messaging, I18n, Notifications, authToken, development }) =>
5
5
  // eslint-disable-next-line react/display-name, react/prop-types
6
- ({ basePath, locale = "en", customerId, onNotAccessible }) => {
6
+ ({ basePath, locale = "en", customerId, onNotAccessible, useRedirect }) => {
7
7
  const handleOnI18nError = useCallback(() => void 0, []);
8
8
  return (React.createElement(Messaging, { includeReactQueryDevTools: Platform.OS === "web" },
9
9
  React.createElement(Notifications, { includeReactQueryDevTools: Platform.OS === "web" },
10
- React.createElement(Routing, { I18n: I18n, authToken: authToken, basePath: basePath, customerId: customerId, locale: locale, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible }))));
10
+ React.createElement(Routing, { I18n: I18n, authToken: authToken, basePath: basePath, customerId: customerId, locale: locale, useRedirect: useRedirect, onI18nError: development ? undefined : handleOnI18nError, onNotAccessible: onNotAccessible }))));
11
11
  };
12
12
  export { root };
@@ -8,6 +8,7 @@ interface RoutingProps {
8
8
  readonly authToken: string;
9
9
  readonly onNotAccessible: () => void;
10
10
  readonly onI18nError?: (err: Error) => void;
11
+ readonly useRedirect: () => Record<string, string>;
11
12
  }
12
13
  declare const Routing: FC<RoutingProps>;
13
14
  export { Routing };
@@ -10,7 +10,7 @@ const Intro = lazy(() => import("../views/intro/Intro").then((module) => ({ defa
10
10
  const Item = lazy(() => import("../views/item/Item").then((module) => ({ default: module.Item })));
11
11
  const Summary = lazy(() => import("../views/summary/Summary").then((module) => ({ default: module.Summary })));
12
12
  const Checkout = lazy(() => import("../views/checkout/Checkout").then((module) => ({ default: module.Checkout })));
13
- const Routing = ({ basePath = "", customerId, locale, I18n, authToken, onI18nError, onNotAccessible, }) => {
13
+ const Routing = ({ basePath = "", customerId, locale, I18n, authToken, onI18nError, onNotAccessible, useRedirect, }) => {
14
14
  const routes = useRoutes([
15
15
  {
16
16
  path: "",
@@ -44,7 +44,7 @@ const Routing = ({ basePath = "", customerId, locale, I18n, authToken, onI18nErr
44
44
  {
45
45
  path: Routes.CHECKOUT,
46
46
  element: (React.createElement(Suspense, { fallback: React.createElement(Spinner, null) },
47
- React.createElement(Checkout, { authToken: authToken, customerId: customerId }))),
47
+ React.createElement(Checkout, { authToken: authToken, customerId: customerId, useRedirect: useRedirect }))),
48
48
  },
49
49
  {
50
50
  path: "*",
@@ -2,6 +2,7 @@ import { FC } from "react";
2
2
  interface CheckoutProps {
3
3
  readonly customerId: string;
4
4
  readonly authToken: string;
5
+ readonly useRedirect: () => Record<string, string>;
5
6
  }
6
7
  declare const Checkout: FC<CheckoutProps>;
7
8
  export { Checkout };
@@ -1,7 +1,7 @@
1
1
  import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
2
  import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import { CommandStatus, QueryStatus } from "@lookiero/messaging-react";
4
- import { CheckoutStatus, PaymentFlow } from "@lookiero/payments-front";
4
+ import { CheckoutStatus, PaymentFlow, PaymentInstrumentSelect, PaymentMethod, Section, } from "@lookiero/payments-front";
5
5
  import React, { useCallback, useMemo, useRef, useState } from "react";
6
6
  import { View } from "react-native";
7
7
  import { useNavigate } from "react-router-native";
@@ -22,8 +22,9 @@ import { ProductVariant } from "../item/components/productVariant/ProductVariant
22
22
  import { Pricing } from "../summary/components/pricing/Pricing";
23
23
  import { style } from "./Checkout.style";
24
24
  import { CheckoutSuccessModal } from "./components/CheckoutSuccessModal";
25
- const Checkout = ({ customerId, authToken }) => {
25
+ const Checkout = ({ customerId, authToken, useRedirect }) => {
26
26
  const titleText = useI18nMessage({ id: I18nMessages.CHECKOUT_TITLE });
27
+ const paymentInstrumentSelectRef = useRef(null);
27
28
  const paymentFlowRef = useRef(null);
28
29
  const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
29
30
  const [pricing, pricingStatus] = useViewPricingByCheckoutId({ checkoutId: checkout?.id });
@@ -35,6 +36,7 @@ const Checkout = ({ customerId, authToken }) => {
35
36
  const [processingCheckout, setProcessingCheckout] = useState(false);
36
37
  const navigate = useNavigate();
37
38
  const basePath = useBasePath();
39
+ const { returnUrl } = useRedirect();
38
40
  const handleOnSubmitCheckout = useCallback(() => {
39
41
  console.log("onSubmit checkout");
40
42
  if (!paymentFlowRef.current) {
@@ -73,6 +75,7 @@ const Checkout = ({ customerId, authToken }) => {
73
75
  React.createElement(CheckoutSuccessModal, { visible: markAsPaidStatus === CommandStatus.SUCCESS, onDismiss: handleOnSuccessModalDismiss }),
74
76
  React.createElement(SafeAreaScrollView, null,
75
77
  React.createElement(Body, { style: { column: style.bodyColumn } },
78
+ React.createElement(PaymentInstrumentSelect, { ref: paymentInstrumentSelectRef, beforeRedirect: returnUrl ? () => Promise.resolve(returnUrl) : undefined, hasError: false, hidePaymentMethods: [PaymentMethod.GOOGLE_PAY], section: Section.BOX_CHECKOUT }),
76
79
  React.createElement(Text, { level: 3, style: style.title, heading: true }, titleText),
77
80
  checkoutItemsKept?.map((checkoutItem) => (React.createElement(View, { key: checkoutItem.id, style: style.checkoutItemKept, testID: "checkout-items-kept" },
78
81
  React.createElement(ProductVariant, { brand: checkoutItem.productVariant.brand, color: checkoutItem.productVariant.color, media: checkoutItem.productVariant.media, name: checkoutItem.productVariant.name, price: checkoutItem.price, size: checkoutItem.productVariant.size, status: checkoutItem.status })))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -46,7 +46,7 @@
46
46
  "@lookiero/data-sources": "^0.3",
47
47
  "@lookiero/event": "^0.3",
48
48
  "@lookiero/locale": "^0.3",
49
- "@lookiero/payments-front": "^0.16.3",
49
+ "@lookiero/payments-front": "^0.16.5",
50
50
  "apollo-boost": "0.4.4",
51
51
  "graphql": "14.5.8",
52
52
  "graphql-tag": "2.12.6",
@@ -66,7 +66,7 @@
66
66
  "@lookiero/data-sources": "^0.3",
67
67
  "@lookiero/event": "^0.3",
68
68
  "@lookiero/locale": "^0.3",
69
- "@lookiero/payments-front": "^0.16.3",
69
+ "@lookiero/payments-front": "^0.16.5",
70
70
  "@pact-foundation/pact": "^10.1.4",
71
71
  "@pact-foundation/pact-node": "^10.17.6",
72
72
  "@testing-library/react": "^13.4.0",