@moneydevkit/nextjs 0.5.0-beta.0 → 0.5.0-beta.2
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 +58 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -78,6 +78,64 @@ export default withMdkCheckout({})
|
|
|
78
78
|
|
|
79
79
|
You now have a complete Lightning checkout loop: the button creates a session, the dynamic route renders it, and the webhook endpoint signals your Lightning node to claim paid invoices.
|
|
80
80
|
|
|
81
|
+
## Customer Data
|
|
82
|
+
Collect and store customer information with each checkout. Pass `customer` to pre-fill data and `requireCustomerData` to prompt the user for specific fields:
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
navigate({
|
|
86
|
+
title: "Premium Plan",
|
|
87
|
+
description: 'Monthly subscription',
|
|
88
|
+
amount: 1000,
|
|
89
|
+
currency: 'USD',
|
|
90
|
+
successUrl: '/checkout/success',
|
|
91
|
+
// Pre-fill customer data (optional)
|
|
92
|
+
customer: {
|
|
93
|
+
name: 'John Doe',
|
|
94
|
+
email: 'john@example.com',
|
|
95
|
+
},
|
|
96
|
+
// Require fields at checkout (shows form if not provided)
|
|
97
|
+
requireCustomerData: ['name', 'email', 'company'],
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### How it works
|
|
102
|
+
- If all `requireCustomerData` fields are already provided in `customer`, the form is skipped
|
|
103
|
+
- If some required fields are missing, a form is shown to collect only those fields
|
|
104
|
+
- **Email is required** to create a customer record. Without email, customer data is attached to the checkout but no customer record is created
|
|
105
|
+
- Field names are flexible: `tax_id`, `tax-id`, `taxId`, or `Tax ID` all normalize to `taxId`
|
|
106
|
+
- Custom fields (beyond `name`, `email`, `externalId`) are stored in customer metadata
|
|
107
|
+
|
|
108
|
+
### Returning customers
|
|
109
|
+
Customers are matched by `email` or `externalId`. When a match is found:
|
|
110
|
+
- Existing customer data is preserved and not overwritten
|
|
111
|
+
- Only missing fields from `requireCustomerData` are requested
|
|
112
|
+
- All checkouts and orders are linked to the same customer record
|
|
113
|
+
|
|
114
|
+
### Using externalId for authenticated users
|
|
115
|
+
When your user is already authenticated in your app, pass `externalId` to link checkouts to their account:
|
|
116
|
+
|
|
117
|
+
```jsx
|
|
118
|
+
navigate({
|
|
119
|
+
title: "Premium Plan",
|
|
120
|
+
description: 'Monthly subscription',
|
|
121
|
+
amount: 1000,
|
|
122
|
+
currency: 'USD',
|
|
123
|
+
successUrl: '/checkout/success',
|
|
124
|
+
customer: {
|
|
125
|
+
externalId: user.id, // Your app's user ID
|
|
126
|
+
name: user.name,
|
|
127
|
+
email: user.email,
|
|
128
|
+
},
|
|
129
|
+
requireCustomerData: ['name', 'email'],
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
When `externalId` is provided:
|
|
134
|
+
- The system assumes the user is authenticated
|
|
135
|
+
- If the customer already exists (matched by `externalId`), their stored `name` and `email` are used
|
|
136
|
+
- Only fields missing from the customer record are requested
|
|
137
|
+
- This prevents authenticated users from being asked for data you already have
|
|
138
|
+
|
|
81
139
|
## Verify successful payments
|
|
82
140
|
When a checkout completes, use `useCheckoutSuccess()` on the success page
|
|
83
141
|
```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneydevkit/nextjs",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.2",
|
|
4
4
|
"title": "@moneydevkit/nextjs",
|
|
5
5
|
"description": "moneydevkit checkout components for Next.js.",
|
|
6
6
|
"repository": {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@hookform/resolvers": "^5.0.1",
|
|
53
|
-
"@moneydevkit/api-contract": "^0.1.
|
|
54
|
-
"@moneydevkit/core": "0.5.0-beta.
|
|
53
|
+
"@moneydevkit/api-contract": "^0.1.13",
|
|
54
|
+
"@moneydevkit/core": "0.5.0-beta.2",
|
|
55
55
|
"@moneydevkit/lightning-js": "^0.1.54",
|
|
56
56
|
"@orpc/client": "1.3.0",
|
|
57
57
|
"@orpc/contract": "1.3.0",
|