@moneydevkit/nextjs 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 +40 -1
- package/package.json +4 -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,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
|
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.7",
|
|
4
4
|
"title": "@moneydevkit/nextjs",
|
|
5
5
|
"description": "moneydevkit checkout components for Next.js.",
|
|
6
6
|
"repository": {
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@hookform/resolvers": "^5.0.1",
|
|
53
|
-
"@moneydevkit/api-contract": "^0.1.
|
|
54
|
-
"@moneydevkit/core": "0.7.0-beta.
|
|
55
|
-
"@moneydevkit/lightning-js": "^0.1.
|
|
53
|
+
"@moneydevkit/api-contract": "^0.1.16",
|
|
54
|
+
"@moneydevkit/core": "0.7.0-beta.7",
|
|
55
|
+
"@moneydevkit/lightning-js": "^0.1.60",
|
|
56
56
|
"@orpc/client": "1.3.0",
|
|
57
57
|
"@orpc/contract": "1.3.0",
|
|
58
58
|
"@radix-ui/react-collapsible": "^1.1.11",
|