I have integrated stripe api in my website. I have created bundle.js using stripe, express and http-browserify. and encountered this error:
bundle.js:50930 Uncaught TypeError: require(...).createServer is not a function at Object.
at Object.require.stripe.../package.json
at s bundle.js:1:262 at /post.html:11:14(anonymous function)
@ bundle.js:50930require.stripe.../package.json
@ bundle.js:51112s
@ bundle.js:1(anonymous function) @ post.html:11
When I click on error it give error on :
Stripe.DEFAULT_TIMEOUT = require('http').createServer().timeout;
You used the server-side stripe package, of which the documentation states:
These are serverside bindings only
If you're looking to install stripe.js, our clientside tokenization library - this is not it. These are serverside node.js bindings only.
You can't use these in a browser.
The client-side library, stripe.js, isn't available from NPM so you need to add it to your client-side code the old-fashioned way, by using:
<script src='https://js.stripe.com/v2/'></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With