I would like to create a Payment form using Stripe as payment provider.
In Stripe.js Reference the procedure to create the form component is described using jQuery including the external script in the page. How is it possible to include it in my React component? What is the best way? By far i have the following:
import React, { Component } from 'react';
class PaymentForm extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
Stripe.setPublishableKey('THE-PUBLIC-KEY');
}
handleSubmit(e) {
e.preventDefault();
Stripe.card.createToken(e.currentTarget, (status, response) => {
console.log( status, response );
});
}
render() {
//THE PAYMENT FORM
}
}
Note1: I would not like to use ReactScriptLoader as it is not actively updated.
Note2: Also saw dangerouslySetInnerHTML solution which i don't think it is good practice.