From 7fb5a74d2eb5f6627afe2548399e387e8bae3f4f Mon Sep 17 00:00:00 2001 From: Scott Kennedy Date: Sat, 16 Mar 2024 14:05:02 +0000 Subject: [PATCH] Use new getStripePaymentIntent endpoint --- functions/stripe.ts | 23 ------------------- netlify.toml | 6 ----- .../components/shopElements/StripeElement.vue | 17 ++++---------- woonuxt_base/composables/useAuth.ts | 5 +++- woonuxt_base/composables/useCart.ts | 3 +++ .../queries/getStripePaymentIntent.gql | 9 ++++++++ 6 files changed, 21 insertions(+), 42 deletions(-) delete mode 100644 functions/stripe.ts create mode 100644 woonuxt_base/queries/getStripePaymentIntent.gql diff --git a/functions/stripe.ts b/functions/stripe.ts deleted file mode 100644 index 0d9dcd4..0000000 --- a/functions/stripe.ts +++ /dev/null @@ -1,23 +0,0 @@ -const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); - -exports.handler = async (event: any, context: any) => { - const { amount, currency } = JSON.parse(event.body); - - try { - const paymentIntent = await stripe.paymentIntents.create({ - amount: parseInt(amount), - currency: currency || 'eur', - payment_method_types: ['card'], - }); - - return { - statusCode: 200, - body: JSON.stringify({ ...paymentIntent }), - }; - } catch (error) { - return { - statusCode: 500, - body: JSON.stringify({ error }), - }; - } -}; diff --git a/netlify.toml b/netlify.toml index 8359c40..3768647 100644 --- a/netlify.toml +++ b/netlify.toml @@ -4,12 +4,6 @@ [build] command = "nuxi generate" - functions = "functions" - -[[redirects]] - from = '/api/*' - to = '/.netlify/functions/:splat' - status = 200 [[headers]] for = "/*.js" diff --git a/woonuxt_base/components/shopElements/StripeElement.vue b/woonuxt_base/components/shopElements/StripeElement.vue index ec3ce6d..ba3aaf1 100644 --- a/woonuxt_base/components/shopElements/StripeElement.vue +++ b/woonuxt_base/components/shopElements/StripeElement.vue @@ -1,22 +1,14 @@