command to install
=======================================================================
npm i react-stripe-checkout
https://www.npmjs.com/package/react-stripe-checkout
Import in Js file
=======================================================================
import StripeCheckout from "react-stripe-checkout";
In JS File
=======================================================================
const 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}`);
});
});
};
In render JS File
====================================================================
<StripeCheckout
token={onToken}
stripeKey="key"
/>
Comments
Post a Comment