@dodopayments/nuxt 0.1.5 → 0.2.0
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
CHANGED
|
@@ -32,9 +32,9 @@ export default defineNuxtConfig({
|
|
|
32
32
|
bearerToken: process.env.NUXT_PRIVATE_BEARER_TOKEN,
|
|
33
33
|
webhookKey: process.env.NUXT_PRIVATE_BEARER_TOKEN,
|
|
34
34
|
environment: process.env.NUXT_PRIVATE_ENVIRONMENT,
|
|
35
|
-
returnUrl: process.env.NUXT_PRIVATE_RETURNURL
|
|
35
|
+
returnUrl: process.env.NUXT_PRIVATE_RETURNURL,
|
|
36
36
|
},
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -47,11 +47,11 @@ export default defineEventHandler((event) => {
|
|
|
47
47
|
const {
|
|
48
48
|
private: { bearerToken, environment, returnUrl },
|
|
49
49
|
} = useRuntimeConfig();
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
const handler = checkoutHandler({
|
|
52
52
|
bearerToken: bearerToken,
|
|
53
|
-
environment:
|
|
54
|
-
returnUrl: returnUrl
|
|
53
|
+
environment: environment,
|
|
54
|
+
returnUrl: returnUrl,
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
return handler(event);
|
|
@@ -60,7 +60,6 @@ export default defineEventHandler((event) => {
|
|
|
60
60
|
|
|
61
61
|
- Accepts GET requests with `productId` as a query parameter.
|
|
62
62
|
|
|
63
|
-
|
|
64
63
|
### 3. Customer Portal API Route
|
|
65
64
|
|
|
66
65
|
Create a new file at `server/routes/api/customer-portal.get.ts`:
|
|
@@ -68,16 +67,16 @@ Create a new file at `server/routes/api/customer-portal.get.ts`:
|
|
|
68
67
|
```ts
|
|
69
68
|
export default defineEventHandler((event) => {
|
|
70
69
|
const {
|
|
71
|
-
private: { bearerToken, environment }
|
|
72
|
-
} = useRuntimeConfig()
|
|
70
|
+
private: { bearerToken, environment },
|
|
71
|
+
} = useRuntimeConfig();
|
|
73
72
|
|
|
74
73
|
const handler = customerPortalHandler({
|
|
75
74
|
bearerToken,
|
|
76
75
|
environment: environment,
|
|
77
|
-
})
|
|
76
|
+
});
|
|
78
77
|
|
|
79
|
-
return handler(event)
|
|
80
|
-
})
|
|
78
|
+
return handler(event);
|
|
79
|
+
});
|
|
81
80
|
```
|
|
82
81
|
|
|
83
82
|
- Accepts GET requests with `customer_id` as a query parameter.
|
|
@@ -89,20 +88,19 @@ Create a new file at `server/routes/api/webhook.post.ts`:
|
|
|
89
88
|
|
|
90
89
|
```ts
|
|
91
90
|
export default defineEventHandler((event) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const handler = Webhooks({
|
|
97
|
-
webhookKey: webhookKey,
|
|
98
|
-
onPayload: async (payload: any) => {
|
|
99
|
-
// Handle here
|
|
100
|
-
}
|
|
101
|
-
})
|
|
91
|
+
const {
|
|
92
|
+
private: { webhookKey },
|
|
93
|
+
} = useRuntimeConfig();
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
const handler = Webhooks({
|
|
96
|
+
webhookKey: webhookKey,
|
|
97
|
+
onPayload: async (payload: any) => {
|
|
98
|
+
// Handle here
|
|
99
|
+
},
|
|
100
|
+
});
|
|
105
101
|
|
|
102
|
+
return handler(event);
|
|
103
|
+
});
|
|
106
104
|
```
|
|
107
105
|
|
|
108
106
|
- Only POST requests are supported. Signature is verified using `webhookSecret`.
|
|
@@ -127,7 +125,6 @@ NUXT_PRIVATE_RETURN_URL=""
|
|
|
127
125
|
|
|
128
126
|
---
|
|
129
127
|
|
|
130
|
-
|
|
131
128
|
## Prompt for LLM
|
|
132
129
|
|
|
133
130
|
```
|
|
@@ -210,7 +207,7 @@ Dynamic Checkout (POST): Parameters are sent as a JSON body. Supports both one-t
|
|
|
210
207
|
- Docs - Subscription Product: https://docs.dodopayments.com/api-reference/subscriptions/post-subscriptions
|
|
211
208
|
|
|
212
209
|
Checkout Sessions (POST) - (Recommended) A more customizable checkout experience:
|
|
213
|
-
- Parameters are sent as a JSON body. Supports both one-time and recurring payments.
|
|
210
|
+
- Parameters are sent as a JSON body. Supports both one-time and recurring payments.
|
|
214
211
|
- Returns: {"checkout_url": "https://checkout.dodopayments.com/session/..."}
|
|
215
212
|
- For a complete list of supported POST body fields, refer to:
|
|
216
213
|
- Docs - One Time Payment Product: https://docs.dodopayments.com/api-reference/payments/post-payments
|
|
@@ -320,4 +317,4 @@ webhookKey: useRuntimeConfig().private.webhookKey
|
|
|
320
317
|
Important: Never commit sensitive environment variables directly into your version control. Use environment variables for all sensitive information.
|
|
321
318
|
|
|
322
319
|
If the user needs assistance setting up environment variables for their specific deployment environment, ask them what platform they are using (e.g., Vercel, Netlify, AWS, etc.), and provide guidance.
|
|
323
|
-
```
|
|
320
|
+
```
|
package/dist/module.json
CHANGED
|
@@ -19,7 +19,11 @@ export function checkoutHandler(config) {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
|
-
const url = await buildCheckoutUrl({
|
|
22
|
+
const url = await buildCheckoutUrl({
|
|
23
|
+
body: data,
|
|
24
|
+
...config,
|
|
25
|
+
type: "dynamic"
|
|
26
|
+
});
|
|
23
27
|
return { checkout_url: url };
|
|
24
28
|
} catch (error2) {
|
|
25
29
|
throw createError({ statusCode: 400, statusMessage: error2.message });
|
|
@@ -20,7 +20,10 @@ export function customerPortalHandler(config) {
|
|
|
20
20
|
);
|
|
21
21
|
return sendRedirect(event, session.link, 302);
|
|
22
22
|
} catch (error) {
|
|
23
|
-
return {
|
|
23
|
+
return {
|
|
24
|
+
status: 500,
|
|
25
|
+
body: `Failed to create customer portal session: ${error.message}`
|
|
26
|
+
};
|
|
24
27
|
}
|
|
25
28
|
};
|
|
26
29
|
}
|
|
@@ -39,7 +39,10 @@ export function Webhooks(config) {
|
|
|
39
39
|
try {
|
|
40
40
|
payload = JSON.parse(rawString);
|
|
41
41
|
} catch {
|
|
42
|
-
throw createError({
|
|
42
|
+
throw createError({
|
|
43
|
+
statusCode: 400,
|
|
44
|
+
statusMessage: "Invalid JSON payload"
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
const { success, data, error } = WebhookPayloadSchema.safeParse(payload);
|
|
45
48
|
if (!success) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodopayments/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Dodo Payments Nuxt integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dev": "rollup -c -w"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dodopayments/core": "^0.
|
|
23
|
+
"@dodopayments/core": "^0.2.0",
|
|
24
24
|
"@nuxt/module-builder": "^1.0.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|