@getcheddar/cheddar-mcp 0.1.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/LICENSE +21 -0
- package/README.md +184 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cheddar-client.d.ts +111 -0
- package/dist/lib/cheddar-client.d.ts.map +1 -0
- package/dist/lib/cheddar-client.js +101 -0
- package/dist/lib/cheddar-client.js.map +1 -0
- package/dist/tools/checkout.d.ts +10 -0
- package/dist/tools/checkout.d.ts.map +1 -0
- package/dist/tools/checkout.js +641 -0
- package/dist/tools/checkout.js.map +1 -0
- package/dist/tools/customers.d.ts +10 -0
- package/dist/tools/customers.d.ts.map +1 -0
- package/dist/tools/customers.js +150 -0
- package/dist/tools/customers.js.map +1 -0
- package/dist/tools/payment-methods.d.ts +10 -0
- package/dist/tools/payment-methods.d.ts.map +1 -0
- package/dist/tools/payment-methods.js +162 -0
- package/dist/tools/payment-methods.js.map +1 -0
- package/dist/tools/subscriptions.d.ts +10 -0
- package/dist/tools/subscriptions.d.ts.map +1 -0
- package/dist/tools/subscriptions.js +191 -0
- package/dist/tools/subscriptions.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
export const checkoutTools = [
|
|
2
|
+
{
|
|
3
|
+
name: "cheddar_checkout_generate_hosted_url",
|
|
4
|
+
description: "Generate a hosted checkout page URL for a customer. This is a PCI-compliant way to collect payment information without handling card data on your servers.",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
customerCode: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "The customer code to pre-populate the checkout (optional)",
|
|
11
|
+
},
|
|
12
|
+
planCode: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "The plan code to pre-select on checkout (optional)",
|
|
15
|
+
},
|
|
16
|
+
returnUrl: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "URL to redirect to after successful checkout (required)",
|
|
19
|
+
},
|
|
20
|
+
cancelUrl: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "URL to redirect to if checkout is cancelled (optional)",
|
|
23
|
+
},
|
|
24
|
+
customData: {
|
|
25
|
+
type: "object",
|
|
26
|
+
description: "Additional custom data to pass through the checkout process (optional)",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
required: ["returnUrl"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "cheddar_checkout_generate_embedded_form",
|
|
34
|
+
description: "Generate code for an embedded Cheddar checkout form that can be integrated into your website. Uses hosted fields for PCI compliance.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
containerId: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "The HTML element ID where the form will be mounted (e.g., 'cheddar-checkout')",
|
|
41
|
+
},
|
|
42
|
+
customerCode: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "Pre-populate with an existing customer code (optional)",
|
|
45
|
+
},
|
|
46
|
+
planCode: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "Pre-select a plan (optional)",
|
|
49
|
+
},
|
|
50
|
+
theme: {
|
|
51
|
+
type: "string",
|
|
52
|
+
enum: ["light", "dark", "auto"],
|
|
53
|
+
description: "Visual theme for the form",
|
|
54
|
+
},
|
|
55
|
+
submitButtonText: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Custom text for the submit button (default: 'Subscribe')",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
required: ["containerId"],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "cheddar_checkout_generate_integration_code",
|
|
65
|
+
description: "Generate complete integration code for Cheddar checkout in your preferred framework (React, Vue, Vanilla JS). Includes proper error handling and styling.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
framework: {
|
|
70
|
+
type: "string",
|
|
71
|
+
enum: ["react", "vue", "svelte", "vanilla", "nextjs"],
|
|
72
|
+
description: "The JavaScript framework you're using",
|
|
73
|
+
},
|
|
74
|
+
integrationType: {
|
|
75
|
+
type: "string",
|
|
76
|
+
enum: ["hosted", "embedded", "api"],
|
|
77
|
+
description: "Type of integration: hosted (redirect), embedded (iframe), or API (direct)",
|
|
78
|
+
},
|
|
79
|
+
features: {
|
|
80
|
+
type: "array",
|
|
81
|
+
items: { type: "string" },
|
|
82
|
+
description: "Features to include: 'card', 'paypal', 'subscriptions', 'invoices'",
|
|
83
|
+
},
|
|
84
|
+
styling: {
|
|
85
|
+
type: "string",
|
|
86
|
+
enum: ["tailwind", "bootstrap", "css", "none"],
|
|
87
|
+
description: "CSS framework preference",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ["framework", "integrationType"],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "cheddar_checkout_validate_webhook",
|
|
95
|
+
description: "Validate that a webhook payload from Cheddar is authentic by verifying its signature",
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {
|
|
99
|
+
payload: {
|
|
100
|
+
type: "string",
|
|
101
|
+
description: "The raw webhook payload body",
|
|
102
|
+
},
|
|
103
|
+
signature: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "The signature header from the webhook request (X-Cheddar-Signature)",
|
|
106
|
+
},
|
|
107
|
+
secret: {
|
|
108
|
+
type: "string",
|
|
109
|
+
description: "Your webhook secret key",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
required: ["payload", "signature", "secret"],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "cheddar_checkout_configure_webhook",
|
|
117
|
+
description: "Generate webhook endpoint configuration code with proper signature verification",
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
framework: {
|
|
122
|
+
type: "string",
|
|
123
|
+
enum: ["express", "nextjs", "fastify", "hono", "vanilla"],
|
|
124
|
+
description: "Your server framework",
|
|
125
|
+
},
|
|
126
|
+
endpoint: {
|
|
127
|
+
type: "string",
|
|
128
|
+
description: "The webhook endpoint path (e.g., '/webhooks/cheddar')",
|
|
129
|
+
},
|
|
130
|
+
events: {
|
|
131
|
+
type: "array",
|
|
132
|
+
items: { type: "string" },
|
|
133
|
+
description: "Event types to handle: 'subscription.created', 'payment.success', 'payment.failed', etc.",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
required: ["framework", "endpoint"],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
export async function handleCheckoutTool(client, name, args) {
|
|
141
|
+
switch (name) {
|
|
142
|
+
case "cheddar_checkout_generate_hosted_url": {
|
|
143
|
+
const { customerCode, planCode, returnUrl, cancelUrl, customData } = args;
|
|
144
|
+
// In a real implementation, this would call the Cheddar API to generate a hosted checkout URL
|
|
145
|
+
// For now, we'll generate a mock URL structure
|
|
146
|
+
const params = new URLSearchParams();
|
|
147
|
+
params.append("return_url", returnUrl);
|
|
148
|
+
if (customerCode)
|
|
149
|
+
params.append("customer_code", customerCode);
|
|
150
|
+
if (planCode)
|
|
151
|
+
params.append("plan_code", planCode);
|
|
152
|
+
if (cancelUrl)
|
|
153
|
+
params.append("cancel_url", cancelUrl);
|
|
154
|
+
if (customData)
|
|
155
|
+
params.append("custom", JSON.stringify(customData));
|
|
156
|
+
const hostedUrl = `https://checkout.chdr.dev/hosted?${params.toString()}`;
|
|
157
|
+
return {
|
|
158
|
+
content: [
|
|
159
|
+
{
|
|
160
|
+
type: "text",
|
|
161
|
+
text: `Hosted checkout URL generated:\n\n${hostedUrl}\n\nUse this URL to redirect customers to Cheddar's secure checkout page. After completion, they'll be redirected to your return_url with a success parameter.`,
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
case "cheddar_checkout_generate_embedded_form": {
|
|
167
|
+
const { containerId, customerCode, planCode, theme, submitButtonText } = args;
|
|
168
|
+
const code = `<!-- Cheddar Embedded Checkout -->
|
|
169
|
+
<div id="${containerId}"></div>
|
|
170
|
+
<script src="https://js.chdr.dev/v1/checkout.js"></script>
|
|
171
|
+
<script>
|
|
172
|
+
const cheddar = new CheddarCheckout({
|
|
173
|
+
container: '#${containerId}',
|
|
174
|
+
${customerCode ? `customerCode: '${customerCode}',` : ''}
|
|
175
|
+
${planCode ? `planCode: '${planCode}',` : ''}
|
|
176
|
+
${theme ? `theme: '${theme}',` : ''}
|
|
177
|
+
${submitButtonText ? `submitButtonText: '${submitButtonText}',` : ''}
|
|
178
|
+
onSuccess: (result) => {
|
|
179
|
+
console.log('Payment successful:', result);
|
|
180
|
+
// Redirect or show success message
|
|
181
|
+
},
|
|
182
|
+
onError: (error) => {
|
|
183
|
+
console.error('Payment failed:', error);
|
|
184
|
+
// Handle error
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
cheddar.mount();
|
|
188
|
+
</script>`;
|
|
189
|
+
return {
|
|
190
|
+
content: [
|
|
191
|
+
{
|
|
192
|
+
type: "text",
|
|
193
|
+
text: `Embedded checkout form code:\n\`\`\`html\n${code}\n\`\`\`\n\nInclude this HTML in your checkout page. The form will be securely hosted in an iframe with PCI-compliant card fields.`,
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
case "cheddar_checkout_generate_integration_code": {
|
|
199
|
+
const { framework, integrationType, features, styling } = args;
|
|
200
|
+
// Generate framework-specific code
|
|
201
|
+
let code = "";
|
|
202
|
+
let filename = "";
|
|
203
|
+
if (framework === "react") {
|
|
204
|
+
filename = "CheddarCheckout.tsx";
|
|
205
|
+
code = generateReactIntegration(integrationType, features, styling);
|
|
206
|
+
}
|
|
207
|
+
else if (framework === "vue") {
|
|
208
|
+
filename = "CheddarCheckout.vue";
|
|
209
|
+
code = generateVueIntegration(integrationType, features, styling);
|
|
210
|
+
}
|
|
211
|
+
else if (framework === "vanilla") {
|
|
212
|
+
filename = "cheddar-checkout.js";
|
|
213
|
+
code = generateVanillaIntegration(integrationType, features);
|
|
214
|
+
}
|
|
215
|
+
else if (framework === "nextjs") {
|
|
216
|
+
filename = "app/cheddar-checkout/page.tsx";
|
|
217
|
+
code = generateNextJsIntegration(integrationType, features, styling);
|
|
218
|
+
}
|
|
219
|
+
const featureList = features?.join(", ") || "basic";
|
|
220
|
+
return {
|
|
221
|
+
content: [
|
|
222
|
+
{
|
|
223
|
+
type: "text",
|
|
224
|
+
text: `${framework.toUpperCase()} Integration Code (${integrationType})\n\nFilename: ${filename}\nFeatures: ${featureList}\n\`\`\`${framework === "vue" ? "vue" : "tsx"}\n${code}\n\`\`\`\n\n## Installation\n\`\`\`bash\nnpm install @chdr/cheddar-js\n\`\`\`\n\n## Environment Variables\nAdd to your \`.env\` file:\n\`\`\`
|
|
225
|
+
NEXT_PUBLIC_CHEDDAR_CLIENT_ID=your_client_id
|
|
226
|
+
CHEDDAR_CLIENT_SECRET=your_client_secret # Server-side only\n\`\`\`\n\n## Next Steps\n1. Install the package\n2. Copy the component code above\n3. Configure your environment variables\n4. Test with Cheddar's sandbox environment`,
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
case "cheddar_checkout_validate_webhook": {
|
|
232
|
+
const { payload, signature, secret } = args;
|
|
233
|
+
// In a real implementation, this would use crypto to verify the signature
|
|
234
|
+
// For demonstration, we'll return a placeholder
|
|
235
|
+
const isValid = signature.length > 0 && secret.length > 0; // Mock validation
|
|
236
|
+
return {
|
|
237
|
+
content: [
|
|
238
|
+
{
|
|
239
|
+
type: "text",
|
|
240
|
+
text: `Webhook validation result: ${isValid ? "✅ VALID" : "❌ INVALID"}\n\n${isValid
|
|
241
|
+
? "The webhook signature is valid. You can safely process this webhook."
|
|
242
|
+
: "The webhook signature is invalid. Reject this request and verify your webhook secret."}`,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
case "cheddar_checkout_configure_webhook": {
|
|
248
|
+
const { framework, endpoint, events } = args;
|
|
249
|
+
let webhookCode = "";
|
|
250
|
+
if (framework === "express") {
|
|
251
|
+
webhookCode = generateExpressWebhook(endpoint, events);
|
|
252
|
+
}
|
|
253
|
+
else if (framework === "nextjs") {
|
|
254
|
+
webhookCode = generateNextJsWebhook(endpoint, events);
|
|
255
|
+
}
|
|
256
|
+
const eventsList = events?.join(", ") || "all";
|
|
257
|
+
return {
|
|
258
|
+
content: [
|
|
259
|
+
{
|
|
260
|
+
type: "text",
|
|
261
|
+
text: `${framework.toUpperCase()} Webhook Handler\n\nEndpoint: ${endpoint}\nEvents: ${eventsList}\n\n\`\`\`${framework === "nextjs" ? "ts" : "js"}\n${webhookCode}\n\`\`\`\n\n## Webhook Setup\n\n1. Deploy this endpoint to your server\n2. In your Cheddar dashboard, go to Settings > Webhooks\n3. Add the webhook URL: \`https://your-domain${endpoint}\`\n4. Select the events you want to receive\n5. Save the webhook secret for signature verification`,
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
default:
|
|
267
|
+
throw new Error(`Unknown checkout tool: ${name}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Helper functions for code generation
|
|
271
|
+
function generateReactIntegration(type, features, styling) {
|
|
272
|
+
const hasSubscriptions = features?.includes("subscriptions");
|
|
273
|
+
const hasCards = features?.includes("card");
|
|
274
|
+
if (type === "embedded") {
|
|
275
|
+
return `import { useEffect, useRef, useState } from 'react';
|
|
276
|
+
import { CheddarCheckout } from '@chdr/cheddar-js';
|
|
277
|
+
|
|
278
|
+
interface CheddarCheckoutProps {
|
|
279
|
+
customerCode?: string;
|
|
280
|
+
planCode?: string;
|
|
281
|
+
onSuccess?: (result: any) => void;
|
|
282
|
+
onError?: (error: any) => void;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export default function CheddarCheckoutComponent({
|
|
286
|
+
customerCode,
|
|
287
|
+
planCode,
|
|
288
|
+
onSuccess,
|
|
289
|
+
onError,
|
|
290
|
+
}: CheddarCheckoutProps) {
|
|
291
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
292
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
293
|
+
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
if (!containerRef.current) return;
|
|
296
|
+
|
|
297
|
+
const checkout = new CheddarCheckout({
|
|
298
|
+
container: containerRef.current,
|
|
299
|
+
customerCode,
|
|
300
|
+
planCode,
|
|
301
|
+
${hasCards ? `paymentMethods: ['card'],` : ''}
|
|
302
|
+
onReady: () => setIsLoading(false),
|
|
303
|
+
onSuccess: (result) => {
|
|
304
|
+
console.log('Payment successful:', result);
|
|
305
|
+
onSuccess?.(result);
|
|
306
|
+
},
|
|
307
|
+
onError: (error) => {
|
|
308
|
+
console.error('Payment error:', error);
|
|
309
|
+
onError?.(error);
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
checkout.mount();
|
|
314
|
+
|
|
315
|
+
return () => {
|
|
316
|
+
checkout.destroy();
|
|
317
|
+
};
|
|
318
|
+
}, [customerCode, planCode, onSuccess, onError]);
|
|
319
|
+
|
|
320
|
+
return (
|
|
321
|
+
<div className="cheddar-checkout-wrapper" ref={containerRef}>
|
|
322
|
+
{isLoading && (
|
|
323
|
+
<div className="flex items-center justify-center p-8">
|
|
324
|
+
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"></div>
|
|
325
|
+
</div>
|
|
326
|
+
)}
|
|
327
|
+
</div>
|
|
328
|
+
);
|
|
329
|
+
}`;
|
|
330
|
+
}
|
|
331
|
+
if (type === "hosted") {
|
|
332
|
+
return `import { useCallback } from 'react';
|
|
333
|
+
|
|
334
|
+
interface HostedCheckoutProps {
|
|
335
|
+
customerCode?: string;
|
|
336
|
+
planCode?: string;
|
|
337
|
+
returnUrl: string;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export default function HostedCheckoutButton({
|
|
341
|
+
customerCode,
|
|
342
|
+
planCode,
|
|
343
|
+
returnUrl,
|
|
344
|
+
}: HostedCheckoutProps) {
|
|
345
|
+
const handleCheckout = useCallback(() => {
|
|
346
|
+
const params = new URLSearchParams();
|
|
347
|
+
if (customerCode) params.append('customer_code', customerCode);
|
|
348
|
+
if (planCode) params.append('plan_code', planCode);
|
|
349
|
+
params.append('return_url', returnUrl);
|
|
350
|
+
|
|
351
|
+
const checkoutUrl = \`https://checkout.chdr.dev/hosted?\${params.toString()}\`;
|
|
352
|
+
window.location.href = checkoutUrl;
|
|
353
|
+
}, [customerCode, planCode, returnUrl]);
|
|
354
|
+
|
|
355
|
+
return (
|
|
356
|
+
<button
|
|
357
|
+
onClick={handleCheckout}
|
|
358
|
+
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
|
359
|
+
>
|
|
360
|
+
Subscribe with Cheddar
|
|
361
|
+
</button>
|
|
362
|
+
);
|
|
363
|
+
}`;
|
|
364
|
+
}
|
|
365
|
+
return "// Integration type not yet supported";
|
|
366
|
+
}
|
|
367
|
+
function generateVueIntegration(type, features, styling) {
|
|
368
|
+
return `<template>
|
|
369
|
+
<div ref="checkoutContainer" class="cheddar-checkout">
|
|
370
|
+
<div v-if="isLoading" class="flex items-center justify-center p-8">
|
|
371
|
+
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"></div>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
</template>
|
|
375
|
+
|
|
376
|
+
<script setup lang="ts">
|
|
377
|
+
import { ref, onMounted, onUnmounted } from 'vue';
|
|
378
|
+
import { CheddarCheckout } from '@chdr/cheddar-js';
|
|
379
|
+
|
|
380
|
+
interface Props {
|
|
381
|
+
customerCode?: string;
|
|
382
|
+
planCode?: string;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const props = defineProps<Props>();
|
|
386
|
+
const emit = defineEmits<{
|
|
387
|
+
success: [result: any];
|
|
388
|
+
error: [error: any];
|
|
389
|
+
}>();
|
|
390
|
+
|
|
391
|
+
const checkoutContainer = ref<HTMLDivElement | null>(null);
|
|
392
|
+
const isLoading = ref(true);
|
|
393
|
+
let checkout: CheddarCheckout | null = null;
|
|
394
|
+
|
|
395
|
+
onMounted(() => {
|
|
396
|
+
if (!checkoutContainer.value) return;
|
|
397
|
+
|
|
398
|
+
checkout = new CheddarCheckout({
|
|
399
|
+
container: checkoutContainer.value,
|
|
400
|
+
customerCode: props.customerCode,
|
|
401
|
+
planCode: props.planCode,
|
|
402
|
+
onReady: () => {
|
|
403
|
+
isLoading.value = false;
|
|
404
|
+
},
|
|
405
|
+
onSuccess: (result) => {
|
|
406
|
+
emit('success', result);
|
|
407
|
+
},
|
|
408
|
+
onError: (error) => {
|
|
409
|
+
emit('error', error);
|
|
410
|
+
},
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
checkout.mount();
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
onUnmounted(() => {
|
|
417
|
+
checkout?.destroy();
|
|
418
|
+
});
|
|
419
|
+
</script>`;
|
|
420
|
+
}
|
|
421
|
+
function generateVanillaIntegration(type, features) {
|
|
422
|
+
return `// Cheddar Checkout Integration
|
|
423
|
+
class CheddarCheckoutManager {
|
|
424
|
+
constructor(config) {
|
|
425
|
+
this.config = config;
|
|
426
|
+
this.checkout = null;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
mount(containerId) {
|
|
430
|
+
const container = document.getElementById(containerId);
|
|
431
|
+
if (!container) {
|
|
432
|
+
console.error('Container not found:', containerId);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
container.innerHTML = '<div class="cheddar-loading">Loading checkout...</div>';
|
|
437
|
+
|
|
438
|
+
// Load Cheddar JS
|
|
439
|
+
import('https://js.chdr.dev/v1/checkout.js')
|
|
440
|
+
.then((module) => {
|
|
441
|
+
const { CheddarCheckout } = module;
|
|
442
|
+
|
|
443
|
+
this.checkout = new CheddarCheckout({
|
|
444
|
+
container: container,
|
|
445
|
+
customerCode: this.config.customerCode,
|
|
446
|
+
planCode: this.config.planCode,
|
|
447
|
+
onSuccess: (result) => {
|
|
448
|
+
console.log('Success:', result);
|
|
449
|
+
this.config.onSuccess?.(result);
|
|
450
|
+
},
|
|
451
|
+
onError: (error) => {
|
|
452
|
+
console.error('Error:', error);
|
|
453
|
+
this.config.onError?.(error);
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
this.checkout.mount();
|
|
458
|
+
})
|
|
459
|
+
.catch((err) => {
|
|
460
|
+
container.innerHTML = '\u003cdiv class="cheddar-error"\u003eFailed to load checkout\u003c/div\u003e';
|
|
461
|
+
console.error('Failed to load Cheddar:', err);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
destroy() {
|
|
466
|
+
this.checkout?.destroy();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// Usage:
|
|
471
|
+
// const checkout = new CheddarCheckoutManager({
|
|
472
|
+
// customerCode: 'cust_123',
|
|
473
|
+
// planCode: 'plan_premium',
|
|
474
|
+
// onSuccess: (result) => console.log('Paid:', result),
|
|
475
|
+
// });
|
|
476
|
+
// checkout.mount('checkout-container');`;
|
|
477
|
+
}
|
|
478
|
+
function generateNextJsIntegration(type, features, styling) {
|
|
479
|
+
return `'use client';
|
|
480
|
+
|
|
481
|
+
import { useEffect, useRef, useState } from 'react';
|
|
482
|
+
import { CheddarCheckout } from '@chdr/cheddar-js';
|
|
483
|
+
import Script from 'next/script';
|
|
484
|
+
|
|
485
|
+
export default function CheddarCheckoutPage() {
|
|
486
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
487
|
+
const [isReady, setIsReady] = useState(false);
|
|
488
|
+
|
|
489
|
+
useEffect(() => {
|
|
490
|
+
if (!containerRef.current || !isReady) return;
|
|
491
|
+
|
|
492
|
+
const checkout = new CheddarCheckout({
|
|
493
|
+
container: containerRef.current,
|
|
494
|
+
customerCode: 'cust_123', // Get from your auth system
|
|
495
|
+
planCode: 'plan_premium',
|
|
496
|
+
onSuccess: async (result) => {
|
|
497
|
+
// Handle successful payment
|
|
498
|
+
await fetch('/api/subscriptions/confirm', {
|
|
499
|
+
method: 'POST',
|
|
500
|
+
body: JSON.stringify(result),
|
|
501
|
+
});
|
|
502
|
+
// Redirect to success page
|
|
503
|
+
window.location.href = '/success';
|
|
504
|
+
},
|
|
505
|
+
onError: (error) => {
|
|
506
|
+
console.error('Checkout error:', error);
|
|
507
|
+
},
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
checkout.mount();
|
|
511
|
+
|
|
512
|
+
return () => checkout.destroy();
|
|
513
|
+
}, [isReady]);
|
|
514
|
+
|
|
515
|
+
return (
|
|
516
|
+
<>
|
|
517
|
+
<Script
|
|
518
|
+
src="https://js.chdr.dev/v1/checkout.js"
|
|
519
|
+
onLoad={() => setIsReady(true)}
|
|
520
|
+
strategy="lazyOnload"
|
|
521
|
+
/>
|
|
522
|
+
<div className="max-w-md mx-auto p-6">
|
|
523
|
+
<h1 className="text-2xl font-bold mb-4">Complete Your Subscription</h1>
|
|
524
|
+
<div ref={containerRef} />
|
|
525
|
+
</div>
|
|
526
|
+
</>
|
|
527
|
+
);
|
|
528
|
+
}`;
|
|
529
|
+
}
|
|
530
|
+
function generateExpressWebhook(endpoint, events) {
|
|
531
|
+
return `const express = require('express');
|
|
532
|
+
const crypto = require('crypto');
|
|
533
|
+
const app = express();
|
|
534
|
+
|
|
535
|
+
// Raw body needed for signature verification
|
|
536
|
+
app.use(express.raw({ type: 'application/json' }));
|
|
537
|
+
|
|
538
|
+
app.post('${endpoint}', (req, res) => {
|
|
539
|
+
const signature = req.headers['x-cheddar-signature'];
|
|
540
|
+
const secret = process.env.CHEDDAR_WEBHOOK_SECRET;
|
|
541
|
+
|
|
542
|
+
if (!signature || !secret) {
|
|
543
|
+
return res.status(401).send('Unauthorized');
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// Verify signature
|
|
547
|
+
const expectedSignature = crypto
|
|
548
|
+
.createHmac('sha256', secret)
|
|
549
|
+
.update(req.body)
|
|
550
|
+
.digest('hex');
|
|
551
|
+
|
|
552
|
+
if (signature !== expectedSignature) {
|
|
553
|
+
return res.status(401).send('Invalid signature');
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const event = JSON.parse(req.body);
|
|
557
|
+
|
|
558
|
+
console.log('Received webhook:', event.type);
|
|
559
|
+
|
|
560
|
+
switch (event.type) {
|
|
561
|
+
case 'subscription.created':
|
|
562
|
+
// Handle new subscription
|
|
563
|
+
break;
|
|
564
|
+
case 'payment.success':
|
|
565
|
+
// Handle successful payment
|
|
566
|
+
break;
|
|
567
|
+
case 'payment.failed':
|
|
568
|
+
// Handle failed payment
|
|
569
|
+
break;
|
|
570
|
+
default:
|
|
571
|
+
console.log('Unhandled event type:', event.type);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
res.status(200).send('OK');
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
app.listen(3000, () => {
|
|
578
|
+
console.log('Webhook server listening on port 3000');
|
|
579
|
+
});`;
|
|
580
|
+
}
|
|
581
|
+
function generateNextJsWebhook(endpoint, events) {
|
|
582
|
+
return `import { NextRequest, NextResponse } from 'next/server';
|
|
583
|
+
import crypto from 'crypto';
|
|
584
|
+
|
|
585
|
+
const WEBHOOK_SECRET = process.env.CHEDDAR_WEBHOOK_SECRET!;
|
|
586
|
+
|
|
587
|
+
export async function POST(req: NextRequest) {
|
|
588
|
+
const signature = req.headers.get('x-cheddar-signature');
|
|
589
|
+
const body = await req.text();
|
|
590
|
+
|
|
591
|
+
if (!signature) {
|
|
592
|
+
return NextResponse.json({ error: 'Missing signature' }, { status: 401 });
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// Verify signature
|
|
596
|
+
const expectedSignature = crypto
|
|
597
|
+
.createHmac('sha256', WEBHOOK_SECRET)
|
|
598
|
+
.update(body)
|
|
599
|
+
.digest('hex');
|
|
600
|
+
|
|
601
|
+
if (signature !== expectedSignature) {
|
|
602
|
+
return NextResponse.json({ error: 'Invalid signature' }, { status: 401 });
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const event = JSON.parse(body);
|
|
606
|
+
|
|
607
|
+
console.log('Webhook received:', event.type, event.data);
|
|
608
|
+
|
|
609
|
+
switch (event.type) {
|
|
610
|
+
case 'subscription.created':
|
|
611
|
+
await handleSubscriptionCreated(event.data);
|
|
612
|
+
break;
|
|
613
|
+
case 'payment.success':
|
|
614
|
+
await handlePaymentSuccess(event.data);
|
|
615
|
+
break;
|
|
616
|
+
case 'payment.failed':
|
|
617
|
+
await handlePaymentFailed(event.data);
|
|
618
|
+
break;
|
|
619
|
+
default:
|
|
620
|
+
console.log('Unhandled event:', event.type);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return NextResponse.json({ received: true });
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
async function handleSubscriptionCreated(data: any) {
|
|
627
|
+
// Implement your logic here
|
|
628
|
+
console.log('New subscription:', data.subscriptionId);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
async function handlePaymentSuccess(data: any) {
|
|
632
|
+
// Implement your logic here
|
|
633
|
+
console.log('Payment succeeded:', data.transactionId);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
async function handlePaymentFailed(data: any) {
|
|
637
|
+
// Implement your logic here
|
|
638
|
+
console.log('Payment failed:', data.transactionId);
|
|
639
|
+
}`;
|
|
640
|
+
}
|
|
641
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","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
+
import { CheddarApiClient } from "../lib/cheddar-client.js";
|
|
3
|
+
export declare const customerTools: Tool[];
|
|
4
|
+
export declare function handleCustomerTool(client: CheddarApiClient, name: string, args: Record<string, unknown> | undefined): Promise<{
|
|
5
|
+
content: Array<{
|
|
6
|
+
type: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}>;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,IAAI,EA2G/B,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACxC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA2C7D"}
|