I have a payment page which first does an axios call to get the required HPP model data. I then call the Hpp function to open the hosted page but it takes 2 clicks to complete the action. I have tried putting the code direct from the hpp function but the same thing happens. Any help is appreciated.
paymentFunction(){
const data = {
//my passed data
};
const response = axios ({
url: "Myserverapitogetmodeldata",
data: data,
method: "POST"
})
//open the hosted page
this.hppFunction(response.data.id);
}
hppFunction(i) {
$.getJSON("serverapimodeldata" + i, function (
jsonFromRequestEndpoint
) {
debugger;
window.RealexHpp.setHppUrl("realexpaymentsapi");
window.RealexHpp.lightbox.init(
"payButtonId",
"responseUrl",
jsonFromRequestEndpoint
);
});
}
<MDBBtn id="payButtonId" onClick={() =>this.paymentFunction()}>Pay Now</MDBBtn>
if i call the initial function with onClick={this.paymentFunction()}, this works but it is doing the post to the Db with the onchange and posting each time a character is entered