Building starts at the Square Developer Dashboard, where you create an Application and get separate Sandbox and Production access tokens. The sandbox comes with its own fake test card numbers and a simulated location, so you can run real-looking transactions without touching live money or a live reader.
Square's SDKs wrap the underlying REST API for most common languages, and the building blocks underneath cover the core of a real integration: the Payments API to charge a card programmatically, the Orders API to build out a cart, the Catalog API to manage items, variations, and inventory counts, and the Terminal API specifically to send a charge request to a physical Square reader over the internet and get the result back, without your software needing to own the card-present payment screen itself.
Webhooks work the same way they do on most modern payment platforms: register an endpoint, and Square pushes event notifications to it, a payment updating, an order changing, an inventory count moving, instead of your system polling the API on a loop to catch changes.