@moneydevkit/replit 0.5.0-beta.1 → 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.
Files changed (2) hide show
  1. package/README.md +58 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -68,6 +68,64 @@ export default function CheckoutPage({ params }: { params: { id: string } }) {
68
68
  }
69
69
  ```
70
70
 
71
+ ## Customer Data
72
+ Collect and store customer information with each checkout. Pass `customer` to pre-fill data and `requireCustomerData` to prompt the user for specific fields:
73
+
74
+ ```tsx
75
+ navigate({
76
+ title: "Premium Plan",
77
+ description: 'Monthly subscription',
78
+ amount: 1000,
79
+ currency: 'USD',
80
+ successUrl: '/checkout/success',
81
+ // Pre-fill customer data (optional)
82
+ customer: {
83
+ name: 'John Doe',
84
+ email: 'john@example.com',
85
+ },
86
+ // Require fields at checkout (shows form if not provided)
87
+ requireCustomerData: ['name', 'email', 'company'],
88
+ })
89
+ ```
90
+
91
+ ### How it works
92
+ - If all `requireCustomerData` fields are already provided in `customer`, the form is skipped
93
+ - If some required fields are missing, a form is shown to collect only those fields
94
+ - **Email is required** to create a customer record. Without email, customer data is attached to the checkout but no customer record is created
95
+ - Field names are flexible: `tax_id`, `tax-id`, `taxId`, or `Tax ID` all normalize to `taxId`
96
+ - Custom fields (beyond `name`, `email`, `externalId`) are stored in customer metadata
97
+
98
+ ### Returning customers
99
+ Customers are matched by `email` or `externalId`. When a match is found:
100
+ - Existing customer data is preserved and not overwritten
101
+ - Only missing fields from `requireCustomerData` are requested
102
+ - All checkouts and orders are linked to the same customer record
103
+
104
+ ### Using externalId for authenticated users
105
+ When your user is already authenticated in your app, pass `externalId` to link checkouts to their account:
106
+
107
+ ```tsx
108
+ navigate({
109
+ title: "Premium Plan",
110
+ description: 'Monthly subscription',
111
+ amount: 1000,
112
+ currency: 'USD',
113
+ successUrl: '/checkout/success',
114
+ customer: {
115
+ externalId: user.id, // Your app's user ID
116
+ name: user.name,
117
+ email: user.email,
118
+ },
119
+ requireCustomerData: ['name', 'email'],
120
+ })
121
+ ```
122
+
123
+ When `externalId` is provided:
124
+ - The system assumes the user is authenticated
125
+ - If the customer already exists (matched by `externalId`), their stored `name` and `email` are used
126
+ - Only fields missing from the customer record are requested
127
+ - This prevents authenticated users from being asked for data you already have
128
+
71
129
  Verify successful payments:
72
130
  ```tsx
73
131
  import { useCheckoutSuccess } from '@moneydevkit/replit'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneydevkit/replit",
3
- "version": "0.5.0-beta.1",
3
+ "version": "0.5.0-beta.2",
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.5.0-beta.1"
43
+ "@moneydevkit/core": "0.5.0-beta.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/express": "^4.17.21",