Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React JS, Having to double click to open Hpp payment function #36

Open
seamy20 opened this issue Oct 6, 2020 · 0 comments
Open

React JS, Having to double click to open Hpp payment function #36

seamy20 opened this issue Oct 6, 2020 · 0 comments

Comments

@seamy20
Copy link

seamy20 commented Oct 6, 2020

i have the address input fields which when entered does an axios post to my server and returns the customers details and with that post id i can use a get method for the request endpoint. The issue i have is i want the both to happen in the one click but i am having to click twice to bring up the hosted page. Below is my code, is there a simple fix to this?

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant