Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3. Seeding your Stripe account step failed #457

Open
ogawa5773 opened this issue Jul 19, 2023 · 1 comment
Open

3. Seeding your Stripe account step failed #457

ogawa5773 opened this issue Jul 19, 2023 · 1 comment

Comments

@ogawa5773
Copy link

ogawa5773 commented Jul 19, 2023

What is happening

Follow the README and in the step "3. Seeding your Stripe account" I got an error like below

Error in script: Cannot find module '/Users/xxx/redwood/example-store-stripe/api/src/lib/stripe'
Require stack:
- /Users/xxx/example-store-stripe/scripts/seed-stripe.js
- /Users/xxx/example-store-stripe/node_modules/@redwoodjs/cli/dist/lib/exec.js
- /Users/xxx/example-store-stripe/node_modules/@redwoodjs/cli/dist/commands/execHandler.js
[FAILED] Cannot find module '/Users/xxx/example-store-stripe/api/src/lib/stripe'
[FAILED] Require stack:
[FAILED] - /Users/xxx/example-store-stripe/scripts/seed-stripe.js
[FAILED] - /Users/xxx/example-store-stripe/node_modules/@redwoodjs/cli/dist/lib/exec.js
[FAILED] - /Users/xxx/example-store-stripe/node_modules/@redwoodjs/cli/dist/commands/execHandler.js
The script exited with errors.

My Solution

I was able to proceed without any problems by revert the following commit

commit 822e875fb62649dc2df29553fa2b768dfb33e0ee (origin/tmp)
...
diff --git a/api/src/lib/stripe.js b/api/src/lib/stripe.js
deleted file mode 100644
index 78d89c9..0000000
--- a/api/src/lib/stripe.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import Stripe from 'stripe'
-
-export const stripe = new Stripe(process.env.STRIPE_SK)
-
-export const handleStripeWebhooks = (event, context, webhooksObj) => {
-  let stripeEvent
-  try {
-    const sig = event.headers['stripe-signature']
-    stripeEvent = stripe.webhooks.constructEvent(
-      event.body,
-      sig,
-      process.env.STRIPE_WEBHOOK_SK
-    )
-
-    let results = null
-    if (typeof webhooksObj[stripeEvent.type] !== 'undefined') {
-      results = webhooksObj[stripeEvent.type](event, context)
-    }
-    return results
-  } catch (error) {
-    console.log(error)
-    throw error
-  }
-}

Question

Is this an intentional file deletion or a bug?

@jacebenson
Copy link

jacebenson commented Jul 22, 2024

Not sure, but since this comment, the readme uses a different env variable; here's my version

// ./api/src/lib/stripe.js

import Stripe from 'stripe'

export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)

export const handleStripeWebhooks = (event, context, webhooksObj) => {
  let stripeEvent
  try {
    const sig = event.headers['stripe-signature']
    stripeEvent = stripe.webhooks.constructEvent(
      event.body,
      sig,
      process.env.STRIPE_WEBHOOK_SK
    )

    let results = null
    if (typeof webhooksObj[stripeEvent.type] !== 'undefined') {
      results = webhooksObj[stripeEvent.type](event, context)
    }
    return results
  } catch (error) {
    console.log(error)
    throw error
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants