Build with Square

Get Started with Square APIs, SDKs, and Plugins

Step 1: Create a Square account Permalink Get a link to this section

Square provides collections of APIs that work together to solve a variety of problems, including online payments (eCommerce), in-person payments (point of sale), product management, customer management, and business management.

To work with Square APIs, you must create a Square account or sign in to an existing account.

Important

Square API support for credit card and card on file processing is currently limited to the United States, Canada, Japan, Australia, and the United Kingdom.

Cash payments and non-payment API functionality (such as, employee management, timecards, and catalogs) are supported everywhere Square accounts are available.

Step 2: Create a new application Permalink Get a link to this section

To create a new application:

  1. Open the Developer Dashboard.

  2. Choose New Application or choose Create Your First Application if your account is new.

  3. Enter a name for your application.

  4. Agree to the Square Developer Terms of Service.

  5. Choose Create Application.

Note

You can test payment processing in the Sandbox right away. To process payments in production, you need to visit squareup.com/activate to activate payment processing on the target account or Square returns an error.

Step 3: Get to know the application settings pages Permalink Get a link to this section

Choose the application you created in step 2 to open the application settings pages. The application settings pages includes multiple pages with different values and settings you might need while developing your application:

  • Credentials. Manage application credentials for production and the Sandbox.

  • OAuth. Manage the OAuth workflow for your custom solution.

  • Webhooks. Configure and enable webhooks.

  • Reader SDK. Configure the Reader SDK for your custom mobile solution.

  • Point of Sale API. Configure the Point of Sale API for your custom mobile solution.

  • Apple Pay. Configure Apple Pay on the Web for eCommerce solutions using the Square payment form.

  • Locations. Display production and Sandbox location IDs for the Square account. Location IDs are listed in the application control panel for convenience.

Important

The Developer Dashboard is defaulted to Sandbox mode and provides application credentials for the Sandbox environment. When you are ready to deploy your application to the production environment, set Developer Dashboard to Production mode and replace the Sandbox credentials in your application configuration code with production credentials.

Step 4: Understand the different application credentials Permalink Get a link to this section

The application settings pages provide a variety of credentials for accessing Square services. You need to use different credentials depending on how your application is used.

To learn about different application credentials, see Application credential types.

Step 5: Try it out Permalink Get a link to this section

Use your Sandbox access token and location ID with the tool below to send a Payment request with a test nonce to process a credit card payment.

Get application Sandbox credentials Permalink Get a link to this section

  1. Open the Developer Dashboard and select an application. The Credentials page for the selected application is shown.

  2. Set the dashboard to Production mode for a production application ID or to Sandbox mode for a Sandbox application ID (used in testing).

  3. Copy the Sandbox Application ID and the Sandbox Access Token in the Credentials section of the page.

Command line Permalink Get a link to this section

If you are using a Mac, open a Terminal. If using Windows, open a PowerShell session.

  1. Update the Authorization header by replacing {{ACCESS_TOKEN}} with your Sandbox Personal Access Token.

  2. Update the default JSON block in the payload of the command:

    • Set idempotency_key to any unique string, for example TESTKEY123.

    • Set source_id to cnon:card-nonce-ok.

  3. Copy the command and paste it into the command line.

  4. Run the command.

Terminal Permalink Get a link to this section

curl -X POST \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
    "idempotency_key": "{{UNIQUE-KEY}}",
    "autocomplete": true,
    "amount_money": {
      "amount": 100,
      "currency": "USD"
    },
    "source_id": "cnon:card-nonce-ok"
    }
}' \
'https://connect.squareupsandbox.com/v2/payments'

PowerShell Permalink Get a link to this section

$authHeader = @{ Authorization = 'Bearer  {0}' -f "{{ACCESS_TOKEN}}" }
$body = '{
    "idempotency_key": "{{UNIQUE-KEY}}",
    "autocomplete": true,
    "amount_money": {
      "amount": 100,
      "currency": "USD"
    },
    "source_id": "cnon:card-nonce-ok"
    }
}'

Invoke-RestMethod -Uri https://connect.squareupsandbox.com/v2/payments |
   -Method Post |
   -ContentType "application/json" |
   -Headers $authHeader |
   -Body $body 

Step 6: Start building Permalink Get a link to this section

The Square developer platform provides a collection of APIs and a variety of development tools:

  • Square API Suite. Supports online payments, order creation for itemized transactions, product catalog management, customer management, and employee time keeping.

  • Square SDKs. Simplify development by encapsulating the Square API suites.

  • Webhooks. Supports push notifications for the Square Catalog, Inventory, and Labor APIs.

  • Payments SDKs. Square payments can be processed across multiple channels, including online, in-app, and in-person. The Square developer platform includes server-side APIs that support online payments and mobile SDKs that support mobile payments on seller or buyer mobile devices.

  • Open Source Plugins. Support development in multi-platform application development frameworks. Plugins are available for Reader SDK (Flutter and React Native) and In-App Payments SDK (Flutter and React Native).

The tools and environments include: