From ed0e32d8cfff29a29ca643376e8d37d28db4febd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Coletta?= Date: Tue, 14 Jan 2025 22:28:19 +0100 Subject: [PATCH] feat: add copilot configuration --- ww-config.js | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) diff --git a/ww-config.js b/ww-config.js index 4f2853b..3f42bef 100644 --- a/ww-config.js +++ b/ww-config.js @@ -34,6 +34,37 @@ export default { !!cancelPage ); }, + copilot: { + description: "Create a Stripe checkout session and redirect to the payment page", + returns: "void - Redirects to Stripe checkout page", + schema: { + mode: { + type: "string", + description: "Payment mode (payment or subscription)", + bindable: true + }, + prices: { + type: "array", + description: "Array of price objects with price IDs and quantities", + bindable: true + }, + paymentMethods: { + type: "array", + description: "Allowed payment methods", + bindable: true + }, + successPage: { + type: "string", + description: "Page ID to redirect after successful payment", + bindable: true + }, + cancelPage: { + type: "string", + description: "Page ID to redirect if payment is cancelled", + bindable: true + } + } + }, /* wwEditor:end */ }, { @@ -45,6 +76,22 @@ export default { getIsValid({ customerId, cancelPage }) { return !!customerId && !!cancelPage; }, + copilot: { + description: "Create and redirect to Stripe customer portal session", + returns: "void - Redirects to customer portal", + schema: { + customerId: { + type: "string", + description: "Stripe customer ID", + bindable: true + }, + cancelPage: { + type: "string", + description: "Page ID to redirect when leaving portal", + bindable: true + } + } + }, /* wwEditor:end */ }, { @@ -61,6 +108,27 @@ export default { ((!!prices.length && !!prices.every(({ price }) => !!price)) || prices.__wwtype !== undefined) ); }, + copilot: { + description: "Create a new Stripe payment intent", + returns: "Payment intent object", + schema: { + prices: { + type: "array", + description: "Array of price objects with price IDs and quantities", + bindable: true + }, + customerId: { + type: "string", + description: "Optional Stripe customer ID", + bindable: true + }, + paymentMethods: { + type: "array", + description: "Allowed payment methods", + bindable: true + } + } + }, /* wwEditor:end */ }, { @@ -72,6 +140,17 @@ export default { getIsValid({ clientSecret }) { return !!clientSecret; }, + copilot: { + description: "Retrieve an existing payment intent by client secret", + returns: "Payment intent object", + schema: { + clientSecret: { + type: "string", + description: "Client secret of the payment intent", + bindable: true + } + } + }, /* wwEditor:end */ }, { @@ -83,6 +162,22 @@ export default { getIsValid({ elementId, redirectPage }) { return !!elementId && !!redirectPage; }, + copilot: { + description: "Confirm a payment using Stripe Elements", + returns: "void - Redirects to result page", + schema: { + elementId: { + type: "string", + description: "ID of the Stripe payment element", + bindable: true + }, + redirectPage: { + type: "string", + description: "Page ID to redirect after confirmation", + bindable: true + } + } + }, /* wwEditor:end */ }, { @@ -94,7 +189,23 @@ export default { getIsValid({ clientSecret, elementId }) { return !!clientSecret && !!elementId; }, + copilot: { + description: "Confirm a card payment using Stripe Elements", + returns: "Payment intent object", + schema: { + clientSecret: { + type: "string", + description: "Client secret of the payment intent", + bindable: true + }, + elementId: { + type: "string", + description: "ID of the Stripe card element", + bindable: true + } + } + }, /* wwEditor:end */ }, ], -}; +}; \ No newline at end of file