@sintecinformatik/checkout 1.0.0 → 1.1.0

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/README.md CHANGED
@@ -5,10 +5,33 @@ React components for integrating Sintec License Server checkout into your produc
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @sintec/checkout
8
+ npm install @sintecinformatik/checkout
9
9
  ```
10
10
 
11
- > **Note**: Package not yet published to npm. For now, copy the source from this directory or use a local path reference.
11
+ ## Finding Your Product Slug
12
+
13
+ To find available products and their slugs, call the products endpoint:
14
+
15
+ ```bash
16
+ curl https://license.sintec.ch/api/v1/checkout/products
17
+ ```
18
+
19
+ Response:
20
+ ```json
21
+ [
22
+ {
23
+ "slug": "littlewoodshed",
24
+ "name": "LittleWoodshed",
25
+ "perpetualPriceCents": 19900,
26
+ "monthlyPriceCents": 900,
27
+ "yearlyPriceCents": 7800,
28
+ "currency": "chf",
29
+ "checkoutEnabled": true
30
+ }
31
+ ]
32
+ ```
33
+
34
+ Use the `slug` value as your `productSlug` prop.
12
35
 
13
36
  ## Usage
14
37
 
@@ -17,7 +40,7 @@ npm install @sintec/checkout
17
40
  The simplest way to add a buy button:
18
41
 
19
42
  ```tsx
20
- import { CheckoutButton } from "@sintec/checkout";
43
+ import { CheckoutButton } from "@sintecinformatik/checkout";
21
44
 
22
45
  function BuyPage() {
23
46
  return (
@@ -38,7 +61,7 @@ function BuyPage() {
38
61
  For custom UI implementations:
39
62
 
40
63
  ```tsx
41
- import { useCheckout } from "@sintec/checkout";
64
+ import { useCheckout } from "@sintecinformatik/checkout";
42
65
 
43
66
  function CustomCheckout() {
44
67
  const { startCheckout, isLoading, error } = useCheckout();
package/dist/index.d.mts CHANGED
@@ -31,6 +31,18 @@ interface CheckoutSessionResponse {
31
31
  interface CheckoutErrorResponse {
32
32
  error: string;
33
33
  }
34
+ interface ProductPricing {
35
+ id: string;
36
+ name: string;
37
+ slug: string;
38
+ description: string | null;
39
+ perpetualPriceCents: number | null;
40
+ monthlyPriceCents: number | null;
41
+ yearlyPriceCents: number | null;
42
+ currency: string;
43
+ checkoutEnabled: boolean;
44
+ trialDaysLimit: number;
45
+ }
34
46
 
35
47
  declare function CheckoutButton({ productSlug, licenseType, customerEmail, serverUrl, className, children, onCheckoutStart, onError, }: CheckoutButtonProps): react_jsx_runtime.JSX.Element;
36
48
 
@@ -44,4 +56,11 @@ interface UseCheckoutReturn {
44
56
  }
45
57
  declare function useCheckout(options?: CheckoutOptions): UseCheckoutReturn;
46
58
 
47
- export { CheckoutButton, type CheckoutButtonProps, type CheckoutErrorResponse, type CheckoutOptions, type CheckoutSessionResponse, type LicenseType, type StartCheckoutParams, type UseCheckoutReturn, useCheckout };
59
+ interface UseProductReturn {
60
+ product: ProductPricing | null;
61
+ isLoading: boolean;
62
+ error: string | null;
63
+ }
64
+ declare function useProduct(slug: string, options?: CheckoutOptions): UseProductReturn;
65
+
66
+ export { CheckoutButton, type CheckoutButtonProps, type CheckoutErrorResponse, type CheckoutOptions, type CheckoutSessionResponse, type LicenseType, type ProductPricing, type StartCheckoutParams, type UseCheckoutReturn, type UseProductReturn, useCheckout, useProduct };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,18 @@ interface CheckoutSessionResponse {
31
31
  interface CheckoutErrorResponse {
32
32
  error: string;
33
33
  }
34
+ interface ProductPricing {
35
+ id: string;
36
+ name: string;
37
+ slug: string;
38
+ description: string | null;
39
+ perpetualPriceCents: number | null;
40
+ monthlyPriceCents: number | null;
41
+ yearlyPriceCents: number | null;
42
+ currency: string;
43
+ checkoutEnabled: boolean;
44
+ trialDaysLimit: number;
45
+ }
34
46
 
35
47
  declare function CheckoutButton({ productSlug, licenseType, customerEmail, serverUrl, className, children, onCheckoutStart, onError, }: CheckoutButtonProps): react_jsx_runtime.JSX.Element;
36
48
 
@@ -44,4 +56,11 @@ interface UseCheckoutReturn {
44
56
  }
45
57
  declare function useCheckout(options?: CheckoutOptions): UseCheckoutReturn;
46
58
 
47
- export { CheckoutButton, type CheckoutButtonProps, type CheckoutErrorResponse, type CheckoutOptions, type CheckoutSessionResponse, type LicenseType, type StartCheckoutParams, type UseCheckoutReturn, useCheckout };
59
+ interface UseProductReturn {
60
+ product: ProductPricing | null;
61
+ isLoading: boolean;
62
+ error: string | null;
63
+ }
64
+ declare function useProduct(slug: string, options?: CheckoutOptions): UseProductReturn;
65
+
66
+ export { CheckoutButton, type CheckoutButtonProps, type CheckoutErrorResponse, type CheckoutOptions, type CheckoutSessionResponse, type LicenseType, type ProductPricing, type StartCheckoutParams, type UseCheckoutReturn, type UseProductReturn, useCheckout, useProduct };
package/dist/index.js CHANGED
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  CheckoutButton: () => CheckoutButton,
24
- useCheckout: () => useCheckout
24
+ useCheckout: () => useCheckout,
25
+ useProduct: () => useProduct
25
26
  });
26
27
  module.exports = __toCommonJS(index_exports);
27
28
 
@@ -113,8 +114,40 @@ function CheckoutButton({
113
114
  }
114
115
  );
115
116
  }
117
+
118
+ // src/useProduct.ts
119
+ var import_react2 = require("react");
120
+ var DEFAULT_SERVER_URL2 = "https://license.sintec.ch";
121
+ function useProduct(slug, options = {}) {
122
+ const { serverUrl = DEFAULT_SERVER_URL2 } = options;
123
+ const [product, setProduct] = (0, import_react2.useState)(null);
124
+ const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
125
+ const [error, setError] = (0, import_react2.useState)(null);
126
+ (0, import_react2.useEffect)(() => {
127
+ async function fetchProduct() {
128
+ setIsLoading(true);
129
+ setError(null);
130
+ try {
131
+ const response = await fetch(`${serverUrl}/api/v1/checkout/products/${slug}`);
132
+ if (!response.ok) {
133
+ const data2 = await response.json();
134
+ throw new Error(data2.error || "Failed to fetch product");
135
+ }
136
+ const data = await response.json();
137
+ setProduct(data);
138
+ } catch (err) {
139
+ setError(err instanceof Error ? err.message : "Failed to fetch product");
140
+ } finally {
141
+ setIsLoading(false);
142
+ }
143
+ }
144
+ fetchProduct();
145
+ }, [slug, serverUrl]);
146
+ return { product, isLoading, error };
147
+ }
116
148
  // Annotate the CommonJS export names for ESM import in node:
117
149
  0 && (module.exports = {
118
150
  CheckoutButton,
119
- useCheckout
151
+ useCheckout,
152
+ useProduct
120
153
  });
package/dist/index.mjs CHANGED
@@ -86,7 +86,39 @@ function CheckoutButton({
86
86
  }
87
87
  );
88
88
  }
89
+
90
+ // src/useProduct.ts
91
+ import { useState as useState2, useEffect } from "react";
92
+ var DEFAULT_SERVER_URL2 = "https://license.sintec.ch";
93
+ function useProduct(slug, options = {}) {
94
+ const { serverUrl = DEFAULT_SERVER_URL2 } = options;
95
+ const [product, setProduct] = useState2(null);
96
+ const [isLoading, setIsLoading] = useState2(true);
97
+ const [error, setError] = useState2(null);
98
+ useEffect(() => {
99
+ async function fetchProduct() {
100
+ setIsLoading(true);
101
+ setError(null);
102
+ try {
103
+ const response = await fetch(`${serverUrl}/api/v1/checkout/products/${slug}`);
104
+ if (!response.ok) {
105
+ const data2 = await response.json();
106
+ throw new Error(data2.error || "Failed to fetch product");
107
+ }
108
+ const data = await response.json();
109
+ setProduct(data);
110
+ } catch (err) {
111
+ setError(err instanceof Error ? err.message : "Failed to fetch product");
112
+ } finally {
113
+ setIsLoading(false);
114
+ }
115
+ }
116
+ fetchProduct();
117
+ }, [slug, serverUrl]);
118
+ return { product, isLoading, error };
119
+ }
89
120
  export {
90
121
  CheckoutButton,
91
- useCheckout
122
+ useCheckout,
123
+ useProduct
92
124
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sintecinformatik/checkout",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Checkout components for Sintec License Server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",