Apple Pay is a mobile payment and digital wallet service developed by Apple Inc. It allows you to make payments using your Apple devices, including iPhones and iPads. However, testing Apple Pay can be challenging, especially when it comes to testing it on different devices and environments. In this regard, Sauce Labs provides three ways to test Apple Pay, including using Simulators, using real private devices with an Apple Pay Sandbox Testing account, and using real private devices with a real production account and real credit cards.
What You'll Need
- A Sauce Labs account (Log in or sign up for a free trial license).
- A native iOS, or iPadOS mobile app.
- A private devices with Apple Pay enabled! To access our private device cloud, contact your Sauce Labs account executive or our support team.
Testing Apple Pay
Sauce Labs offers three ways to test Apple Pay :
- Using Simulators.
- Using real private devices with an Apple Pay Sandbox Testing account.
- Using real private devices with a real production account and real credit cards.
There are important differences between the Apple Pay Real Device and Simulator flow. The Simulator has the following limitations:
- It is focused on the front-end integration of Apple Pay and does not test the back-end integration.
- You can't add cards to the wallet, meaning:
- No Apple Pay Sandbox Testing cards.
- No real credit cards.
- You can't test the Apple Pay in-web flow.
- You can test the Apple Pay in-app flow, but the Apple Pay in-app flow will not work the same as with Real Devices. It won't return a payment token and will not properly process your payment. In addition to this, it automatically provides simulated cards for all the supported payment networks.
- You need to use Private devices with Apple Payment enabled.
- Instrumentation needs to be disabled.
- You need to add your Sauce Labs hosted Private device UDID to your own provisioning profile.
- Devices with Assistive touch enabled. In this case, you need to accept Apple Payment confirmation through assistive touch!
Apple certificates are used to ensure security in their systems, and they are much more strict about them than Android. This level of security makes certificates a very complex part of making Apple Pay work with devices in a cloud.
To give you an example, Android apps can be installed without any specific signing on whatever real device you want. With Apple you have two options, or you need to add a remote device to your developer certificate and the provisioning profile, so you are allowed to install the app on that specific device. Or you need to use an enterprise certificate where the Apple device that has that certificate installed allows you to install the app. Similarly, when you install an iOS app on a device, we re-sign the app with a Sauce Labs enterprise certificate so you can install your app on all Sauce Labs public/private devices.
Apple Pay has a limitation that it cannot work with an enterprise certificate. You need to use the developer certificate where the device has been added to the provisioning profile to make this work. This can only be done for Sauce Labs private devices on which you have disabled the instrumentation.
Apple Pay on Real Private Devices
Our real devices are cleaned after every test session. Therefore, you need to configure your Apple Pay Sandbox Testing account, including a passcode and sandbox cards, every time you want to test Apple Pay on an iOS real device.
To make Apple Pay work on Sauce Labs real private devices:
Follow Apple’s steps to enable Apple Pay (see Setting Up Apple Pay Requirements). Apple is strict about certificates, so they require you to follow very specific steps:
Set up Apple Pay integration in your app.
Register the Merchant ID in your Apple developer account.
Set up an Apple sandbox tester account (see Create a sandbox tester account for more information).
Build your app. Apple Pay doesn’t work with enterprise certificates, so it will not work with Sauce Labs out of the box. The first step is to add the Sauce Labs real private devices to your Apple developer certificate before building the app. You can do that in one of the following ways:
Manually adding the device and its UDID to the device list for your developer certificate.note
Your device list can be found on Apple’s Certificates, Identifiers & Profiles page for your developer account, and you can get the UDID of your private device by contacting your Sauce Labs CSM.
Using the Sauce Labs Virtual USB solution:
- Start a session with Virtual USB (see Testing with Virtual USB on Real Devices for more information).
- When the connection is established, open XCODE.
- Select the device from the device list.
On the Signing & Capabilities tab you will see that the device has not yet been added.
- Click Register Device to add the device to your developer certificate.
- Once the UDID of the device is added to the developer certificate, you can build the app (manually or automatically):
- Select your build scheme and then select Generic iOS Device.
- To build the app, click Product and then click Archive.
- Click Distribute App.
- Distribute the app with Ad Hoc and Automatically manage signing.
- Store the app on your local machine.
If the app has been built, you should not yet upload it to Sauce Labs. The device to be tested needs to be prepared. If you have already prepared the device, then you can skip to step 4.
Prepare the device. Set up the first Sauce Labs private device to use Apple Pay with the Apple sandbox account that was created in step 1.
One of the Apple Pay requirements is having a set passcode on your phone. Without it, you won't be able to add cards to your wallet. You need to use our Device Passcode capability. To initiate a session with automatic Passcode enabling, explore our passcode capability, where you have the option to utilize either a dummy app or our Sauce Demo application.
Add Apple Sandbox Test Cards
Apple test cards can be found on Apple’s Sandbox Testing page.
- On your device, go to Wallet. If you didn’t set the passcode capability, Apple will show a notification.
- In Wallet, tap the plus sign to add a new card. Use the card information on Apple’s Sandbox Testing page.
- Prepare Sauce Labs. As mentioned before, Sauce Labs uses an enterprise certificate to install an app on public and private devices. But Apple Pay can’t work with the enterprise certificate, so the app needs to be signed with the developer certificate. You need to instruct Sauce Labs to not re-sign the app when it is installed.
- On Sauce Labs, in the left navigation, click Live and then click Mobile-App.
You will see an overview of the already uploaded apps. If no app has been uploaded, then upload the app. Once uploaded, open the app settings by hovering over the row until you see this:
- Click Settings.
- Under Default settings, toggle Instrumentation to Disabled.
Disabling this allows the app to use Apple Pay and the developer certificate and provisioning profile that you used when you built the app.
Disabling re-signing will break the installation of the app on public devices. The app will only be allowed to be installed on private devices that have been added to the developer certificate and provisioning profile.
Once the app has been uploaded and re-signing has been disabled, you can start the device and let Sauce Labs install the app on the device.
Test the app. View the Sauce Labs Demo Payments app: