Easily inject checkout.js as a react component. Will load the script on demand and supports all the options from stripe docs.
npm install react-stripe-checkout-nsen


.styl file and respective .css output. These have been removed and are now written directly in js.
token and stripeKey are the only required props,
StripeCheckout.js.
jsx
import React from 'react'
import StripeCheckout from 'react-stripe-checkout-nsen';
export default class TakeMoney extends React.Component {
onToken = (token) => {
fetch('/save-stripe-token', {
method: 'POST',
body: JSON.stringify(token),
}).then(response => {
response.json().then(data => {
alert(We are in business, ${data.email});
});
});
}
// ...
render() {
return (
// ...
token={this.onToken}
stripeKey="my_PUBLISHABLE_stripekey"
/>
)
}
}
`
This will give you a default Stripe-style button which looks like this:
!stripe checkout button
$3
`jsx
name="Three Comma Co." // the pop-in header title
description="Big Data Stuff" // the pop-in header subtitle
image="https://stripe.com/img/documentation/checkout/marketplace.png" // the pop-in header image (default none)
ComponentClass="div"
label="Buy the Thing" // text inside the Stripe button
panelLabel="Give Money" // prepended to the amount in the bottom pay button
amount={1000000} // cents
currency="USD"
stripeKey="..."
locale="zh"
email="info@vidhub.co"
// Note: Enabling either address option will give the user the ability to
// fill out both. Addresses are sent as a second parameter in the token callback.
shippingAddress
billingAddress={false}
// Note: enabling both zipCode checks and billing or shipping address will
// cause zipCheck to be pulled from billing address (set to shipping if none provided).
zipCode={false}
alipay // accept Alipay (default false)
bitcoin // accept Bitcoins (default false)
allowRememberMe // "Remember Me" option (default true)
token={this.onToken} // submit callback
opened={this.onOpened} // called when the checkout popin is opened (no IE6/7)
closed={this.onClosed} // called when the checkout popin is closed (no IE6/7)
// Note: reconfigureOnUpdate should be set to true IFF, for some reason
// you are using multiple stripe keys
reconfigureOnUpdate={false}
// Note: you can change the event to onTouchTap, onClick, onTouchStart
// useful if you're using React-Tap-Event-Plugin
triggerEvent="onTouchTap"
>
``