@moneydevkit/nextjs 0.7.0-beta.1 → 0.7.0-beta.11
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 +54 -1
- package/dist/hooks/useProducts.d.ts +1 -0
- package/dist/hooks/useProducts.js +3 -0
- package/dist/hooks/useProducts.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/route.d.ts +1 -1
- package/dist/server/route.js +1 -1
- package/dist/server/route.js.map +1 -1
- package/package.json +9 -4
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,57 @@ 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
|
+
product: 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 `product` field with a product ID. Amount is calculated from product price.
|
|
191
|
+
|
|
192
|
+
### Pay What You Want (CUSTOM prices)
|
|
193
|
+
Products can have CUSTOM prices that let customers choose their own amount. When a checkout includes a product with a CUSTOM price, the checkout UI automatically shows an amount input field:
|
|
194
|
+
|
|
195
|
+
```jsx
|
|
196
|
+
// Create a checkout for a product with CUSTOM pricing
|
|
197
|
+
const result = await createCheckout({
|
|
198
|
+
type: 'PRODUCTS',
|
|
199
|
+
product: customPriceProductId, // Product configured with CUSTOM price in dashboard
|
|
200
|
+
successUrl: '/checkout/success',
|
|
201
|
+
})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The customer enters their desired amount during checkout. For USD, amounts are in dollars (converted to cents internally). For SAT, amounts are in satoshis.
|
|
205
|
+
|
|
153
206
|
## Verify successful payments
|
|
154
207
|
When a checkout completes, use `useCheckoutSuccess()` on the success page
|
|
155
208
|
```tsx
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useProducts } from '@moneydevkit/core/client';
|
|
@@ -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
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
|
package/dist/server/route.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { POST } from '@moneydevkit/core/route';
|
|
1
|
+
export { POST, GET } from '@moneydevkit/core/route';
|
package/dist/server/route.js
CHANGED
|
@@ -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
|
package/dist/server/route.js.map
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.7.0-beta.11",
|
|
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,9 +55,9 @@
|
|
|
50
55
|
},
|
|
51
56
|
"dependencies": {
|
|
52
57
|
"@hookform/resolvers": "^5.0.1",
|
|
53
|
-
"@moneydevkit/api-contract": "^0.1.
|
|
54
|
-
"@moneydevkit/core": "0.7.0-beta.
|
|
55
|
-
"@moneydevkit/lightning-js": "^0.1.
|
|
58
|
+
"@moneydevkit/api-contract": "^0.1.17",
|
|
59
|
+
"@moneydevkit/core": "0.7.0-beta.11",
|
|
60
|
+
"@moneydevkit/lightning-js": "^0.1.60",
|
|
56
61
|
"@orpc/client": "1.3.0",
|
|
57
62
|
"@orpc/contract": "1.3.0",
|
|
58
63
|
"@radix-ui/react-collapsible": "^1.1.11",
|