Square Java API vs Take card Payment (HTML)

This might have already been answered and I just need a little clarity,

I presumed front end would sent something to notify backend to run the methods:
So backend would run something like this

But when I run a sandbox example of front end html / js

This seems to do al the processing and return a success with a dummy card.

I am just a little confused since it would seem the backend java implementation is not actually required ?
the backend api allows discounts / customer address etc to be created where as this front end takes card and gives back a success with some card details as well as a token. Does backend do anything further with those details so far as square API goes ?

:wave: The Take a Card Payment with Web Payments SDK walkthrough is designed to be an end to end example of processing a payment with the SDK. You can definitely use the front end components to tokenize the card. Once tokenized you can send it to your Java backend to perform other functions like saving the card on file with the Cards API or processing the payment with an order that was created with the Orders API to list a few. :slightly_smiling_face:

Hi Bryan

Thanks for your feedback, I have worked it out now, the front end gives a token which is sent to backend as sourceId which backend then creates paymentRequest and uses squareClient.paymentsApi to send the actual transaction at which point in logs on square that token appears to have relevant details provided by user on front end such as last 4 digits of card expiry date etc.

I have a rough idea now and this can be closed if there is such a thing


Glad the hear that you figured it out. Please feel free to reach out if you have any additional questions. We’re always happy to help. :slightly_smiling_face: