Proper code locations for processing successful payment?

I am using:

connect-api-examples/connect-examples/v2/php_payment/

to add credit card payments to my php website. I wanted to make sure I am using an acceptable method to move on after a successful payment.

In sq-payment-flow.js

after a successful payment I am removing the payment form, button and default success message with the following added around line 55:

document.getElementById(“card-container”).innerHTML=“Payment Successful!”;
document.getElementById(“card-button”).style.visibility = “hidden”;
document.getElementById(“payment-flow-message”).style.visibility = “hidden”;

In process-payment.php

I am adding php code to record the successful payment in my MySql tables after ‘if ($response->isSuccess()) {’

Is this the proper way to do this? I didn’t find anything in the documentation.

Thank you,
Jim
Columbus Ohio

Currently we don’t have any documentation on how to record the successful payment in MySQL tables since each integration may choose to handle a successful response differently depending on their business need. :slightly_smiling_face:

Thanks Bryan. I think you misunderstood my question though.

Once a payment is successful, I need to record the sale and move them off the payment input page. My question was where in the sample code it was best to do this.

After looking over the code, this is what I came up with:

In sq-payment-flow.js

after a successful payment I am removing the payment form, button and default success message with the following added around line 55:

document.getElementById(“card-container”).innerHTML=“Payment Successful!”;
document.getElementById(“card-button”).style.visibility = “hidden”;
document.getElementById(“payment-flow-message”).style.visibility = “hidden”;

In process-payment.php

I am adding php code to record the successful payment in my MySql tables after ‘if ($response->isSuccess()) {’

My question is, is this a proper place in the sample code to do this or is there a better place?

Thank you,
Jim
Columbus Ohio

Yeah, that works if that is how you would like to handle the successful payment and move the customer off the payment input. :slightly_smiling_face: