@moneydevkit/replit 0.7.0-beta.5 → 0.7.0-beta.7

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
@@ -44,6 +44,7 @@ export default function App() {
44
44
  setError(null)
45
45
 
46
46
  const result = await createCheckout({
47
+ type: 'AMOUNT', // or 'PRODUCTS' for product-based checkouts
47
48
  title: 'Purchase title for the buyer',
48
49
  description: 'Description of the purchase',
49
50
  amount: 500,
@@ -86,6 +87,7 @@ Collect and store customer information with each checkout. Pass `customer` to pr
86
87
 
87
88
  ```tsx
88
89
  const result = await createCheckout({
90
+ type: 'AMOUNT',
89
91
  title: "Premium Plan",
90
92
  description: 'Monthly subscription',
91
93
  amount: 1000,
@@ -119,6 +121,7 @@ When your user is already authenticated in your app, pass `externalId` to link c
119
121
 
120
122
  ```tsx
121
123
  const result = await createCheckout({
124
+ type: 'AMOUNT',
122
125
  title: "Premium Plan",
123
126
  description: 'Monthly subscription',
124
127
  amount: 1000,
@@ -139,7 +142,44 @@ When `externalId` is provided:
139
142
  - Only fields missing from the customer record are requested
140
143
  - This prevents authenticated users from being asked for data you already have
141
144
 
142
- Verify successful payments:
145
+ ## Product Checkouts
146
+ Sell products defined in your Money Dev Kit dashboard using `type: 'PRODUCTS'`:
147
+
148
+ ```tsx
149
+ import { useCheckout, useProducts } from '@moneydevkit/replit'
150
+
151
+ function ProductPage() {
152
+ const { createCheckout, isLoading } = useCheckout()
153
+ const { products } = useProducts()
154
+
155
+ const handleBuyProduct = async (productId: string) => {
156
+ const result = await createCheckout({
157
+ type: 'PRODUCTS',
158
+ products: [productId],
159
+ successUrl: '/checkout/success',
160
+ })
161
+
162
+ if (result.error) return
163
+ window.location.href = result.data.checkoutUrl
164
+ }
165
+
166
+ return (
167
+ <div>
168
+ {products?.map(product => (
169
+ <button key={product.id} onClick={() => handleBuyProduct(product.id)}>
170
+ Buy {product.name} - ${(product.price?.priceAmount ?? 0) / 100}
171
+ </button>
172
+ ))}
173
+ </div>
174
+ )
175
+ }
176
+ ```
177
+
178
+ ### Checkout Types
179
+ - **`type: 'AMOUNT'`** - For donations, tips, or custom amounts. Requires `amount` field.
180
+ - **`type: 'PRODUCTS'`** - For selling products. Requires `products` array with product IDs. Amount is calculated from product prices.
181
+
182
+ ## Verify successful payments
143
183
  ```tsx
144
184
  import { useCheckoutSuccess } from '@moneydevkit/replit'
145
185
 
@@ -0,0 +1 @@
1
+ export { useProducts } from '@moneydevkit/core/client';
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ export { useProducts } from '@moneydevkit/core/client';
3
+ //# sourceMappingURL=useProducts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProducts.js","sourceRoot":"","sources":["../../src/hooks/useProducts.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export { Checkout } from './components/Checkout';
2
2
  export type { CheckoutProps } from './components/Checkout';
3
3
  export { useCheckout } from './hooks/useCheckout';
4
4
  export { useCheckoutSuccess } from './hooks/useCheckoutSuccess';
5
+ export { useProducts } from './hooks/useProducts';
5
6
  export type { MdkError, Result } from '@moneydevkit/core/client';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Checkout } from './components/Checkout';
2
2
  export { useCheckout } from './hooks/useCheckout';
3
3
  export { useCheckoutSuccess } from './hooks/useCheckoutSuccess';
4
+ export { useProducts } from './hooks/useProducts';
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneydevkit/replit",
3
- "version": "0.7.0-beta.5",
3
+ "version": "0.7.0-beta.7",
4
4
  "description": "Money Dev Kit checkout package for Replit (Vite + Express).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  "react-dom": "^18 || ^19"
41
41
  },
42
42
  "dependencies": {
43
- "@moneydevkit/core": "0.7.0-beta.5"
43
+ "@moneydevkit/core": "0.7.0-beta.7"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/express": "^4.17.21",