@moneydevkit/nextjs 0.7.0-beta.6 → 0.7.0-beta.8

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
@@ -31,13 +31,13 @@ export default function HomePage() {
31
31
  setError(null)
32
32
 
33
33
  const result = await createCheckout({
34
+ type: 'AMOUNT', // or 'PRODUCTS' for product-based checkouts
34
35
  title: 'Describe the purchase shown to the buyer',
35
36
  description: 'A description of the purchase',
36
37
  amount: 500, // 500 USD cents or Bitcoin sats
37
38
  currency: 'USD', // or 'SAT'
38
39
  successUrl: '/checkout/success',
39
40
  metadata: {
40
- type: 'my_type',
41
41
  customField: 'internal reference for this checkout',
42
42
  name: 'John Doe'
43
43
  }
@@ -97,6 +97,7 @@ Collect and store customer information with each checkout. Pass `customer` to pr
97
97
 
98
98
  ```jsx
99
99
  const result = await createCheckout({
100
+ type: 'AMOUNT',
100
101
  title: "Premium Plan",
101
102
  description: 'Monthly subscription',
102
103
  amount: 1000,
@@ -130,6 +131,7 @@ When your user is already authenticated in your app, pass `externalId` to link c
130
131
 
131
132
  ```jsx
132
133
  const result = await createCheckout({
134
+ type: 'AMOUNT',
133
135
  title: "Premium Plan",
134
136
  description: 'Monthly subscription',
135
137
  amount: 1000,
@@ -150,6 +152,43 @@ When `externalId` is provided:
150
152
  - Only fields missing from the customer record are requested
151
153
  - This prevents authenticated users from being asked for data you already have
152
154
 
155
+ ## Product Checkouts
156
+ Sell products defined in your Money Dev Kit dashboard using `type: 'PRODUCTS'`:
157
+
158
+ ```jsx
159
+ import { useCheckout, useProducts } from '@moneydevkit/nextjs'
160
+
161
+ function ProductPage() {
162
+ const { createCheckout, isLoading } = useCheckout()
163
+ const { products } = useProducts()
164
+
165
+ const handleBuyProduct = async (productId) => {
166
+ const result = await createCheckout({
167
+ type: 'PRODUCTS',
168
+ products: [productId],
169
+ successUrl: '/checkout/success',
170
+ })
171
+
172
+ if (result.error) return
173
+ window.location.href = result.data.checkoutUrl
174
+ }
175
+
176
+ return (
177
+ <div>
178
+ {products?.map(product => (
179
+ <button key={product.id} onClick={() => handleBuyProduct(product.id)}>
180
+ Buy {product.name} - ${(product.price?.priceAmount ?? 0) / 100}
181
+ </button>
182
+ ))}
183
+ </div>
184
+ )
185
+ }
186
+ ```
187
+
188
+ ### Checkout Types
189
+ - **`type: 'AMOUNT'`** - For donations, tips, or custom amounts. Requires `amount` field.
190
+ - **`type: 'PRODUCTS'`** - For selling products. Requires `products` array with product IDs. Amount is calculated from product prices.
191
+
153
192
  ## Verify successful payments
154
193
  When a checkout completes, use `useCheckoutSuccess()` on the success page
155
194
  ```tsx
@@ -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"}
@@ -0,0 +1,2 @@
1
+ export { createCheckoutUrl } from '@moneydevkit/core/route';
2
+ export type { CreateCheckoutUrlOptions } from '@moneydevkit/core/route';
@@ -0,0 +1,2 @@
1
+ export { createCheckoutUrl } from '@moneydevkit/core/route';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1 +1 @@
1
- export { POST } from '@moneydevkit/core/route';
1
+ export { POST, GET } from '@moneydevkit/core/route';
@@ -1,2 +1,2 @@
1
- export { POST } from '@moneydevkit/core/route';
1
+ export { POST, GET } from '@moneydevkit/core/route';
2
2
  //# sourceMappingURL=route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/server/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/server/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneydevkit/nextjs",
3
- "version": "0.7.0-beta.6",
3
+ "version": "0.7.0-beta.8",
4
4
  "title": "@moneydevkit/nextjs",
5
5
  "description": "moneydevkit checkout components for Next.js.",
6
6
  "repository": {
@@ -20,6 +20,11 @@
20
20
  },
21
21
  "./mdk-styles.css": "./dist/mdk-styles.css",
22
22
  "./package.json": "./package.json",
23
+ "./server": {
24
+ "types": "./dist/server/index.d.ts",
25
+ "import": "./dist/server/index.js",
26
+ "default": "./dist/server/index.js"
27
+ },
23
28
  "./server/route": {
24
29
  "types": "./dist/server/route.d.ts",
25
30
  "import": "./dist/server/route.js",
@@ -50,8 +55,8 @@
50
55
  },
51
56
  "dependencies": {
52
57
  "@hookform/resolvers": "^5.0.1",
53
- "@moneydevkit/api-contract": "^0.1.13",
54
- "@moneydevkit/core": "0.7.0-beta.6",
58
+ "@moneydevkit/api-contract": "^0.1.16",
59
+ "@moneydevkit/core": "0.7.0-beta.8",
55
60
  "@moneydevkit/lightning-js": "^0.1.60",
56
61
  "@orpc/client": "1.3.0",
57
62
  "@orpc/contract": "1.3.0",