Integration and use

To integrate with Tap to Pay on iPhone, request a Tap to Pay Entitlement from Apple, and then set up your XCode project.

Request Tap to Pay Entitlement from Apple

  1. Sign into your Apple Developer Account.
  2. Select Certificates, IDs & Profiles.
  3. Select Tap to Pay on iPhone Entitlement, and then submit a request.
    If Apple approves the request it adds the entitlement to Managed Capabilities.

Set up your XCode project

  1. Enable Tap to Pay on iPhone.
  2. Generate a Provisioning Profile.
  3. Add the Provisioning Profile and Tap to Pay on iPhone capability.
  4. Add the Entitlements file.
  5. Install the Tap to Pay on iPhone SDK.

Enable Tap to Pay on iPhone

  1. Sign into your Apple Developer Account.
  2. Create an App ID.
  3. From Certificates, IDs & Profiles, select Identifiers.
  4. Select your app, and then select Additional Capabilities.
  5. For the Tap to Pay on iPhone capability, select the Enable checkbox.
  6. Select Save.

Generate a Provisioning Profile

  1. On the side menu, go to Profiles.
  2. Beside Profiles, select +.
  3. Select iOS App Development, and then select Continue.
  4. Select your app, and then select Continue.
  5. Select the certificates to include in the profile, and then select Continue.
  6. Select the devices you want to include in the profile, and then select Continue. If you haven't registered a device, see Testing your integration > Register your test device.
  7. In the Provisioning Profile Name field, name your profile, and then select Generate.
  8. To download the profile, select Download.

Add the Provisioning Profile and Tap to Pay on iPhone capability

  1. From the XCode Project Navigator, select your project.
  2. Select Signing and Capabilities.
  3. From the Provisioning Profile, select Download Profile.
  4. Select your Provisioning Profile.
  5. Select + Capability.
  6. In the search bar, enter Tap to Pay on iPhone, and then double-click the result to add it to your project.

Add the Entitlements file

  1. From the XCode Project Navigator, select your project.
  2. Select File > New > File > Resource.
  3. Enter a name for the Entitlements file in the format [ProjectName].entitlements.
  4. Select Build Settings.
  5. Locate Code Signing Entitlements, and then enter the path of your .entitlements file.
  6. Open your .entitlements file, and then add the following key-value pair:
<key>com.apple.developer.proximity-reader.payment.acceptance</key>
<true/>

Install the Tap to Pay on iPhone SDK

  1. In XCode, select File > Swift Packages > Add Package Dependency…
  2. Enter the following repository URL: https://github.com/CaperCo/ios-sdk.
  3. Select a versioning rule, for example, Up to Next Minor.
  4. After XCode installs the package, from Choose package products and targets, select the targets to add the SDK to.

Using the SDK

Set up a new device

When you use the SDK for the first time on a new device, you need to provision the device to assign it to a merchant and a store. Before you can provision the device, check that you have the following information for the merchant:
  • merchantCode
  • merchantPin

Provision the device

  • To provision the device, use the following function:
    BleuMerchantSDKClient.shared.provisionDevice(merchantCode: "yourMerchantCode", merchantPin: "yourMerchantPin")

Example code

BleuMerchantSDKClient.shared.provisionDevice(merchantCode: "yourMerchantCode", merchantPin: "yourMerchantPin") { result in
switch result {
case .success:
print("Device provisioned successfully.")
case .failure(let error):
print("Provisioning failed: \(error.localizedDescription)")
}
}

Accept the terms and conditions

The merchant must accept the terms and conditions before they can run Tap to Pay on iPhone transactions on the device. If the merchant declines the terms and conditions, repeat the request until the merchant accepts.
Note: The device displays an iOS module for Terms and Conditions, therefore, you don’t need to create a separate Terms and Conditions experience in your app.
  1. To check if the merchant has accepted the terms and conditions, use the following function:
    BleuMerchantSDKClient.shared.areTermsAndConditionsAccepted()
  2. To accept the terms and conditions, use the following function:
    BleuMerchantSDKClient.shared.acceptTerms()

Register the device to a store

  1. To retrieve a list of available stores use the following function:
    BleuMerchantSDKClient.shared.stores
  2. Locate the storeID you want to register the device to, and include it as the parameter in the following function:
    BleuMerchantSDKClient.shared.registerDevice(storeID: "selectedStoreID")

Initialize the SDK

Your app must initialize the SDK each time the merchant opens the app on their device. If you have provisioned the device, initializing the SDK automatically loads the credentials.
• To initialize the SDK, from the AppDelegate function inside application(:didFinishLaunchingWithOptions:), call:
BleuMerchantSDKClient.shared.initialize(environment: .production, loggingLevel: .verbose)

Take a payment

• To take a payment, use the following function:
BleuMerchantSDKClient.shared.pay(amount: Int, breakdown: PaymentBreakdown?, terminal: String, currency: CurrencyCode)

PaymentBreakdown object

The PaymentBreakdown object contains the following parameters:
ParameterData typeDescription
subtotalIntAmount of the transaction before taxes and fees. The value is in cents.
taxRateIntPercentage rate of the tax for the transaction.
taxAmountIntAmount of tax added to the transaction. The value is in cents.
tipAmountIntAmount of tip added to the transaction. The value is in cents.
tipTypeTipTypeIndicates if the tip is a fixed amount or a percentage of the transaction. The value is one of the following:
- fixed
- percentage

Additional methods

• Check card reader status
BleuMerchantSDKClient.shared.status
• Subscribe to reader events
BleuMerchantSDKClient.shared.readerReadinessEvents
• Check Tap to Pay availability
BleuMerchantSDKClient.shared.isTapToPayAvailable()
• Get device ID
BleuMerchantSDKClient.shared.deviceID
• Fetch past transactions
BleuMerchantSDKClient.shared.getTransactionHistory()
• Retrieve transaction details
BleuMerchantSDKClient.shared.getTransactionDetail(transactionID: "transactionID")
• Retrieve active session token
BleuMerchantSDKClient.shared.token
Note: The session token uses the terminal profile config and the merchant ID to create a card reader session to read card data. Each session token expires after two hours.