@betterstore/react 0.2.8 → 0.2.10

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/.prettierignore CHANGED
@@ -1,3 +1,3 @@
1
- node_modules
2
- dist
1
+ node_modules
2
+ dist
3
3
  pnpm-lock.yaml
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.2.10
4
+
5
+ ### Patch Changes
6
+
7
+ - prep commit
8
+
9
+ ## 0.2.9
10
+
11
+ ### Patch Changes
12
+
13
+ - cicd test
14
+
3
15
  ## 0.2.8
4
16
 
5
17
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Better Store
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Better Store
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,8 +1,16 @@
1
+ import BetterStore from "@betterstore/sdk";
1
2
  import React from "react";
2
- declare function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, }: {
3
+ type BetterStoreClient = () => {
4
+ retrieveCheckout: InstanceType<typeof BetterStore>["checkout"]["retrieve"];
5
+ updateCheckout: InstanceType<typeof BetterStore>["checkout"]["update"];
6
+ getShippingRates: InstanceType<typeof BetterStore>["checkout"]["getShippingRates"];
7
+ };
8
+ interface CheckoutEmbedProps {
3
9
  checkoutId: string;
4
10
  cancelUrl: string;
5
11
  successUrl: string;
6
- }): React.JSX.Element;
12
+ client: BetterStoreClient;
13
+ }
14
+ declare function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, client, }: CheckoutEmbedProps): React.JSX.Element;
7
15
  declare const _default: React.MemoExoticComponent<typeof CheckoutEmbed>;
8
16
  export default _default;
package/dist/index.cjs.js CHANGED
@@ -981,7 +981,7 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, }) {
981
981
  React.createElement("span", { className: "text-2xl font-bold" }, formatPrice(total)))))));
982
982
  }
983
983
 
984
- function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, }) {
984
+ function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, client, }) {
985
985
  const [checkout, setCheckout] = React.useState(null);
986
986
  const [loading, setLoading] = React.useState(true);
987
987
  React.useEffect(() => {
@@ -989,11 +989,11 @@ function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, }) {
989
989
  function fetchCheckout() {
990
990
  return __awaiter(this, void 0, void 0, function* () {
991
991
  try {
992
- const response = yield fetch(`/api/betterstore/checkout?checkoutId=${checkoutId}`);
993
- const data = yield response.json();
992
+ const checkout = yield client().retrieveCheckout(checkoutId);
993
+ console.log("checkout", checkout);
994
994
  if (mounted) {
995
995
  // Only update state if component is still mounted
996
- setCheckout(data);
996
+ setCheckout(checkout);
997
997
  setLoading(false);
998
998
  }
999
999
  }
package/dist/index.mjs CHANGED
@@ -957,7 +957,7 @@ function CheckoutSummary({ lineItems, shipping, tax, currency, }) {
957
957
  React__default.createElement("span", { className: "text-2xl font-bold" }, formatPrice(total)))))));
958
958
  }
959
959
 
960
- function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, }) {
960
+ function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, client, }) {
961
961
  const [checkout, setCheckout] = useState(null);
962
962
  const [loading, setLoading] = useState(true);
963
963
  useEffect(() => {
@@ -965,11 +965,11 @@ function CheckoutEmbed({ checkoutId, cancelUrl, successUrl, }) {
965
965
  function fetchCheckout() {
966
966
  return __awaiter(this, void 0, void 0, function* () {
967
967
  try {
968
- const response = yield fetch(`/api/betterstore/checkout?checkoutId=${checkoutId}`);
969
- const data = yield response.json();
968
+ const checkout = yield client().retrieveCheckout(checkoutId);
969
+ console.log("checkout", checkout);
970
970
  if (mounted) {
971
971
  // Only update state if component is still mounted
972
- setCheckout(data);
972
+ setCheckout(checkout);
973
973
  setLoading(false);
974
974
  }
975
975
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/react",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -10,16 +10,6 @@
10
10
  "module": "dist/index.mjs",
11
11
  "types": "dist/index.d.ts",
12
12
  "type": "module",
13
- "scripts": {
14
- "dev": "vite",
15
- "prepublish": "changeset && changeset version && git add .",
16
- "build": "rollup -c",
17
- "lint": "tsc",
18
- "format:check": "prettier --check --ignore-path .prettierignore .",
19
- "format": "prettier --write --ignore-path .prettierignore .",
20
- "ci": "pnpm run lint && pnpm run format:check && pnpm run build",
21
- "release": "pnpm run ci && changeset publish"
22
- },
23
13
  "keywords": [
24
14
  "betterstore",
25
15
  "ecommerce",
@@ -29,12 +19,13 @@
29
19
  "author": "Better Store",
30
20
  "license": "MIT",
31
21
  "devDependencies": {
32
- "@betterstore/sdk": "^0.2.2",
22
+ "@betterstore/sdk": "^0.2.11",
33
23
  "@changesets/cli": "^2.28.1",
34
24
  "@rollup/plugin-commonjs": "^28.0.3",
35
25
  "@rollup/plugin-node-resolve": "^16.0.0",
36
26
  "@rollup/plugin-typescript": "^12.1.2",
37
27
  "@tailwindcss/postcss": "^4.0.12",
28
+ "@types/node": "^22.13.10",
38
29
  "@types/react": "^18.3.18",
39
30
  "@types/react-dom": "^18.3.5",
40
31
  "@vitejs/plugin-react": "^4.3.4",
@@ -62,6 +53,7 @@
62
53
  "@radix-ui/react-slot": "^1.1.2",
63
54
  "@stripe/react-stripe-js": "^3.3.0",
64
55
  "@stripe/stripe-js": "^5.10.0",
56
+ "axios": "^1.8.2",
65
57
  "class-variance-authority": "^0.7.1",
66
58
  "clsx": "^2.1.1",
67
59
  "lucide-react": "^0.479.0",
@@ -72,5 +64,15 @@
72
64
  "tailwindcss-animate": "^1.0.7",
73
65
  "zod": "^3.24.2",
74
66
  "zustand": "^5.0.3"
67
+ },
68
+ "scripts": {
69
+ "dev": "vite",
70
+ "prep": "changeset && changeset version && git add .",
71
+ "build": "rollup -c",
72
+ "lint": "tsc",
73
+ "format:check": "prettier --check --ignore-path .prettierignore .",
74
+ "format": "prettier --write --ignore-path .prettierignore .",
75
+ "ci": "pnpm run lint && pnpm run format:check && pnpm run build",
76
+ "release": "pnpm run ci && pnpm publish -r --no-git-checks"
75
77
  }
76
- }
78
+ }