Build on iOS

Link to section


The Mobile Payments SDK offers developers a secure way to integrate the Square checkout flow into their mobile applications, and accept in-person payments with a Square Reader or Square Stand.

There are four steps required to take your first payment using the Mobile Payments SDK:

  1. Install and configure the Mobile Payments SDK in your XCode application
  2. Authorize the Mobile Payments SDK
  3. Pair a card reader
  4. Take a payment
Link to section

Requirements and limitations

  • You have a Square account enabled for payment processing. If you haven't enabled payment processing on your account (or you're not sure), visit

  • You have a Square Reader device to take payments.

  • You're using Xcode 15.1+.

  • You've set your Xcode iOS deployment target to iOS 15+.

  • You have a Square application ID. You can find your application ID on the Developer Dashboard.

  • Your version of the Mobile Payments SDK adheres to the Square update policy. To limit risk to developers and their users, Square enforces an update policy requiring developers keep their version of the Mobile Payments SDK current.

  • You're generally familiar with developing applications on iOS. If you're new to iOS development, you should visit the Apple Training Center before continuing.

Link to section

Privacy permissions

The Mobile Payments SDK requires that each user grant access to their device's current location while using your application. Bluetooth must be enabled to take payments with a contactless and chip reader and microphone access must be granted to take payments with a magstripe reader.

Include the following privacy key/value pairs in your application's Info.plist file:

Key Description
NSBluetoothAlwaysUsageDescriptionSquare uses Bluetooth to connect and communicate with Square readers and compatible accessories.
NSLocationWhenInUseUsageDescriptionSquare needs to know where transactions take place to reduce risk and minimize payment disputes.
NSMicrophoneUsageDescriptionSome Square readers use the microphone to communicate payment card data to your device.
Link to section

Device compatibility

The Mobile Payments SDK isn't compatible with custom devices from OEMs that violate Square's security rules or on devices that grant root access to the mobile device operating system code and kernel. These devices cannot connect to a contactless and chip reader.

The following additional considerations apply when trying to run the SDK on custom devices:

  • The Mobile Payments SDK isn't supported for rooted or jailbroken devices.
  • The Mobile Payments SDK cannot run on custom operating systems.
  • Square prohibits using any software that provides the ability to record or capture screen data or that results in elevated privileges.
  • Verify that your device is supported (see Devices Compatible with Square Reader for Contactless and Chip).
  • Supported OS versions should be the latest or as close to the latest as possible.
  • Review Square's support window for the OS version and confirm support for the compilation target version and the runtime version: The compilation target currently supports iOS versions 15 and later.
Link to section


Get started with the Mobile Payments SDK by configuring your iOS application and taking a test payment in the Square Sandbox.

Link to section

1. Install the SDK and dependencies

Link to section

Option A: Install with Swift Package Manager

Install the Mobile Payments SDK with Swift Package Manager by following these steps in your Xcode project:

  1. Click File > Add Package Dependencies.
  2. Enter the repository URL:
  3. Select the Exact Version dependency rule and specify the version as 2.0.0-beta1.
  4. Ensure the SquareMobilePaymentsSDK product is added to your target.
  5. Optionally, you can also add the MockReaderUI product to your target to simulate a physical reader when one is not present in a sandbox environment.
Link to section

Option B: Install with Cocoapods

Install the Mobile Payments SDK with Cocoapods by adding the following to your Podfile:

use_frameworks! pod "SquareMobilePaymentsSDK", "~> 2.0.0-beta1" # To use a simulated reader device to take sandbox payments, add the optional MockReaderUI: pod "MockReaderUI", "~> 2.0.0-beta1", configurations: ['Debug']
Link to section

2. Add a build phase to your target

  1. On the Build Phases tab for your application target, click the + button (at the top left of the pane).

  2. Choose New Run Script Phase. The new run script phase should be the last build phase. Otherwise, the build fails.

  3. Paste the following into the editor panel of the new run script:

Link to section

3. Initialize the Mobile Payments SDK

Before taking a payment or attempting any other operation with the Mobile Payments SDK, you must initialize it using the initialize() method and your Square application ID in your AppDelegates didFinishLaunchingWithOptions method.

To get your application ID, sign in to the Developer Dashboard and choose your application. If you don't have an application yet, see Get Started for steps to create a Square application.

Your application opens to the Credentials page. This page contains the Square application ID used to initialize the Mobile Payments SDK.


To test the Mobile Payments SDK in the Square Sandbox with mock readers and mock payments, switch the toggle at the top of the Developer Dashboard to Sandbox to show your Sandbox credentials and initialize the SDK with your Sandbox application ID. To start taking production payments, you must initialize the Mobile Payments SDK again with your production application ID.

Link to section

4. Authorize the Mobile Payments SDK

The AuthorizationManager handles authorization for the Mobile Payments SDK. Call the authorize() method with an OAuth access token and location ID. If you're testing your application in the Square Sandbox, you can use your personal access token and location ID from the Sandbox tab in your Developer Dashboard.


Don't deploy an application into production that contains your personal access token. For a secure authorization implementation in production, you should implement OAuth instead of using a personal access token.

When authorization completes, the AuthorizeCompletionHandler provides the result of the authorization, including any errors.

Link to section

5. Test with mock readers in the Square Sandbox

Physical card readers aren't supported in the Square Sandbox. To take test payments, you must simulate a virtual reader with the Mock Reader UI.

The Mock Reader UI consists of a floating action button (FAB) that can be dragged anywhere on the screen and persists as you navigate between screens in your application. Show the button by calling MockReaderUI.present().

Click this button to simulate connecting a magstripe reader or a contactless and chip reader to your device. You can use the ReaderManager to programmatically access information about these simulated readers, such as their model and available card entry methods.

When mock readers have been connected and you begin a payment, click the FAB again to test your application's payment flow and simulate a swiped, inserted, or tapped card with the mock reader. Click Payment details to select different card brands and payment behaviors (approved or declined) for testing purposes. To hide the mock reader UI in your application, call MockReaderUI.dismiss().

To pair physical readers for production payments, see Pair and Manage Card Readers.

Link to section

6. Set up a payment

The PaymentManager handles payments in the Mobile Payments SDK. Prior to starting a payment, you create a set of PaymentParameters to represent details of an individual payment, and a set of PromptParameters indicating how the payment prompts are presented to the buyer.

When setting up a payment, you must conform to the PaymentManagerDelegate to handle results and errors from a payment. If the payment completes successfully, a Payment object is returned, which can be accessed on the Sandbox Seller Dashboard or with the Payments API. If the payment fails, the response contains a PaymentError.

Use the availableCardInputMethodsObserver to notify your application if the available card entry methods have changed (for example, if a magstripe reader was inserted or removed from the mobile device).

Link to section

Payment parameters

Before beginning a payment, create a PaymentParameters object, which includes the payment amount, idempotency key, optional tip, application fee (if applicable), and the processing mode if you want to take payments while offline. For the complete list of payment parameter values and details, see the iOS technical reference.

Link to section

Prompt parameters

Each payment must also have a set of PromptParameters configured, consisting of a mode and a set of additionalMethods buyers can use for payment. At this time, keyed (a manually entered credit card payment) is the only additional payment method available.

Square provides a payment prompt screen that displays a UI to buyers prompting them to swipe, insert, or tap their card, depending on the payment options available. To use this screen, set the PromptParameters.mode to default.

A graphic showing the Square-provided payment prompt screen for the Mobile Payments SDK. The screen shows a 24 dollar payment and prompts the buyer to swipe, tap, or insert in card reader to pay.

Link to section

7. Take a payment

When you're ready to begin a payment, call PaymentManager.startPayment() with the PaymentParameters and PromptParameters you created for this payment.

During each payment, Square takes control of the screen display to ensure that buyer information is handled securely and that the final confirmation of the payment is correctly shown to the buyer. While a payment is in progress, the UIViewController passed to startPayment must remain presented or pushed until your PaymentManagerDelegate receives a callback indicating the payment has completed, failed, or was cancelled.

A graphic showing two payment screens in the Mobile Payments SDK, showing a 24 dollar payment going through "Processing" and "Approved" status

If the payment completes successfully, a Payment object is returned to your payment callback. This payment can be accessed on the Seller Dashboard or with the Payments API. If the payment fails, the response contains an error.

Link to section

Next steps

After installing the Mobile Payments SDK and testing your application with test payments in the Square Sandbox, learn more about configuring your application to take production payments: