react-stripe-checkout
react-stripe-checkout copied to clipboard
How to open stripe-checkout programatically
Hi, is there a way to programatically open the react-stripe-checkout dialog?
In My use case I have a subscription form for the user to enter his/her address and then register them through aws cognito so that later I can authenticate securely.
I perform error checking and data validation in the front end first then. When the user clicks the subscribe button I verify that cognito has successfully registered the user. Once the registration is successful I want to be able to open the stripe checkout dialog automatically so that the user has a smooth experience. If its not successful I do not want to open the dialogue.
If anyone could help I would be very grateful
Thank You.
Yes, that should be possible. I'm not exactly an expert with this library, but here is what I did.
In my constructor I have
this.handler = StripeCheckout.configure({
key: ...,
name: ...,
token: token => {
...
}
});
Then I have a function I can call when I want to open the dialog:
stripeCreditCardDialog = () => {
this.handler.open({
amount: ...,
});
}