Using API as payment gateway from an already working form

Hi
API Newbie here so before delving into the API documentation I thought I’d ask if what I want to do is possible.

We have an on-line entry form which obtains quite a lot of information. Currently once the form is complete the user clicks on the submit button and the information is sent into a mysql database.

We would like to use our square account to collect payment for these entries and then after credit card details and payment has been submitted the information in the form is inserted into the mysql database. We wnt this to happen only once payment has been submitted.

Is API the right tool for this?
TIA

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Collecting Information
Collecting Information
Web Payments SDK Requirements

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Yes, the Square API is the right tool for this. You can use the Square Payments API to process the payment. Once the payment is successful, you can then insert the form data into your MySQL database. The Payments API allows you to create a payment using a nonce (a secure token generated by the Square payment form). Once the payment is successful, the API returns a payment object which includes details of the transaction. You can use this response to confirm the payment was successful before storing your form data in the database.

This answer was reviewed by @Bryan-Square.

Thank you. Just browsing through the information I wondering if it is possible to do a few extra things.

  1. I have one form with two membership options at different prices. Is there a way of adding checkboxes for these two options where the member can check which option they would like and that payment amount will appear?
  2. One of my forms calculates a final balance owing using javascript/php calculations. Can that final amount be automatically added to the gateway rather than the customer filling out the amount to pay?
  3. Can an extra field be added to the payment gateway asking for the caedholders name?

Thanks for your help.

Our Web Payments SDK is just a iframe form field. You can definitely add additional form fields for additional functionality. :slightly_smiling_face: