Learn how to quickly set up and test the Square Ruby SDK.
Before you begin, you need a Square account and account credentials. You use the Square Sandbox for the Quickstart exercise.
Create a Square account and an application. For more information, see Create an Account and Application.
Get a Sandbox access token from the Developer Dashboard. For more information, see Make your First API Call.
Install the following:
Ruby - Square supports Ruby version 2.7 or later.
Square Ruby SDK - To install it, use the
Open a new terminal window.
Create a new directory for your project, and then go to that directory.
In your project directory, create a new file named quickstart.rb with the following content:
Save the quickstart.rb file.
This code does the following:
The Ruby code in this Quickstart reads your Square Sandbox access token from the
SQUARE_ACCESS_TOKEN environment variable. This helps avoid the use of hardcoded credentials in the code.
For the following commands, replace
yourSandboxAccessToken with your Square Sandbox access token:
Run the following command:
Verify the result. You should see at least one location (Square creates one location when you create a Square account).