https://blog.cloudflare.com/announcing-stripe-support-in-workers/
I tried using the official Stripe package for Webhook verification but I got this error (as seen in the second screenshot)
32 messages · Page 1 of 1 (latest)
https://blog.cloudflare.com/announcing-stripe-support-in-workers/
I tried using the official Stripe package for Webhook verification but I got this error (as seen in the second screenshot)
To do webhook validation in Workers you need to use async validation: https://jross.me/verifying-stripe-webhook-signatures-cloudflare-workers/
Specifically look at constructEventAsync and createSubtleCryptoProvider
yes, but 'stripe/lib/stripe.js' doesn't import at all for me, which is the first screenshot
With the new version of stripe-node, you simply need to import from 'stripe'
just ensure you're up to date
Do I still need export const webCrypto = Stripe.createSubtleCryptoProvider();?
You don't necessarily need to export it, but you do need to pass it to the constructEventAsync method
I get this which is confusing
Can you share your full code and any other errors during build?
Or your repo, if that's easier and it's public
yeah just a moment
I can't give you the full code for legal reasons, but this is the relevant parts
oh I forgot the webCrypto object
I can't use the export part because this has to be under the stripe object
Endpoint secret is not in prod, so it's not sensitive
just a local thing.
I would recommend you import Stripe, at the top. Then instantiate inside a request context, similarly to how I have illustrated at https://jross.me/verifying-stripe-webhook-signatures-cloudflare-workers/
I tried that, but this happens.
Otherwise if you can get me a minimal reproduction of the error, I'd be happy to take a look. 🙂
You don't need /lib/stripe.js
Just import Stripe from 'stripe'
right of course, idiot moment for me
where do I put my key then?
do brackets still work?
Later, when you initiate it. Check my blog post for where I do const client = Stripe(env.STRIPE_KEY, {
In my example, I get a req, call my getStripe function to get a Stripe instance, then validate a webhook with constructEventAsync
I'm stepping away for about 30 minutes but will take a look when I get back if you're still having issues 🙂
awesome!
thanks for your help!