@moneydevkit/replit 0.7.0-beta.0 → 0.7.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 +31 -18
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,26 +34,39 @@ Trigger a checkout from your client code (the checkout component pulls in its ow
|
|
|
34
34
|
```tsx
|
|
35
35
|
// src/App.tsx
|
|
36
36
|
import { useCheckout } from '@moneydevkit/replit'
|
|
37
|
+
import { useState } from 'react'
|
|
37
38
|
|
|
38
39
|
export default function App() {
|
|
39
|
-
const {
|
|
40
|
+
const { createCheckout, isLoading } = useCheckout()
|
|
41
|
+
const [error, setError] = useState<string | null>(null)
|
|
42
|
+
|
|
43
|
+
const handlePurchase = async () => {
|
|
44
|
+
setError(null)
|
|
45
|
+
|
|
46
|
+
const result = await createCheckout({
|
|
47
|
+
title: 'Purchase title for the buyer',
|
|
48
|
+
description: 'Description of the purchase',
|
|
49
|
+
amount: 500,
|
|
50
|
+
currency: 'USD',
|
|
51
|
+
successUrl: '/checkout/success',
|
|
52
|
+
metadata: { name: 'John Doe' },
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
if (result.error) {
|
|
56
|
+
setError(result.error.message)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
window.location.href = result.data.checkoutUrl
|
|
61
|
+
}
|
|
40
62
|
|
|
41
63
|
return (
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
currency: 'USD',
|
|
49
|
-
successUrl: '/checkout/success',
|
|
50
|
-
metadata: { name: 'John Doe' },
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
disabled={isNavigating}
|
|
54
|
-
>
|
|
55
|
-
{isNavigating ? 'Creating checkout…' : 'Buy Now'}
|
|
56
|
-
</button>
|
|
64
|
+
<div>
|
|
65
|
+
{error && <p style={{ color: 'red' }}>{error}</p>}
|
|
66
|
+
<button onClick={handlePurchase} disabled={isLoading}>
|
|
67
|
+
{isLoading ? 'Creating checkout…' : 'Buy Now'}
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
57
70
|
)
|
|
58
71
|
}
|
|
59
72
|
```
|
|
@@ -72,7 +85,7 @@ export default function CheckoutPage({ params }: { params: { id: string } }) {
|
|
|
72
85
|
Collect and store customer information with each checkout. Pass `customer` to pre-fill data and `requireCustomerData` to prompt the user for specific fields:
|
|
73
86
|
|
|
74
87
|
```tsx
|
|
75
|
-
|
|
88
|
+
const result = await createCheckout({
|
|
76
89
|
title: "Premium Plan",
|
|
77
90
|
description: 'Monthly subscription',
|
|
78
91
|
amount: 1000,
|
|
@@ -105,7 +118,7 @@ Customers are matched by `email` or `externalId`. When a match is found:
|
|
|
105
118
|
When your user is already authenticated in your app, pass `externalId` to link checkouts to their account:
|
|
106
119
|
|
|
107
120
|
```tsx
|
|
108
|
-
|
|
121
|
+
const result = await createCheckout({
|
|
109
122
|
title: "Premium Plan",
|
|
110
123
|
description: 'Monthly subscription',
|
|
111
124
|
amount: 1000,
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ 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 type { MdkError, Result } from '@moneydevkit/core/client';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneydevkit/replit",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.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.7.0-beta.
|
|
43
|
+
"@moneydevkit/core": "0.7.0-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/express": "^4.17.21",
|