#Cannot use Stripe natively with workers.

32 messages · Page 1 of 1 (latest)

quick wave
merry schooner
#

Specifically look at constructEventAsync and createSubtleCryptoProvider

quick wave
merry schooner
#

With the new version of stripe-node, you simply need to import from 'stripe'

#

just ensure you're up to date

quick wave
merry schooner
#

You don't necessarily need to export it, but you do need to pass it to the constructEventAsync method

merry schooner
#

Can you share your full code and any other errors during build?

#

Or your repo, if that's easier and it's public

quick wave
#

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.

merry schooner
quick wave
#

I tried that, but this happens.

merry schooner
#

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'

quick wave
#

right of course, idiot moment for me

#

where do I put my key then?

#

do brackets still work?

merry schooner
#

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 🙂

quick wave
#

ight awesome, thanks for the clarification!

#

all fixed 🙂

merry schooner
#

awesome!

quick wave