@ecomiq/storefront 2.1.4 → 3.0.1
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/LICENSE +21 -0
- package/README.md +377 -76
- package/dist/account-Dx4e3syi.js +258 -0
- package/dist/account-forms-AVk71ko7.js +39 -0
- package/dist/account-forms.d.ts +13 -0
- package/dist/account.d.ts +240 -0
- package/dist/address-defaults-BqjRhS82.js +14 -0
- package/dist/address-defaults.d.ts +11 -0
- package/dist/analytics/analytics-CG1Qagwl.js +148 -0
- package/dist/analytics/analytics.d.ts +1 -0
- package/dist/analytics/config-DJr-GRhs.js +62 -0
- package/dist/analytics/config.d.ts +22 -0
- package/dist/analytics/consent-B13rBpBs.js +57 -0
- package/dist/analytics/consent-banner-9QvRRy8v.js +239 -0
- package/dist/analytics/consent-banner.d.ts +20 -0
- package/dist/analytics/cookies-pLozllyB.js +100 -0
- package/dist/analytics/cookies.d.ts +6 -0
- package/dist/analytics/destinations-iECrlLIr.js +144 -0
- package/dist/analytics/events-Dt81tIp1.js +102 -0
- package/dist/analytics/events.d.ts +51 -0
- package/dist/analytics/tracker-p4yaoOyk.js +51 -0
- package/dist/api-cache-DsuIn5hX.js +159 -0
- package/dist/bank-accounts-DlEczQQ5.js +81 -0
- package/dist/bank-accounts.d.ts +4 -0
- package/dist/captcha-DAqaIx8m.js +117 -0
- package/dist/captcha.d.ts +34 -0
- package/dist/cart-D7DxZ2lD.js +30 -0
- package/dist/cart-actions-Bsub_FFG.js +116 -0
- package/dist/cart-actions.d.ts +15 -0
- package/dist/cart-drawer-B7PPsR69.js +22 -0
- package/dist/cart-drawer.d.ts +9 -0
- package/dist/cart-form-y9P1r_EX.js +81 -0
- package/dist/cart-form.d.ts +24 -0
- package/dist/cart-summary-ur2VWKr-.js +89 -0
- package/dist/cart-summary.d.ts +31 -0
- package/dist/cart.d.ts +4 -0
- package/dist/catalog-7gJ-l5hW.js +67 -0
- package/dist/catalog-hooks-B7ZP4wYY.js +312 -0
- package/dist/catalog-hooks.d.ts +111 -0
- package/dist/catalog.d.ts +5 -0
- package/dist/checkout-DVWSXANi.js +474 -0
- package/dist/checkout-form-CbOIdENC.js +131 -0
- package/dist/checkout-form.d.ts +20 -0
- package/dist/checkout.d.ts +86 -0
- package/dist/complaint-book-BvwLvfx0.js +117 -0
- package/dist/complaint-book.d.ts +62 -0
- package/dist/culqi-authentication-BGr20vAJ.js +204 -0
- package/dist/culqi-authentication.d.ts +15 -0
- package/dist/culqi-checkout-CTXpKgp_.js +55 -0
- package/dist/culqi-three-ds-HP3mfrvV.js +33 -0
- package/dist/culqi-three-ds.d.ts +29 -0
- package/dist/customer-avatar-CJXSDroK.js +12 -0
- package/dist/customer-avatar.d.ts +5 -0
- package/dist/customer-cookies-DHOgFAMV.js +45 -0
- package/dist/customer-csrf-C1oDX-Py.js +17 -0
- package/dist/customer-csrf.d.ts +3 -0
- package/dist/customer-document-fields-C1K-_DAD.js +70 -0
- package/dist/customer-document-fields.d.ts +9 -0
- package/dist/customer-login-form-C7AC6vXd.js +144 -0
- package/dist/customer-login-form.d.ts +17 -0
- package/dist/customer-registration-form-BEm_NEfP.js +93 -0
- package/dist/customer-registration-form.d.ts +8 -0
- package/dist/document-url-CGsAl5Tf.js +9 -0
- package/dist/documents-T1mzc_j8.js +38 -0
- package/dist/documents.d.ts +16 -0
- package/dist/entries/account.d.ts +11 -0
- package/dist/entries/account.js +10 -0
- package/dist/entries/analytics.d.ts +6 -0
- package/dist/entries/analytics.js +5 -0
- package/dist/entries/cart.d.ts +8 -0
- package/dist/entries/cart.js +7 -0
- package/dist/entries/checkout.d.ts +12 -0
- package/dist/entries/checkout.js +11 -0
- package/dist/entries/order.d.ts +11 -0
- package/dist/entries/order.js +11 -0
- package/dist/favicon-YpyhVJ9H.js +28 -0
- package/dist/favicon.d.ts +4 -0
- package/dist/form-BtQcbXlJ.js +18 -0
- package/dist/form-contracts-BNpHaTGJ.js +166 -0
- package/dist/form-contracts.d.ts +42 -0
- package/dist/form.d.ts +3 -0
- package/dist/hidden-CCWtOWKR.js +3 -0
- package/dist/hidden.d.ts +4 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +50 -0
- package/dist/invoice-fields-BG0HjL6T.js +103 -0
- package/dist/invoice-fields.d.ts +39 -0
- package/dist/links-kFxBZfdb.js +96 -0
- package/dist/links.d.ts +21 -0
- package/dist/mercadopago-checkout-DC7RXa8k.js +27 -0
- package/dist/mercadopago-dialog-UTQev0MG.js +180 -0
- package/dist/mercadopago-dialog.d.ts +21 -0
- package/dist/money-DtGOtDri.js +32 -0
- package/dist/money.d.ts +1 -0
- package/dist/optimistic-cart-BveVOHuh.js +53 -0
- package/dist/optimistic-cart.d.ts +16 -0
- package/dist/order-display-DTt5WBbc.js +112 -0
- package/dist/order-display.d.ts +20 -0
- package/dist/order-draft-DxV1Uhm3.js +38 -0
- package/dist/order-draft.d.ts +16 -0
- package/dist/order-pages-Dm6l5m0m.js +38 -0
- package/dist/order-pages.d.ts +12 -0
- package/dist/order-payment-continuation-D_d5PGA4.js +212 -0
- package/dist/order-payment-continuation.d.ts +10 -0
- package/dist/order-payment-in-review-x4gdLFHZ.js +65 -0
- package/dist/order-payment-in-review.d.ts +5 -0
- package/dist/order-status-BJXLJwxq.js +162 -0
- package/dist/order-status.d.ts +89 -0
- package/dist/order-view-9IlBg5AF.js +62 -0
- package/dist/order-view.d.ts +12 -0
- package/dist/page-action-Ctkf4xC6.js +7 -0
- package/dist/page-seo-a5FJl8x5.js +262 -0
- package/dist/page-seo.d.ts +34 -0
- package/dist/pages-Ca_Gt6mq.js +150 -0
- package/dist/pages.d.ts +45 -0
- package/dist/payment-dialog-frame-B-Q_xQ94.js +57 -0
- package/dist/payment-logo-BoPaGJc_.js +46 -0
- package/dist/payment-logo-svgs-By9lDTLK.js +20 -0
- package/dist/payment-logo.d.ts +11 -0
- package/dist/payment-logos-BYvdwYyJ.js +23 -0
- package/dist/payment-methods-B8ocTgFZ.js +73 -0
- package/dist/payment-methods.d.ts +58 -0
- package/dist/payment-return-5cjypwIw.js +7 -0
- package/dist/place-CmW4hBWY.js +13 -0
- package/dist/place.d.ts +4 -0
- package/dist/preview-BiIBif3C.js +427 -0
- package/dist/preview-address-Cf0sJ-9p.js +21 -0
- package/dist/preview-cart-Dg2CVktS.js +376 -0
- package/dist/product-preview-BspMAecJ.js +51 -0
- package/dist/product-preview.d.ts +5 -0
- package/dist/product-variants-BNDHvs1y.js +46 -0
- package/dist/product-variants.d.ts +12 -0
- package/dist/public-pages-XtwlaLwt.js +194 -0
- package/dist/public-pages.d.ts +67 -0
- package/dist/registration-CpDcv8ql.js +91 -0
- package/dist/registration.d.ts +12 -0
- package/dist/request-security-CRsRMgwj.js +76 -0
- package/dist/rich-text-M-Ju8RL4.js +9 -0
- package/dist/rich-text.d.ts +5 -0
- package/dist/route-text-DcJw2SsK.js +9 -0
- package/dist/route-text.d.ts +4 -0
- package/dist/section-preview-CmsMl3yu.js +83 -0
- package/dist/section-preview.d.ts +12 -0
- package/dist/sections/account-addresses.d.ts +18 -0
- package/dist/sections/account-addresses.js +375 -0
- package/dist/sections/account-order.d.ts +12 -0
- package/dist/sections/account-order.js +592 -0
- package/dist/sections/account-orders.d.ts +8 -0
- package/dist/sections/account-orders.js +359 -0
- package/dist/sections/account-profile.d.ts +16 -0
- package/dist/sections/account-profile.js +123 -0
- package/dist/sections/checkout.d.ts +24 -0
- package/dist/sections/checkout.js +963 -0
- package/dist/sections/complaint-book.d.ts +8 -0
- package/dist/sections/complaint-book.js +538 -0
- package/dist/sections/design-system.d.ts +1 -0
- package/dist/sections/design-system.js +310 -0
- package/dist/sections/draft-invoice.d.ts +20 -0
- package/dist/sections/draft-invoice.js +158 -0
- package/dist/sections/order-tracking.d.ts +19 -0
- package/dist/sections/order-tracking.js +141 -0
- package/dist/sections-CNUMWTF_.js +77 -0
- package/dist/sections.d.ts +19 -0
- package/dist/seo-GpDRhAAA.js +78 -0
- package/dist/session-CKvmFJyg.js +379 -0
- package/dist/session.d.ts +24 -0
- package/dist/settings-B0NO2A6Y.js +78 -0
- package/dist/settings.d.ts +51 -0
- package/dist/source-marker-DhqSkW7n.js +4 -0
- package/dist/sources-B-3JFJfb.js +46 -0
- package/dist/sources.d.ts +7 -0
- package/dist/store-8Q-_LFrQ.js +152 -0
- package/dist/store-contact--hY6CoFb.js +19 -0
- package/dist/store-contact.d.ts +6 -0
- package/dist/store.d.ts +17 -0
- package/dist/storefront-language-DrMjVbmk.js +29 -0
- package/dist/storefront-language.d.ts +14 -0
- package/dist/storefront-text-D25ae1qf.js +11 -0
- package/dist/storefront-text-en-ljjjSS4q.js +1030 -0
- package/dist/storefront-text-pt-BtHaJLcp.js +1030 -0
- package/dist/storefront-text.d.ts +4 -0
- package/dist/stripe-dialog-Ev9s3Z62.js +396 -0
- package/dist/stripe-dialog.d.ts +30 -0
- package/dist/telemetry-HuZXWBPi.js +114 -0
- package/dist/telemetry.d.ts +10 -0
- package/dist/templates-CAqoNyTW.js +40 -0
- package/dist/templates.d.ts +15 -0
- package/dist/urls-CpGQPxvf.js +71 -0
- package/dist/urls.d.ts +18 -0
- package/dist/use-checkout-CZcxXJXi.js +42 -0
- package/dist/use-checkout-payment-9R-zacrJ.js +80 -0
- package/dist/use-checkout-payment.d.ts +18 -0
- package/dist/use-checkout.d.ts +36 -0
- package/dist/use-culqi-checkout-CrjLAipU.js +109 -0
- package/dist/use-order-payment-BKIz_IO0.js +45 -0
- package/dist/use-order-payment.d.ts +18 -0
- package/dist/use-payment-token-CErx-tN-.js +105 -0
- package/dist/vite-payment-logos-kziu7wKb.js +27 -0
- package/dist/vite-payment-logos.d.ts +24 -0
- package/dist/vite-public-assets-DW2fgtVb.js +209 -0
- package/dist/vite-public-assets.d.ts +29 -0
- package/dist/vite-sections-DTBr0-Kg.js +464 -0
- package/dist/vite-sections.d.ts +21 -0
- package/dist/vite-theme-ui-BMO-CDi3.js +41 -0
- package/dist/vite-theme-ui.d.ts +10 -0
- package/dist/vite.d.ts +36 -0
- package/dist/vite.js +127 -0
- package/dist/voucher-payment-CVFDZ1L8.js +66 -0
- package/dist/worker-CNi-gzCu.js +86 -0
- package/dist/worker.d.ts +27 -0
- package/package.json +100 -76
- package/src/sections/account-addresses.tsx +215 -0
- package/src/sections/account-order.tsx +424 -0
- package/src/sections/account-orders.tsx +259 -0
- package/src/sections/account-profile.tsx +70 -0
- package/src/sections/checkout.tsx +586 -0
- package/src/sections/complaint-book.tsx +325 -0
- package/src/sections/design-system.tsx +146 -0
- package/src/sections/draft-invoice.tsx +105 -0
- package/src/sections/order-tracking.tsx +81 -0
- package/src/vite-client.d.ts +4 -0
- package/bin/ecomiq.mjs +0 -179
- package/public/design-bridge.js +0 -318
- package/src/api-proxy.ts +0 -194
- package/src/auth/create-storefront-auth.ts +0 -94
- package/src/auth/ecomiq-oauth-password-client.ts +0 -26
- package/src/auth/ecomiq-oauth-password-constants.ts +0 -24
- package/src/auth/ecomiq-oauth-password-plugin.ts +0 -294
- package/src/auth/ecomiq-oauth-password-types.ts +0 -24
- package/src/auth/ecomiq-storefront-sign-in.ts +0 -44
- package/src/auth/env.ts +0 -7
- package/src/auth/secure-cookies.ts +0 -23
- package/src/auth/storefront-auth-base-url.ts +0 -117
- package/src/auth/storefront-auth.ts +0 -7
- package/src/cart-session.ts +0 -239
- package/src/client.ts +0 -48
- package/src/codegen.mjs +0 -801
- package/src/components/account/customer-addresses-panel.tsx +0 -678
- package/src/components/account/customer-order-detail-panel.tsx +0 -285
- package/src/components/account/customer-orders-panel.tsx +0 -192
- package/src/components/account/customer-profile-panel.tsx +0 -379
- package/src/components/checkout/cart-sync.ts +0 -143
- package/src/components/checkout/checkout-contact-section.tsx +0 -76
- package/src/components/checkout/checkout-external-update-banner.tsx +0 -15
- package/src/components/checkout/checkout-form-controls.tsx +0 -139
- package/src/components/checkout/checkout-line-items.tsx +0 -43
- package/src/components/checkout/checkout-order-summary.tsx +0 -165
- package/src/components/checkout/checkout-payment-section.tsx +0 -212
- package/src/components/checkout/checkout-session-view.tsx +0 -564
- package/src/components/checkout/checkout-shipping-address-section.tsx +0 -400
- package/src/components/checkout/checkout-shipping-section.tsx +0 -98
- package/src/components/checkout/checkout-states.tsx +0 -73
- package/src/components/checkout/checkout-step-card.tsx +0 -101
- package/src/components/checkout/checkout-steps.ts +0 -111
- package/src/components/checkout/form-schema.ts +0 -281
- package/src/components/checkout/format.ts +0 -15
- package/src/components/checkout/index.ts +0 -5
- package/src/components/checkout/map-customer-to-checkout.ts +0 -188
- package/src/components/checkout/types.ts +0 -41
- package/src/components/checkout/use-checkout-customer-prefill.ts +0 -409
- package/src/components/checkout/use-checkout-geo.ts +0 -50
- package/src/components/checkout/use-checkout-session.ts +0 -640
- package/src/components/hero.tsx +0 -291
- package/src/config.d.ts +0 -94
- package/src/config.mjs +0 -146
- package/src/format-money.ts +0 -31
- package/src/health.ts +0 -90
- package/src/hooks/index.ts +0 -9
- package/src/hooks/recently-viewed.ts +0 -125
- package/src/index.ts +0 -349
- package/src/link.tsx +0 -2
- package/src/pages/account/account-page-skeleton.tsx +0 -69
- package/src/pages/account/account-page-view.tsx +0 -270
- package/src/pages/account/account-shell.tsx +0 -101
- package/src/pages/account/parse-account-route.ts +0 -36
- package/src/pages/account.tsx +0 -16
- package/src/pages/api.$.ts +0 -20
- package/src/pages/api.auth.$.ts +0 -16
- package/src/pages/checkout.$checkoutId.tsx +0 -60
- package/src/pages/checkout.tsx +0 -31
- package/src/pages/pages.$pageSlug.tsx +0 -74
- package/src/pages/thank-you.tsx +0 -53
- package/src/providers/auth.tsx +0 -96
- package/src/providers/cart.tsx +0 -275
- package/src/providers/ecomiq.ts +0 -137
- package/src/providers/index.ts +0 -26
- package/src/proxy-api.ts +0 -20
- package/src/public-config.ts +0 -24
- package/src/review-submission.ts +0 -89
- package/src/runtime/context.ts +0 -2
- package/src/runtime/default-layout.tsx +0 -64
- package/src/runtime/head.ts +0 -149
- package/src/runtime/page.tsx +0 -143
- package/src/runtime/postcss-browser-stub.mjs +0 -5
- package/src/server-config-store.ts +0 -35
- package/src/server.ts +0 -286
- package/src/styles.css +0 -76
- package/src/ui/badge.tsx +0 -32
- package/src/ui/button.tsx +0 -31
- package/src/ui/card.tsx +0 -31
- package/src/ui/carousel.tsx +0 -218
- package/src/ui/cn.ts +0 -6
- package/src/ui/index.ts +0 -8
- package/src/ui/separator.tsx +0 -6
- package/src/ui/skeleton.tsx +0 -6
- package/src/ui/storefront-error.tsx +0 -49
- package/src/utils.ts +0 -36
- package/src/vite-inline.mjs +0 -263
- package/templates/__root.tsx +0 -83
- package/templates/router.tsx +0 -19
package/dist/urls.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RouterContextProvider } from "react-router";
|
|
2
|
+
import { CategoryDetail, ProductDetail, ProductsResponse, StorefrontSettings, UrlResolution } from "@ecomiq/core";
|
|
3
|
+
export type ResolvedUrl = Exclude<UrlResolution, {
|
|
4
|
+
kind: "redirect";
|
|
5
|
+
}>;
|
|
6
|
+
export type CategoryData = {
|
|
7
|
+
category: CategoryDetail;
|
|
8
|
+
page: number;
|
|
9
|
+
result: ProductsResponse;
|
|
10
|
+
};
|
|
11
|
+
export declare function requireCanonical(request: Request, url: string): void;
|
|
12
|
+
export type ResolveUrlOptions = {
|
|
13
|
+
redirect?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function resolveUrl(request: Request, context: Readonly<RouterContextProvider>, options?: ResolveUrlOptions): Promise<ResolvedUrl>;
|
|
16
|
+
export declare function loadProduct(request: Request, context: Readonly<RouterContextProvider>, options?: ResolveUrlOptions): Promise<ProductDetail>;
|
|
17
|
+
export declare function canonicalUrl(request: Request, context: Readonly<RouterContextProvider>, url: string): Promise<string>;
|
|
18
|
+
export declare function loadCategory(request: Request, context: Readonly<RouterContextProvider>, category: CategoryDetail): Promise<CategoryData>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { checkoutAddressDefaults, checkoutProgress, checkoutStep, defaultPaymentMethod, needsShipping } from "./checkout-DVWSXANi.js";
|
|
2
|
+
import { useCustomerCsrfToken } from "./customer-csrf-C1oDX-Py.js";
|
|
3
|
+
import { useFetcher, useNavigation, useSearchParams } from "react-router";
|
|
4
|
+
// src/use-checkout.ts
|
|
5
|
+
function useCheckout(checkout, result, layout = "steps") {
|
|
6
|
+
const [params] = useSearchParams();
|
|
7
|
+
const navigation = useNavigation();
|
|
8
|
+
const choice = useFetcher();
|
|
9
|
+
const csrf = useCustomerCsrfToken();
|
|
10
|
+
const busy = navigation.state !== "idle" || choice.state !== "idle";
|
|
11
|
+
let error = null;
|
|
12
|
+
let promoError = null;
|
|
13
|
+
let failed = null;
|
|
14
|
+
if (result && "error" in result) failed = result;
|
|
15
|
+
if (failed?.promo) promoError = failed.error;
|
|
16
|
+
else if (failed) error = failed.error;
|
|
17
|
+
else if (choice.data && "error" in choice.data) error = choice.data.error;
|
|
18
|
+
function choosePaymentMethod(code) {
|
|
19
|
+
const form = new FormData();
|
|
20
|
+
form.set("intent", "payment-method");
|
|
21
|
+
form.set("method", code);
|
|
22
|
+
if (csrf) form.set("__customer_csrf", csrf);
|
|
23
|
+
choice.submit(form, {
|
|
24
|
+
method: "post",
|
|
25
|
+
preventScrollReset: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
...checkout,
|
|
30
|
+
step: checkoutStep(checkout.cart, params.get("edit")),
|
|
31
|
+
done: checkoutProgress(checkout.cart),
|
|
32
|
+
needsDelivery: needsShipping(checkout.cart),
|
|
33
|
+
defaults: checkoutAddressDefaults(checkout.cart, checkout.address, checkout.countryCode),
|
|
34
|
+
paymentMethod: defaultPaymentMethod(checkout.cart, checkout.methods),
|
|
35
|
+
choosePaymentMethod,
|
|
36
|
+
single: layout === "single",
|
|
37
|
+
error,
|
|
38
|
+
promoError,
|
|
39
|
+
busy
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export { useCheckout };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { findStripeWallet } from "./stripe-dialog-Ev9s3Z62.js";
|
|
2
|
+
import { usePaymentToken } from "./use-payment-token-CErx-tN-.js";
|
|
3
|
+
import { gathered } from "./checkout-form-CbOIdENC.js";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
// src/use-checkout-payment.ts
|
|
6
|
+
function useCheckoutPayment(methods, cart, title) {
|
|
7
|
+
const payment = usePaymentToken();
|
|
8
|
+
const token = useRef(null);
|
|
9
|
+
const providerPaymentMethodId = useRef(null);
|
|
10
|
+
const deviceSessionId = useRef(null);
|
|
11
|
+
const resubmitting = useRef(false);
|
|
12
|
+
const [stripeDialog, setStripeDialog] = useState(null);
|
|
13
|
+
function onSubmit(event) {
|
|
14
|
+
if (resubmitting.current) return;
|
|
15
|
+
const form = event.currentTarget;
|
|
16
|
+
const fields = gathered(form);
|
|
17
|
+
if (fields === null) {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const email = fields.get("email");
|
|
22
|
+
const method = methods.find((entry) => entry.code === fields.get("method"));
|
|
23
|
+
if (method === void 0) return;
|
|
24
|
+
const submitWith = (provided, methodId = "", deviceId = "") => {
|
|
25
|
+
const input = token.current;
|
|
26
|
+
if (input === null || !form.isConnected) return;
|
|
27
|
+
const methodInput = providerPaymentMethodId.current;
|
|
28
|
+
input.value = provided;
|
|
29
|
+
if (methodInput !== null) methodInput.value = methodId;
|
|
30
|
+
if (deviceSessionId.current !== null) deviceSessionId.current.value = deviceId;
|
|
31
|
+
resubmitting.current = true;
|
|
32
|
+
try {
|
|
33
|
+
form.requestSubmit();
|
|
34
|
+
} finally {
|
|
35
|
+
resubmitting.current = false;
|
|
36
|
+
input.value = "";
|
|
37
|
+
if (methodInput !== null) methodInput.value = "";
|
|
38
|
+
if (deviceSessionId.current !== null) deviceSessionId.current.value = "";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const publishableKey = method.publicConfiguration?.publishableKey;
|
|
42
|
+
if (method.checkoutMode === "embedded" && method.providerId === "stripe" && publishableKey !== void 0) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
setStripeDialog({
|
|
45
|
+
publishableKey,
|
|
46
|
+
amount: cart.totals.total,
|
|
47
|
+
currency: cart.currencyCode,
|
|
48
|
+
wallet: findStripeWallet(method),
|
|
49
|
+
onTokenized: (paymentMethodId) => {
|
|
50
|
+
setStripeDialog(null);
|
|
51
|
+
submitWith("", paymentMethodId);
|
|
52
|
+
},
|
|
53
|
+
onClose: () => setStripeDialog(null)
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (payment.open({
|
|
58
|
+
method,
|
|
59
|
+
charge: {
|
|
60
|
+
title,
|
|
61
|
+
currency: cart.currencyCode,
|
|
62
|
+
amount: cart.totals.total,
|
|
63
|
+
email: typeof email === "string" ? email : cart.email
|
|
64
|
+
},
|
|
65
|
+
onToken: submitWith
|
|
66
|
+
})) event.preventDefault();
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
token,
|
|
70
|
+
providerPaymentMethodId,
|
|
71
|
+
deviceSessionId,
|
|
72
|
+
source: payment.source,
|
|
73
|
+
dialog: payment.dialog,
|
|
74
|
+
stripeDialog,
|
|
75
|
+
loading: payment.loading || stripeDialog !== null,
|
|
76
|
+
error: payment.error,
|
|
77
|
+
onSubmit
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export { useCheckoutPayment };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CheckoutPaymentMethod } from "./checkout.js";
|
|
2
|
+
import { MercadoPagoDialogState } from "./mercadopago-dialog.js";
|
|
3
|
+
import { StripeDialogState } from "./stripe-dialog.js";
|
|
4
|
+
import { CulqiPaymentSource } from "./culqi-three-ds.js";
|
|
5
|
+
import { StorefrontCart } from "@ecomiq/core";
|
|
6
|
+
import { FormEvent, RefObject } from "react";
|
|
7
|
+
export type CheckoutPaymentControls = {
|
|
8
|
+
token: RefObject<HTMLInputElement | null>;
|
|
9
|
+
providerPaymentMethodId: RefObject<HTMLInputElement | null>;
|
|
10
|
+
deviceSessionId: RefObject<HTMLInputElement | null>;
|
|
11
|
+
source: RefObject<CulqiPaymentSource | null>;
|
|
12
|
+
dialog: MercadoPagoDialogState | null;
|
|
13
|
+
stripeDialog: StripeDialogState | null;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare function useCheckoutPayment(methods: CheckoutPaymentMethod[], cart: StorefrontCart, title: string): CheckoutPaymentControls;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CheckoutActionData, CheckoutData, CheckoutPaymentMethod, CheckoutShippingGroup, CheckoutStep } from "./checkout.js";
|
|
2
|
+
import { readCountries } from "./store.js";
|
|
3
|
+
import { PageAnalytics } from "./analytics/events.js";
|
|
4
|
+
import { AddressDefaults } from "./address-defaults.js";
|
|
5
|
+
export type CheckoutLayout = "steps" | "single";
|
|
6
|
+
export declare function useCheckout(checkout: CheckoutData, result?: CheckoutActionData | null, layout?: CheckoutLayout): {
|
|
7
|
+
countryCode: string;
|
|
8
|
+
documentCountries: {
|
|
9
|
+
code: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}[];
|
|
12
|
+
language: string;
|
|
13
|
+
cart: import("@ecomiq/core").StorefrontCart;
|
|
14
|
+
methods: CheckoutPaymentMethod[];
|
|
15
|
+
bumps: import("@ecomiq/core").CartCheckoutReadResponse["orderBumps"];
|
|
16
|
+
signedIn: boolean;
|
|
17
|
+
me: import("@ecomiq/core").CustomerMe | null;
|
|
18
|
+
address: import("@ecomiq/core").CustomerAddress | null;
|
|
19
|
+
countries: Awaited<ReturnType<typeof readCountries>>;
|
|
20
|
+
shipping: CheckoutShippingGroup[];
|
|
21
|
+
analytics: PageAnalytics;
|
|
22
|
+
step: CheckoutStep;
|
|
23
|
+
done: {
|
|
24
|
+
contact: boolean;
|
|
25
|
+
delivery: boolean;
|
|
26
|
+
shipping: boolean;
|
|
27
|
+
};
|
|
28
|
+
needsDelivery: boolean;
|
|
29
|
+
defaults: AddressDefaults;
|
|
30
|
+
paymentMethod: string | undefined;
|
|
31
|
+
choosePaymentMethod: (code: string) => void;
|
|
32
|
+
single: boolean;
|
|
33
|
+
error: string | null;
|
|
34
|
+
promoError: string | null;
|
|
35
|
+
busy: boolean;
|
|
36
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CULQI_ORDER_METHODS, CULQI_TOKEN_METHODS, loadCulqiCheckout } from "./culqi-checkout-CTXpKgp_.js";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
// src/use-culqi-checkout.ts
|
|
4
|
+
const UNAVAILABLE = "Este medio de pago no está disponible. Elige otro medio de pago.";
|
|
5
|
+
function useCulqiCheckout() {
|
|
6
|
+
const [loading, setLoading] = useState(false);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
const checkout = useRef(null);
|
|
9
|
+
const mounted = useRef(true);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
mounted.current = true;
|
|
12
|
+
return () => {
|
|
13
|
+
mounted.current = false;
|
|
14
|
+
checkout.current?.close();
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
async function launch({ publicKey, charge, orderId, paymentMethods, onCallback, onClose = () => {} }) {
|
|
18
|
+
setError(null);
|
|
19
|
+
setLoading(true);
|
|
20
|
+
try {
|
|
21
|
+
const Checkout = await loadCulqiCheckout();
|
|
22
|
+
if (!mounted.current) return;
|
|
23
|
+
checkout.current?.close();
|
|
24
|
+
const instance = new Checkout(publicKey, {
|
|
25
|
+
settings: {
|
|
26
|
+
title: charge.title,
|
|
27
|
+
currency: charge.currency,
|
|
28
|
+
amount: Math.round(charge.amount * 100),
|
|
29
|
+
order: orderId
|
|
30
|
+
},
|
|
31
|
+
client: { email: charge.email ?? void 0 },
|
|
32
|
+
options: {
|
|
33
|
+
lang: "es",
|
|
34
|
+
installments: false,
|
|
35
|
+
modal: true,
|
|
36
|
+
paymentMethods
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
instance.culqi = () => {
|
|
40
|
+
if (!mounted.current || checkout.current !== instance) return;
|
|
41
|
+
onCallback(instance);
|
|
42
|
+
};
|
|
43
|
+
instance.closeCheckout = () => {
|
|
44
|
+
if (!mounted.current || checkout.current !== instance) return;
|
|
45
|
+
onClose();
|
|
46
|
+
};
|
|
47
|
+
checkout.current = instance;
|
|
48
|
+
instance.open();
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (!mounted.current) return;
|
|
51
|
+
if (error instanceof Error) setError(error.message);
|
|
52
|
+
else setError("No pudimos abrir el pago.");
|
|
53
|
+
} finally {
|
|
54
|
+
if (mounted.current) setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function open(charge, onToken) {
|
|
58
|
+
const paymentMethods = CULQI_TOKEN_METHODS.get(charge.methodCode);
|
|
59
|
+
if (!charge.publicKey || paymentMethods === void 0) {
|
|
60
|
+
setError(UNAVAILABLE);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let tokenized = false;
|
|
64
|
+
await launch({
|
|
65
|
+
publicKey: charge.publicKey,
|
|
66
|
+
charge,
|
|
67
|
+
orderId: void 0,
|
|
68
|
+
paymentMethods,
|
|
69
|
+
onCallback: (instance) => {
|
|
70
|
+
if (tokenized) return;
|
|
71
|
+
const token = instance.token?.id;
|
|
72
|
+
if (token === void 0) {
|
|
73
|
+
setError(instance.error?.user_message ?? "No pudimos validar el pago. Intenta de nuevo.");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
tokenized = true;
|
|
77
|
+
instance.close();
|
|
78
|
+
onToken(token);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async function openOrder(charge, onChanged) {
|
|
83
|
+
const paymentMethods = CULQI_ORDER_METHODS.get(charge.methodCode);
|
|
84
|
+
if (!charge.publicKey || paymentMethods === void 0) {
|
|
85
|
+
setError(UNAVAILABLE);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await launch({
|
|
89
|
+
publicKey: charge.publicKey,
|
|
90
|
+
charge,
|
|
91
|
+
orderId: charge.orderId,
|
|
92
|
+
paymentMethods,
|
|
93
|
+
onCallback: (instance) => {
|
|
94
|
+
if (instance.order) {
|
|
95
|
+
onChanged();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
setError(instance.error?.user_message ?? "No pudimos generar el código de pago. Intenta de nuevo.");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
loading,
|
|
104
|
+
error,
|
|
105
|
+
open,
|
|
106
|
+
openOrder
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export { useCulqiCheckout };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { paymentReceiptInput } from "./payment-methods-B8ocTgFZ.js";
|
|
2
|
+
import { usePaymentToken } from "./use-payment-token-CErx-tN-.js";
|
|
3
|
+
import { useSubmit } from "react-router";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
// src/use-order-payment.ts
|
|
6
|
+
function useOrderPayment(order) {
|
|
7
|
+
const submit = useSubmit();
|
|
8
|
+
const payment = usePaymentToken();
|
|
9
|
+
const [methodCode, setMethodCode] = useState((order.methods.find((method) => method.isDefault) ?? order.methods[0])?.code ?? "");
|
|
10
|
+
const method = order.methods.find((entry) => entry.code === methodCode);
|
|
11
|
+
async function onSubmit(event) {
|
|
12
|
+
if (method === void 0) return;
|
|
13
|
+
const form = new FormData(event.currentTarget);
|
|
14
|
+
if (payment.open({
|
|
15
|
+
method,
|
|
16
|
+
charge: {
|
|
17
|
+
title: `Pedido ${order.order.orderNumber}`,
|
|
18
|
+
currency: order.order.currencyCode,
|
|
19
|
+
amount: order.balanceDue,
|
|
20
|
+
email: order.order.email
|
|
21
|
+
},
|
|
22
|
+
onToken: (token, providerPaymentMethodId, deviceSessionId) => {
|
|
23
|
+
form.set("token", token);
|
|
24
|
+
if (providerPaymentMethodId !== void 0) form.set("providerPaymentMethodId", providerPaymentMethodId);
|
|
25
|
+
if (deviceSessionId !== void 0) form.set("deviceSessionId", deviceSessionId);
|
|
26
|
+
submit(form, {
|
|
27
|
+
method: "post",
|
|
28
|
+
encType: "multipart/form-data"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
})) event.preventDefault();
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
method,
|
|
35
|
+
methodCode,
|
|
36
|
+
setMethodCode,
|
|
37
|
+
loading: payment.loading,
|
|
38
|
+
error: payment.error,
|
|
39
|
+
dialog: payment.dialog,
|
|
40
|
+
source: payment.source,
|
|
41
|
+
receipt: paymentReceiptInput(method, "order"),
|
|
42
|
+
onSubmit
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export { useOrderPayment };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OrderStatusData } from "./order-status.js";
|
|
2
|
+
import { PaymentInputProps } from "./payment-methods.js";
|
|
3
|
+
import { MercadoPagoDialogState } from "./mercadopago-dialog.js";
|
|
4
|
+
import { CulqiPaymentSource } from "./culqi-three-ds.js";
|
|
5
|
+
import { OrderPaymentMethod } from "@ecomiq/core";
|
|
6
|
+
import { FormEvent, RefObject } from "react";
|
|
7
|
+
export type OrderPaymentControls = {
|
|
8
|
+
method: OrderPaymentMethod | undefined;
|
|
9
|
+
methodCode: string;
|
|
10
|
+
setMethodCode: (code: string) => void;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
receipt: PaymentInputProps | null;
|
|
14
|
+
dialog: MercadoPagoDialogState | null;
|
|
15
|
+
source: RefObject<CulqiPaymentSource | null>;
|
|
16
|
+
onSubmit: (event: FormEvent<HTMLFormElement>) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export declare function useOrderPayment(order: OrderStatusData): OrderPaymentControls;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { CULQI_TOKEN_METHODS } from "./culqi-checkout-CTXpKgp_.js";
|
|
2
|
+
import { MERCADOPAGO_CARD_METHODS, MERCADOPAGO_YAPE_METHODS } from "./mercadopago-checkout-DC7RXa8k.js";
|
|
3
|
+
import { useCulqiCheckout } from "./use-culqi-checkout-CrjLAipU.js";
|
|
4
|
+
import { loadCulqiThreeDS } from "./culqi-three-ds-HP3mfrvV.js";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
// src/use-payment-token.ts
|
|
7
|
+
function usePaymentToken() {
|
|
8
|
+
const culqi = useCulqiCheckout();
|
|
9
|
+
const [dialog, setDialog] = useState(null);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const [fingerprinting, setFingerprinting] = useState(false);
|
|
12
|
+
const source = useRef(null);
|
|
13
|
+
const mounted = useRef(true);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
mounted.current = true;
|
|
16
|
+
return () => {
|
|
17
|
+
mounted.current = false;
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
function open({ method, charge, onToken }) {
|
|
21
|
+
if (method.checkoutMode !== "embedded") return false;
|
|
22
|
+
if (method.providerId === "culqi" && CULQI_TOKEN_METHODS.has(method.code)) {
|
|
23
|
+
setError(null);
|
|
24
|
+
culqi.open({
|
|
25
|
+
...charge,
|
|
26
|
+
methodCode: method.code,
|
|
27
|
+
publicKey: method.publicConfiguration?.publicKey
|
|
28
|
+
}, (token) => {
|
|
29
|
+
if (method.code !== "card") {
|
|
30
|
+
onToken(token);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setFingerprinting(true);
|
|
34
|
+
loadCulqiThreeDS().then(async (sdk) => {
|
|
35
|
+
sdk.reset();
|
|
36
|
+
sdk.publicKey = method.publicConfiguration?.publicKey ?? "";
|
|
37
|
+
sdk.settings = {
|
|
38
|
+
charge: {
|
|
39
|
+
totalAmount: Math.round(charge.amount * 100),
|
|
40
|
+
currency: charge.currency,
|
|
41
|
+
returnUrl: window.location.href
|
|
42
|
+
},
|
|
43
|
+
card: { email: charge.email ?? "" }
|
|
44
|
+
};
|
|
45
|
+
const deviceSessionId = await sdk.generateDevice();
|
|
46
|
+
if (!mounted.current) return;
|
|
47
|
+
if (!deviceSessionId) throw new Error("No pudimos validar este dispositivo. Intenta nuevamente.");
|
|
48
|
+
source.current = {
|
|
49
|
+
token,
|
|
50
|
+
deviceSessionId
|
|
51
|
+
};
|
|
52
|
+
onToken(token, void 0, deviceSessionId);
|
|
53
|
+
}).catch((error) => {
|
|
54
|
+
if (mounted.current) setError(error instanceof Error ? error.message : "No pudimos validar este dispositivo.");
|
|
55
|
+
}).finally(() => {
|
|
56
|
+
if (mounted.current) setFingerprinting(false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (method.providerId !== "mercadopago" || !MERCADOPAGO_CARD_METHODS.has(method.code) && !MERCADOPAGO_YAPE_METHODS.has(method.code)) return false;
|
|
62
|
+
setError(null);
|
|
63
|
+
const publicKey = method.publicConfiguration?.publicKey;
|
|
64
|
+
if (!publicKey) {
|
|
65
|
+
setError("Este medio de pago no está disponible. Elige otro medio de pago.");
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
let tokenized = false;
|
|
69
|
+
const onTokenized = (token, paymentMethodId) => {
|
|
70
|
+
if (tokenized) return;
|
|
71
|
+
tokenized = true;
|
|
72
|
+
setDialog(null);
|
|
73
|
+
onToken(token, paymentMethodId);
|
|
74
|
+
};
|
|
75
|
+
if (MERCADOPAGO_YAPE_METHODS.has(method.code)) setDialog({
|
|
76
|
+
kind: "yape",
|
|
77
|
+
publicKey,
|
|
78
|
+
amount: charge.amount,
|
|
79
|
+
currency: charge.currency,
|
|
80
|
+
onTokenized,
|
|
81
|
+
onClose: () => setDialog(null)
|
|
82
|
+
});
|
|
83
|
+
else setDialog({
|
|
84
|
+
kind: "card",
|
|
85
|
+
publicKey,
|
|
86
|
+
amount: charge.amount,
|
|
87
|
+
email: charge.email,
|
|
88
|
+
onTokenized,
|
|
89
|
+
onClose: () => setDialog(null),
|
|
90
|
+
onError: (message) => {
|
|
91
|
+
setDialog(null);
|
|
92
|
+
setError(message);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
open,
|
|
99
|
+
dialog,
|
|
100
|
+
source,
|
|
101
|
+
loading: culqi.loading || fingerprinting || dialog !== null,
|
|
102
|
+
error: error ?? culqi.error
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export { usePaymentToken };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { paymentLogoSvgs } from "./payment-logo-svgs-By9lDTLK.js";
|
|
2
|
+
import { paymentLogoPath } from "./payment-logos-BYvdwYyJ.js";
|
|
3
|
+
// src/vite-payment-logos.ts
|
|
4
|
+
const files = new Map([...paymentLogoSvgs].map(([code, svg]) => [paymentLogoPath(code), svg]));
|
|
5
|
+
function paymentLogos() {
|
|
6
|
+
return {
|
|
7
|
+
name: "ecomiq:payment-logos",
|
|
8
|
+
configureServer(server) {
|
|
9
|
+
server.middlewares.use((request, response, next) => {
|
|
10
|
+
const svg = files.get(new URL(request.url ?? "/", "http://localhost").pathname);
|
|
11
|
+
if (svg === void 0) return next();
|
|
12
|
+
response.setHeader("Content-Type", "image/svg+xml");
|
|
13
|
+
response.setHeader("Cache-Control", "no-cache");
|
|
14
|
+
response.end(svg);
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
generateBundle() {
|
|
18
|
+
if (this.environment?.config?.consumer !== "client") return;
|
|
19
|
+
for (const [path, svg] of files) this.emitFile({
|
|
20
|
+
type: "asset",
|
|
21
|
+
fileName: path.slice(1),
|
|
22
|
+
source: svg
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export { paymentLogos };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
type Middleware = (request: IncomingMessage, response: ServerResponse, next: () => void) => void;
|
|
3
|
+
type EmittedAsset = {
|
|
4
|
+
type: "asset";
|
|
5
|
+
fileName: string;
|
|
6
|
+
source: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function paymentLogos(): {
|
|
9
|
+
name: string;
|
|
10
|
+
configureServer(server: {
|
|
11
|
+
middlewares: {
|
|
12
|
+
use(middleware: Middleware): unknown;
|
|
13
|
+
};
|
|
14
|
+
}): void;
|
|
15
|
+
generateBundle(this: {
|
|
16
|
+
emitFile(file: EmittedAsset): string;
|
|
17
|
+
environment?: {
|
|
18
|
+
config?: {
|
|
19
|
+
consumer?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}): void;
|
|
23
|
+
};
|
|
24
|
+
export {};
|