@betterstore/react 0.1.1 → 0.1.2
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/index.d.ts +8 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/index.cjs.js +33 -13
- package/dist/index.d.ts +1 -3
- package/dist/index.esm.js +33 -13
- package/package.json +1 -1
- package/dist/checkout-embed/index.d.ts +0 -6
- /package/dist/{checkout-embed → components/checkout-embed}/summary/index.d.ts +0 -0
- /package/dist/{checkout → components/payment-element}/appearance.d.ts +0 -0
- /package/dist/{checkout → components/payment-element}/checkout-form.d.ts +0 -0
- /package/dist/{checkout/payment-element.d.ts → components/payment-element/index.d.ts} +0 -0
- /package/dist/{checkout → components/payment-element}/useCheckout.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import BetterStore from "@betterstore/sdk";
|
|
2
|
+
import React from "react";
|
|
3
|
+
declare function CheckoutEmbed({ betterStore, checkoutId, }: {
|
|
4
|
+
betterStore: InstanceType<typeof BetterStore>;
|
|
5
|
+
checkoutId: string;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
declare const _default: React.MemoExoticComponent<typeof CheckoutEmbed>;
|
|
8
|
+
export default _default;
|
package/dist/index.cjs.js
CHANGED
|
@@ -76,18 +76,38 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, }) {
|
|
|
76
76
|
React.createElement("span", { className: "text-2xl font-bold" }, formatPrice(total)))))));
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
function CheckoutEmbed(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
function CheckoutEmbed({ betterStore, checkoutId, }) {
|
|
80
|
+
const [checkout, setCheckout] = React.useState(null);
|
|
81
|
+
const [loading, setLoading] = React.useState(true);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
function fetchCheckout() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
try {
|
|
86
|
+
const data = yield betterStore.checkout.retrieve(checkoutId);
|
|
87
|
+
setCheckout(data);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error("Failed to fetch checkout:", error);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
setLoading(false);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
84
96
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
97
|
+
fetchCheckout();
|
|
98
|
+
}, [betterStore, checkoutId]);
|
|
99
|
+
if (loading) {
|
|
100
|
+
return React.createElement("div", null, "Loading...");
|
|
101
|
+
}
|
|
102
|
+
if (!checkout) {
|
|
103
|
+
return React.createElement("div", null, "Checkout not found");
|
|
104
|
+
}
|
|
105
|
+
return (React.createElement("div", { className: "grid md:grid-cols-2 gap-4" },
|
|
106
|
+
React.createElement("div", null, "forms here"),
|
|
107
|
+
React.createElement("div", null,
|
|
108
|
+
React.createElement(CheckoutSummary, { currency: checkout.currency, lineItems: checkout.lineItems, shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax }))));
|
|
90
109
|
}
|
|
110
|
+
var index$1 = React.memo(CheckoutEmbed);
|
|
91
111
|
|
|
92
112
|
function getDefaultExportFromCjs (x) {
|
|
93
113
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -2285,8 +2305,8 @@ function PaymentElement({ paymentSecret, checkoutAppearance, onSuccess, onError,
|
|
|
2285
2305
|
return (React.createElement(Elements, { stripe: stripePromise, options: options },
|
|
2286
2306
|
React.createElement(CheckoutForm$1, { onSuccess: onSuccess, onError: onError, children: children })));
|
|
2287
2307
|
}
|
|
2288
|
-
var
|
|
2308
|
+
var index = React.memo(PaymentElement);
|
|
2289
2309
|
|
|
2290
|
-
exports.CheckoutEmbed =
|
|
2291
|
-
exports.PaymentElement =
|
|
2310
|
+
exports.CheckoutEmbed = index$1;
|
|
2311
|
+
exports.PaymentElement = index;
|
|
2292
2312
|
exports.useCheckout = useCheckout;
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo, useState } from 'react';
|
|
1
|
+
import React, { memo, useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -74,18 +74,38 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, }) {
|
|
|
74
74
|
React.createElement("span", { className: "text-2xl font-bold" }, formatPrice(total)))))));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function CheckoutEmbed(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
function CheckoutEmbed({ betterStore, checkoutId, }) {
|
|
78
|
+
const [checkout, setCheckout] = useState(null);
|
|
79
|
+
const [loading, setLoading] = useState(true);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
function fetchCheckout() {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
try {
|
|
84
|
+
const data = yield betterStore.checkout.retrieve(checkoutId);
|
|
85
|
+
setCheckout(data);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error("Failed to fetch checkout:", error);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
setLoading(false);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
82
94
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
95
|
+
fetchCheckout();
|
|
96
|
+
}, [betterStore, checkoutId]);
|
|
97
|
+
if (loading) {
|
|
98
|
+
return React.createElement("div", null, "Loading...");
|
|
99
|
+
}
|
|
100
|
+
if (!checkout) {
|
|
101
|
+
return React.createElement("div", null, "Checkout not found");
|
|
102
|
+
}
|
|
103
|
+
return (React.createElement("div", { className: "grid md:grid-cols-2 gap-4" },
|
|
104
|
+
React.createElement("div", null, "forms here"),
|
|
105
|
+
React.createElement("div", null,
|
|
106
|
+
React.createElement(CheckoutSummary, { currency: checkout.currency, lineItems: checkout.lineItems, shipping: checkout === null || checkout === void 0 ? void 0 : checkout.shipping, tax: checkout === null || checkout === void 0 ? void 0 : checkout.tax }))));
|
|
88
107
|
}
|
|
108
|
+
var index$1 = memo(CheckoutEmbed);
|
|
89
109
|
|
|
90
110
|
function getDefaultExportFromCjs (x) {
|
|
91
111
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -2283,6 +2303,6 @@ function PaymentElement({ paymentSecret, checkoutAppearance, onSuccess, onError,
|
|
|
2283
2303
|
return (React.createElement(Elements, { stripe: stripePromise, options: options },
|
|
2284
2304
|
React.createElement(CheckoutForm$1, { onSuccess: onSuccess, onError: onError, children: children })));
|
|
2285
2305
|
}
|
|
2286
|
-
var
|
|
2306
|
+
var index = memo(PaymentElement);
|
|
2287
2307
|
|
|
2288
|
-
export { CheckoutEmbed,
|
|
2308
|
+
export { index$1 as CheckoutEmbed, index as PaymentElement, useCheckout };
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|