@betterstore/react 0.2.14 → 0.2.15
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/CHANGELOG.md +6 -0
- package/dist/components/checkout-embed/checkout-form.d.ts +3 -1
- package/dist/components/checkout-embed/index.d.ts +2 -0
- package/dist/components/checkout-embed/steps/payment/form.d.ts +3 -1
- package/dist/components/payment-element/index.d.ts +3 -2
- package/dist/index.cjs.js +7 -6
- package/dist/index.mjs +7 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CheckoutSession } from "@betterstore/sdk";
|
|
2
|
+
import { StripeElementsOptions } from "@stripe/stripe-js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { AppearanceConfig } from "./appearance";
|
|
4
5
|
interface CheckoutFormProps {
|
|
@@ -10,6 +11,7 @@ interface CheckoutFormProps {
|
|
|
10
11
|
customer?: CheckoutSession["customer"];
|
|
11
12
|
currency: string;
|
|
12
13
|
checkoutAppearance?: AppearanceConfig;
|
|
14
|
+
fonts?: StripeElementsOptions["fonts"];
|
|
13
15
|
}
|
|
14
|
-
export default function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, }: CheckoutFormProps): React.JSX.Element;
|
|
16
|
+
export default function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, }: CheckoutFormProps): React.JSX.Element;
|
|
15
17
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Locale } from "@/i18n";
|
|
2
|
+
import { StripeElementsOptions } from "@stripe/stripe-js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import { AppearanceConfig } from "./appearance";
|
|
4
5
|
interface CheckoutEmbedProps {
|
|
@@ -8,6 +9,7 @@ interface CheckoutEmbedProps {
|
|
|
8
9
|
cancelUrl: string;
|
|
9
10
|
successUrl: string;
|
|
10
11
|
appearance?: AppearanceConfig;
|
|
12
|
+
fonts?: StripeElementsOptions["fonts"];
|
|
11
13
|
locale?: Locale;
|
|
12
14
|
};
|
|
13
15
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StripeElementsOptions } from "@stripe/stripe-js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { AppearanceConfig } from "../../appearance";
|
|
3
4
|
interface PaymentFormProps {
|
|
@@ -11,6 +12,7 @@ interface PaymentFormProps {
|
|
|
11
12
|
shippingProvider: string;
|
|
12
13
|
shippingPrice: string;
|
|
13
14
|
checkoutAppearance?: AppearanceConfig;
|
|
15
|
+
fonts?: StripeElementsOptions["fonts"];
|
|
14
16
|
}
|
|
15
|
-
export default function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingAddress, shippingProvider, shippingPrice, checkoutAppearance, }: PaymentFormProps): React.JSX.Element;
|
|
17
|
+
export default function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingAddress, shippingProvider, shippingPrice, checkoutAppearance, fonts, }: PaymentFormProps): React.JSX.Element;
|
|
16
18
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Appearance } from "@stripe/stripe-js";
|
|
1
|
+
import { Appearance, StripeElementsOptions } from "@stripe/stripe-js";
|
|
2
2
|
import React from "react";
|
|
3
|
-
declare function PaymentElement({ paymentSecret, checkoutAppearance, onSuccess, onError, children, }: {
|
|
3
|
+
declare function PaymentElement({ paymentSecret, checkoutAppearance, fonts, onSuccess, onError, children, }: {
|
|
4
4
|
paymentSecret: string;
|
|
5
5
|
checkoutAppearance?: Appearance;
|
|
6
|
+
fonts?: StripeElementsOptions["fonts"];
|
|
6
7
|
onSuccess?: () => void;
|
|
7
8
|
onError?: () => void;
|
|
8
9
|
children: React.ReactNode;
|
package/dist/index.cjs.js
CHANGED
|
@@ -31660,18 +31660,19 @@ var CheckoutForm$2 = React.memo(CheckoutForm$1);
|
|
|
31660
31660
|
|
|
31661
31661
|
const publicStripeKey = "pk_test_51OjSZ2JoDmiuDQz4Vub296KIgTCy4y8NJos59h93bq3sLe3veuXnV9XVmvvWDFlt3aEWHY4pOuIXyahEjjKZwezn00qo4U5fQS";
|
|
31662
31662
|
const stripePromise = stripeJs.loadStripe(publicStripeKey);
|
|
31663
|
-
function PaymentElement({ paymentSecret, checkoutAppearance, onSuccess, onError, children, }) {
|
|
31663
|
+
function PaymentElement({ paymentSecret, checkoutAppearance, fonts, onSuccess, onError, children, }) {
|
|
31664
31664
|
const options = {
|
|
31665
31665
|
locale: "en",
|
|
31666
31666
|
appearance: checkoutAppearance,
|
|
31667
31667
|
clientSecret: paymentSecret,
|
|
31668
|
+
fonts: fonts,
|
|
31668
31669
|
};
|
|
31669
31670
|
return (React.createElement(reactStripeJs.Elements, { stripe: stripePromise, options: options },
|
|
31670
31671
|
React.createElement(CheckoutForm$2, { onSuccess: onSuccess, onError: onError, children: children })));
|
|
31671
31672
|
}
|
|
31672
31673
|
var PaymentElement$1 = React.memo(PaymentElement);
|
|
31673
31674
|
|
|
31674
|
-
function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingAddress, shippingProvider, shippingPrice, checkoutAppearance, }) {
|
|
31675
|
+
function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingAddress, shippingProvider, shippingPrice, checkoutAppearance, fonts, }) {
|
|
31675
31676
|
const { t } = reactI18next.useTranslation();
|
|
31676
31677
|
return (React.createElement("div", { className: "space-y-6" },
|
|
31677
31678
|
React.createElement("div", null,
|
|
@@ -31699,7 +31700,7 @@ function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack,
|
|
|
31699
31700
|
" \u00B7 ",
|
|
31700
31701
|
shippingPrice)),
|
|
31701
31702
|
React.createElement(Button, { variant: "link", onClick: onBack }, t("CheckoutEmbed.Shipping.change")))),
|
|
31702
|
-
React.createElement("div", { className: "mt-8" }, paymentSecret && (React.createElement(PaymentElement$1, { checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance), paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError },
|
|
31703
|
+
React.createElement("div", { className: "mt-8" }, paymentSecret && (React.createElement(PaymentElement$1, { fonts: fonts, checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance), paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError },
|
|
31703
31704
|
React.createElement("div", { className: "flex justify-between items-center pt-8" },
|
|
31704
31705
|
React.createElement(Button, { type: "button", variant: "ghost", onClick: onBack },
|
|
31705
31706
|
React.createElement(lucideReact.ChevronLeft, null),
|
|
@@ -31796,7 +31797,7 @@ const motionSettings = {
|
|
|
31796
31797
|
exit: { opacity: 0 },
|
|
31797
31798
|
transition: { duration: 0.2 },
|
|
31798
31799
|
};
|
|
31799
|
-
function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, }) {
|
|
31800
|
+
function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, }) {
|
|
31800
31801
|
const { formData, setFormData, step, setStep } = useFormStore(checkoutId)();
|
|
31801
31802
|
const [paymentSecret, setPaymentSecret] = React.useState(null);
|
|
31802
31803
|
const [shippingRates, setShippingRates] = React.useState([]);
|
|
@@ -31923,7 +31924,7 @@ function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret,
|
|
|
31923
31924
|
step === "shipping" && formData.customer && (React.createElement(motion.div, Object.assign({ key: "shipping" }, motionSettings, { className: "absolute w-full" }),
|
|
31924
31925
|
React.createElement(ShippingMethodForm, { shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address) }))),
|
|
31925
31926
|
step === "payment" && formData.customer && formData.shipping && (React.createElement(motion.div, Object.assign({ key: "payment" }, motionSettings, { className: "absolute w-full" }),
|
|
31926
|
-
React.createElement(PaymentForm, { checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), shippingProvider: formData.shipping.provider, shippingPrice: formData.shipping.amount.toString() + " " + currency }))))));
|
|
31927
|
+
React.createElement(PaymentForm, { fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), shippingProvider: formData.shipping.provider, shippingPrice: formData.shipping.amount.toString() + " " + currency }))))));
|
|
31927
31928
|
}
|
|
31928
31929
|
|
|
31929
31930
|
function CheckoutFormLoading() {
|
|
@@ -32065,7 +32066,7 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
32065
32066
|
}
|
|
32066
32067
|
return (React.createElement("div", { className: "checkout-embed mx-auto max-w-[1200px] min-h-screen overflow-x-hidden py-8 md:py-12 grid md:grid-cols-7 " },
|
|
32067
32068
|
React.createElement(Appearance, { appearance: appearance }),
|
|
32068
|
-
React.createElement("div", { className: "md:col-span-4 px-4 md:px-8" }, loading ? (React.createElement(CheckoutFormLoading, null)) : (React.createElement(CheckoutForm, { checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError }))),
|
|
32069
|
+
React.createElement("div", { className: "md:col-span-4 px-4 md:px-8" }, loading ? (React.createElement(CheckoutFormLoading, null)) : (React.createElement(CheckoutForm, { fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError }))),
|
|
32069
32070
|
React.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" }, loading ? (React.createElement(CheckoutSummaryLoading, null)) : (React.createElement(CheckoutSummary, { currency: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _b !== void 0 ? _b : "", lineItems: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _c !== void 0 ? _c : [], shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax, cancelUrl: cancelUrl, exchangeRate: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _d !== void 0 ? _d : 1 })))));
|
|
32070
32071
|
}
|
|
32071
32072
|
var index = React.memo(CheckoutEmbed);
|
package/dist/index.mjs
CHANGED
|
@@ -31637,18 +31637,19 @@ var CheckoutForm$2 = memo$1(CheckoutForm$1);
|
|
|
31637
31637
|
|
|
31638
31638
|
const publicStripeKey = "pk_test_51OjSZ2JoDmiuDQz4Vub296KIgTCy4y8NJos59h93bq3sLe3veuXnV9XVmvvWDFlt3aEWHY4pOuIXyahEjjKZwezn00qo4U5fQS";
|
|
31639
31639
|
const stripePromise = loadStripe(publicStripeKey);
|
|
31640
|
-
function PaymentElement({ paymentSecret, checkoutAppearance, onSuccess, onError, children, }) {
|
|
31640
|
+
function PaymentElement({ paymentSecret, checkoutAppearance, fonts, onSuccess, onError, children, }) {
|
|
31641
31641
|
const options = {
|
|
31642
31642
|
locale: "en",
|
|
31643
31643
|
appearance: checkoutAppearance,
|
|
31644
31644
|
clientSecret: paymentSecret,
|
|
31645
|
+
fonts: fonts,
|
|
31645
31646
|
};
|
|
31646
31647
|
return (React__default.createElement(Elements, { stripe: stripePromise, options: options },
|
|
31647
31648
|
React__default.createElement(CheckoutForm$2, { onSuccess: onSuccess, onError: onError, children: children })));
|
|
31648
31649
|
}
|
|
31649
31650
|
var PaymentElement$1 = memo$1(PaymentElement);
|
|
31650
31651
|
|
|
31651
|
-
function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingAddress, shippingProvider, shippingPrice, checkoutAppearance, }) {
|
|
31652
|
+
function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingAddress, shippingProvider, shippingPrice, checkoutAppearance, fonts, }) {
|
|
31652
31653
|
const { t } = useTranslation();
|
|
31653
31654
|
return (React__default.createElement("div", { className: "space-y-6" },
|
|
31654
31655
|
React__default.createElement("div", null,
|
|
@@ -31676,7 +31677,7 @@ function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack,
|
|
|
31676
31677
|
" \u00B7 ",
|
|
31677
31678
|
shippingPrice)),
|
|
31678
31679
|
React__default.createElement(Button, { variant: "link", onClick: onBack }, t("CheckoutEmbed.Shipping.change")))),
|
|
31679
|
-
React__default.createElement("div", { className: "mt-8" }, paymentSecret && (React__default.createElement(PaymentElement$1, { checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance), paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError },
|
|
31680
|
+
React__default.createElement("div", { className: "mt-8" }, paymentSecret && (React__default.createElement(PaymentElement$1, { fonts: fonts, checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance), paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError },
|
|
31680
31681
|
React__default.createElement("div", { className: "flex justify-between items-center pt-8" },
|
|
31681
31682
|
React__default.createElement(Button, { type: "button", variant: "ghost", onClick: onBack },
|
|
31682
31683
|
React__default.createElement(ChevronLeft, null),
|
|
@@ -31773,7 +31774,7 @@ const motionSettings = {
|
|
|
31773
31774
|
exit: { opacity: 0 },
|
|
31774
31775
|
transition: { duration: 0.2 },
|
|
31775
31776
|
};
|
|
31776
|
-
function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, }) {
|
|
31777
|
+
function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, }) {
|
|
31777
31778
|
const { formData, setFormData, step, setStep } = useFormStore(checkoutId)();
|
|
31778
31779
|
const [paymentSecret, setPaymentSecret] = useState(null);
|
|
31779
31780
|
const [shippingRates, setShippingRates] = useState([]);
|
|
@@ -31900,7 +31901,7 @@ function CheckoutForm({ checkoutId, onSuccess, onError, cancelUrl, clientSecret,
|
|
|
31900
31901
|
step === "shipping" && formData.customer && (React__default.createElement(motion.div, Object.assign({ key: "shipping" }, motionSettings, { className: "absolute w-full" }),
|
|
31901
31902
|
React__default.createElement(ShippingMethodForm, { shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address) }))),
|
|
31902
31903
|
step === "payment" && formData.customer && formData.shipping && (React__default.createElement(motion.div, Object.assign({ key: "payment" }, motionSettings, { className: "absolute w-full" }),
|
|
31903
|
-
React__default.createElement(PaymentForm, { checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), shippingProvider: formData.shipping.provider, shippingPrice: formData.shipping.amount.toString() + " " + currency }))))));
|
|
31904
|
+
React__default.createElement(PaymentForm, { fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), shippingProvider: formData.shipping.provider, shippingPrice: formData.shipping.amount.toString() + " " + currency }))))));
|
|
31904
31905
|
}
|
|
31905
31906
|
|
|
31906
31907
|
function CheckoutFormLoading() {
|
|
@@ -32042,7 +32043,7 @@ function CheckoutEmbed({ checkoutId, config }) {
|
|
|
32042
32043
|
}
|
|
32043
32044
|
return (React__default.createElement("div", { className: "checkout-embed mx-auto max-w-[1200px] min-h-screen overflow-x-hidden py-8 md:py-12 grid md:grid-cols-7 " },
|
|
32044
32045
|
React__default.createElement(Appearance, { appearance: appearance }),
|
|
32045
|
-
React__default.createElement("div", { className: "md:col-span-4 px-4 md:px-8" }, loading ? (React__default.createElement(CheckoutFormLoading, null)) : (React__default.createElement(CheckoutForm, { checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError }))),
|
|
32046
|
+
React__default.createElement("div", { className: "md:col-span-4 px-4 md:px-8" }, loading ? (React__default.createElement(CheckoutFormLoading, null)) : (React__default.createElement(CheckoutForm, { fonts: config.fonts, checkoutAppearance: appearance, currency: (_a = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _a !== void 0 ? _a : "", customer: checkout === null || checkout === void 0 ? void 0 : checkout.customer, cancelUrl: cancelUrl, checkoutId: checkoutId, clientSecret: clientSecret, onSuccess: onSuccess, onError: onError }))),
|
|
32046
32047
|
React__default.createElement("div", { className: "md:col-span-3 px-4 md:px-8 order-first md:order-last" }, loading ? (React__default.createElement(CheckoutSummaryLoading, null)) : (React__default.createElement(CheckoutSummary, { currency: (_b = checkout === null || checkout === void 0 ? void 0 : checkout.currency) !== null && _b !== void 0 ? _b : "", lineItems: (_c = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) !== null && _c !== void 0 ? _c : [], shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax, cancelUrl: cancelUrl, exchangeRate: (_d = checkout === null || checkout === void 0 ? void 0 : checkout.exchangeRate) !== null && _d !== void 0 ? _d : 1 })))));
|
|
32047
32048
|
}
|
|
32048
32049
|
var index = memo$1(CheckoutEmbed);
|