Enable Secure Remote Commerce - iOS

This topic provides step-by-step instructions for integrating Secure Remote Commerce (SRC) with the In-App Payments SDK on an iOS device.

Link to section

Prerequisites and limitations

To enable SRC with the In-App Payments SDK on iOS, the following must be true:

  • You're a US-based Square seller. SRC for the In-App Payments SDK is only available for Square sellers based in the United States.
  • You've followed the instructions in Build on iOS. This topic doesn't cover the general setup of the In-App Payments SDK.
  • You've read and will adhere to Mastercard brand guidelines.
  • SRC isn't supported in the Square Sandbox.
Link to section

Step 1: Add an SRC button image to your project

Create the image for your Click to Pay button by following the guidance on the Mastercard Branding Requirements page. Choose Use in digital payments and then choose Signaling Mastercard Click to Pay enablement. The image you create should look like the following:

A graphic showing a Secure Remote Commerce button image for Mastercard.

The examples on this page assume that you've created a PNG file (src_logo_button) and added it as an image in Assets.xcassetes.

Important

If you don't obtain an SRC image and store it in your project, you should download the image URL at runtime, convert the image into a PNG, and cache it.

Link to section

Step 2: Show the SRC payment sheet and get a payment token

Taking an SRC payment from your payment view controller involves the following steps:

  1. Create an instance of SQIPSecureRemoteCommerce.

    let secureRemoteCommerce = SQIPSecureRemoteCommerce()
  2. Create a payment request, specifying the payment amount and a completion handler. Replace YourPaymentViewController with the view controller that the payment sheet shows on top of.

    secureRemoteCommerce.createPaymentRequest(YourPaymentViewController, secureRemoteCommerceParameters: SQIPSecureRemoteCommerceParameters(amount: 5.95), completionHandler: { cardDetails, error in // #3 here })
  3. Get the payment token from the completion handler by reading the cardDetails?.nonce property. Replace // #3 here with the following code:

    // If success, completion handler includes the card details, including a nonce. let nonce = cardDetails?.nonce // Otherwise cardDetails will be nil and an error is passed instead. let errorDescription = error?.localizedDescription