DEV Community

Discussion on: Accepting payments with Stripe, Nuxt. js and vercel

Collapse
 
mikeoxhuge profile image
Mike • Edited

Not working for me.
Says 'Stripe is undefined'
And if I do import Stripe from 'stripe' it fires an alert: TypeError: _this4.stripe.redirectToCheckout is not a function.
Then I cloned the repo, tried to run it and upon npm run dev I got an error:

 Vue packages version mismatch:                                                        
   │                                                                                           
   │   - vue@2.6.11                                                                            
   │   - vue-server-renderer@2.6.12                                                           
   │                                                                                           
   │   This may cause things to work incorrectly. Make sure to use the same version for both.  
   │                                                                                        
Enter fullscreen mode Exit fullscreen mode

Then I tried npm run generate so I could run npm run start, and I had the same error. I guess your tutorial is way outta date.

Collapse
 
fayaz profile image
Fayaz Ahmed

Hey there, looks like a race condition, your mounted function is running before the script in head is loaded or it hasn't been called.

Care to show the code?

Collapse
 
aiyasahmed profile image
Aiyash Ahmed

// eslint-disable-next-line no-undef
stripe.value = Stripe(
'pk_test_ZaFKDdkCzVR4hCmDsUKWodm200fZIzrcmf'
)

OR

check you nuxt.config.js file whether the script is inside the head.

I had the same problem. but I fixed it through my above solution.