Hi, I am a developer using C#. I recently developed web payment project with Square. I hope this message helps you out little bit. I am just writing this message to share my experience, so no offense. I am guessing you are using C# and asp.net
Good starting point is code example link that you can find from developer page.
I am guessing you have followed installing Square’s web payment quick start kit. This is the first step but you don’t need copy and paste any files from this kit. Just take a look how this kit is handling payment flow. A file in the folder web-payments-quickstart\public\examples\card.html is the one that developer must take a look for card payment. This file contains javascript you can copy (not as is), paste, and customize to your site’s aspx file (asp.net page).
This page(card.html from quickstart) will call javascript fetch, for this, your asp.net project must have API Controller to handle this javacript’s fetch call. In this API Controller, you will call CreatePaymentAsync() or CreatePayment(). This controller will be using…
using Square;
using Square.Models; as minimal.
In this asp.net controller,
public async Task Post([FromBody]SquarePayment p) { …//your code } (or any different way you will handle Post with different return type) will call CreatePaymentAsync(). ‘SauarePayment’ is just a custom object I created to handle data using API Controller. → Please research how to handle API Controller in ASP.net. Your javascript fetch call must be able to pass data when calling API controller.
You will refer to Square’s API reference on calling CreatePaymentAsync() for your project’s need. In this method (Post call), you will create Square’s client instance. Square’s API Explorer does not show about client instance, but you need create instance of [Square client] to call any Square’s API.
This api controller must handle ‘cross origin’ for debugging in Visual Studio. → please research. Your web project in Visual Studio works on specific local host port [WHEN DEBUGGING], not the Square provided quick start port (3000). This is for debugging purpose only. You do not need implement ‘cross origin’ for production.
Now, the code behind page of your aspx.
Remember the aspx file has javascript? This javascript called ASP controller as above. Controller created Square client and processed CreatePaymentAsync() method. Now the calling javascript have received response from ASP controller. Using this response, you can call static WebMethod from code behind to handle your POS specific requirement. Of course, only if you need.
Another thing to check is OAuth. Your web application must be able to handle OAuth if you are building application for other merchants. I used Asp handler for this.
Every developer has different way to create or handle the situation. This message is not the only answer. I am sorry that I cannot expose the actual lines of code.