Open the Square Point of Sale application from your mobile Android application to process in-person payments using Square hardware.
Point of Sale API

Build on Android

Open the Square Point of Sale application from your mobile Android application to process in-person payments using Square hardware.

This topic makes the following assumptions:

  • You've read the introductory review of this API.

The example code in this topic assumes the following:

  • You're building an Android application - For information about building an iOS application, see Build on iOS. For information about building a Mobile Web application, see Build on Mobile Web.

  • You're using the Point of Sale SDK for Android version 2.0 and the Square Point of Sale application v4.64 and later - The Point of Sale SDK provides a helpful wrapper around the Point of Sale API, which simplifies the development process.

  • You're using version 15 as the minimum supported Android SDK version - If you're using an earlier version, you might need to update your SDK to use the sample code in this topic.

  • You're using Java - The Point of Sale SDK only supports Java on Android.

To use the steps in this topic, you need the following:

You should install the latest version of the Square Point of Sale application from the Google Play Store.

If you choose to use an older version of the Point of Sale application, you need to confirm that the version is compatible with the Android Point of Sale SDK version you're using.

Application versionAndroid SDK version
4.64 and laterv2.0
4.48 and laterv1.
4.41 and laterv1.0

There are two ways to determine the current version of the Square Point of Sale application:

  • Look it up in the device settings.

  • Run the following command using ADB:

The Square Point of Sale application for Android only accepts requests if it can authenticate the source of the request. Square uses the following information to authenticate application requests:

  • SHA-1 fingerprint - The Square Point of Sale application uses the SHA-1 fingerprint of an application to validate the source of incoming requests.

  • Package name (such as com.example.myapp) - A Java-language-style package name for your Android application. This needs to match the name you use in the package attribute in the Android manifest for your application.

To register your application:

  1. Obtain your Android application fingerprint.

  2. Open the Developer Dashboard.

  3. In the left pane, choose Point of Sale API.

  4. In the Android section, choose Add a new Android Package.

  5. Enter your package name and fingerprint.

  6. Choose Save.

To install the Point of Sale SDK manually, download the point-of-sale-android-sdk repo in GitHub.

If you develop with Gradle, add the following dependency that is appropriate for your plugin to your build.gradle file and rebuild your project.

If you develop with Maven, add the following dependency to your pom.xml file and rebuild your project:

If your project targets Android 11 or newer, you must add the following object to your manifest:

  1. Set your application ID. To find your application ID, open the Developer Dashboard, and choose an application.

  2. Add a constructor that configures an instance of PosClient.

  3. Add code that creates a new charge request and uses it to initiate a transaction in the Point of Sale application. The following function uses ChargeRequest.Builder to create a charge for $1 USD and then uses that request to create a ChargeRequest and initiate the transaction with an Intent object.

Set your application ID as shown:

Add a constructor as shown:

Create a new charge request as shown:


The AlertDialogHelper object that is used in the step 4 and step 5 code blocks is an example of a helper class instance and not part of the Point of Sale SDK.

When the Square Point of Sale application completes a transaction (or encounters an error), it returns the UI focus to your application and calls the onActivityResult() method of the activity that initiated the transaction. Add code to parse the response.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

  @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // Handle unexpected errors
    if (data == null || requestCode != CHARGE_REQUEST_CODE) {
            "Error: unknown",
            "Square Point of Sale was uninstalled or stopped working");

    // Handle expected results
    if (resultCode == Activity.RESULT_OK) {
      // Handle success
      ChargeRequest.Success success = posClient.parseChargeSuccess(data);
          "Client transaction ID: "
              + success.clientTransactionId);
    } else {
        // Handle expected errors
        ChargeRequest.Error error = posClient.parseChargeError(data);
            "Error" + error.code,
            "Client transaction ID: "
                + error.debugDescription);

For more information about the ChargeRequest class, see the Android Point of Sale API Technical Reference.

Did you know?

Your application should keep track of whether a Point of Sale API request has been issued and whether a callback has been received. Because of the constraints of application-switching APIs, sellers can leave Square Point of Sale during an API request and return to your application. It's your responsibility to direct them to return to Square and finish the transaction.

  1. Sign in to the Square Point of Sale application with the business location that you want to use to accept payments.

  2. Open your application and initiate a transaction.

  3. Test your callbacks:

    • Test the cancellation callback by canceling a transaction.

    • Test the success callback by completing a cash transaction.

The Sandbox doesn't support credit card testing for mobile. For alternatives, see Testing for supported countries.