Test Apple Pay on iOS devices
- This feature is currently a Private Beta service and available only under Device Cloud Pro, Device Cloud Pro + Visual Cloud, and Enterprise Pro plans. Contact our Support team or Sales team to enable this feature. For more details, check out our pricing page.
- Setting this feature will lead to an increase in session start-time by 100-180 seconds. Thus, users are expected to use this feature based on their needs.
The Apple Pay feature in iOS devices enables purchases, one-click payments, and provides additional security for financial transactions.
BrowserStack App Automate enables you to test Apple Pay as a payment method in your mobile apps on select remote iOS devices.
In this guide you will learn about:
- Supported App Types
- Supported OS Versions and Devices
- Enabling Apple Pay using capability
- Confirming Apple Pay payment using Javascript executor
Supported App types
App Automate only supports testing of Apple Pay with mobile apps that are signed using Apple’s Developer Enterprise Program. Also, ensure that your app has Apple Pay entitlement added as a dependency.
Supported Devices and OS Versions
Supported Devices | iOS Version |
---|---|
iPhone 15 | 17 |
iPhone 14 | 16 |
iPhone 14 Pro | 16 |
iPhone 13 Pro Max | 15 |
iPhone 13 Pro | 15 |
iPhone 13 Mini | 15 |
iPhone 13 | 15 |
iPhone 11 Pro | 15 |
iPhone 11 | 15 |
iPhone XR | 15 |
Enable Apple Pay using a capability
Use the capability values enableApplePay
for W3C protocol and browserstack.enableApplePay
for JSON wire protocol in your test scripts.
Upon passing this capability, the following actions are completed on the device before starting your Appium session:
- A passcode is set on the device.
- A sample card for testing payments is added to the Wallet app.
- Assistive Touch is enabled.
- Apple Pay is added to the Assistive Touch menu.
If you are using BrowserStack SDK, you can set the following capability within the browserstack.yml
file:
Capability | Description |
---|---|
enableApplePay |
Set this capability to "true" if you want to test Apple Pay in your test session. |
nativeWebTap |
Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button. |
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
Capability | Description |
---|---|
enableApplePay |
Set this capability to "true" if you want to test Apple Pay in your test session. |
nativeWebTap |
Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button. |
Example:
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("resignApp", "false");
browserstackOptions.put("enableApplePay", "true");
capabilities.setCapability("bstack:options", browserstackOptions);
capabilities.setCapability("platformName", "ios");
capabilities.setCapability("platformVersion", "15");
capabilities.setCapability("deviceName", "iPhone 13 Pro");
capabilities.setCapability("appium:nativeWebTap", "true");
var capabilities = {
"platformName" : "ios",
"appium:platformVersion" : "15",
"appium:deviceName" : "iPhone 13 Pro",
'bstack:options' : {
"resignApp" : "false",
"enableApplePay" : "true",
"nativeWebTap": "true"
}
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("resignApp", "false");
browserstackOptions.Add("enableApplePay", "true");
capabilities.AddAdditionalCapability("bstack:options", browserstackOptions);
capabilities.AddAdditionalCapability("platformName", "ios");
capabilities.AddAdditionalCapability("platformVersion", "15");
capabilities.AddAdditionalCapability("appium:deviceName", "iPhone 13 Pro");
capabilities.AddAdditionalCapability("appium:nativeWebTap", "true");
desired_cap = {
"platformName" : "ios",
"platformVersion" : "15",
"deviceName" : "iPhone 13 Pro",
'bstack:options' : {
"resignApp" : "false",
"enableApplePay" : "true",
"nativeWebTap": "true"
},
}
capabilities = {
"platformName" => "ios",
"platformVersion" => "15",
"deviceName" => "iPhone 13 Pro",
'bstack:options' => {
"resignApp" => "false",
"enableApplePay" => "false",
"nativeWebTap" => "true"
},
}
Capability | Description |
---|---|
browserstack.enableApplePay |
Set this capability to "true" if you want to test Apple Pay in your test session. |
browserstack.nativeWebTap |
Set this capability to "true" to display the Apple Pay payment screen after clicking Apple Pay. |
Example:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("os_version", "15");
capabilities.setCapability("device", "iPhone 13 Pro");
capabilities.setCapability("browserstack.resignApp", "false");
capabilities.setCapability("browserstack.enableApplePay","true");
capabilities.setCapability("browserstack.nativeWebTap", "true");
var capabilities = {
"os_version" : "15",
"device" : "iPhone 13 Pro",
"browserstack.resignApp" : "false",
"browserstack.enableApplePay" : "true",
"browserstack.nativeWebTap", "true"
}
AppiumOptions capabilities = new AppiumOptions();
capabilities.AddAdditionalCapability("os_version", "15");
capabilities.AddAdditionalCapability("device", "iPhone 13 Pro");
capabilities.AddAdditionalCapability("browserstack.resignApp", "false");
capabilities.AddAdditionalCapability("browserstack.enableApplePay", "true");
capabilities.AddAdditionalCapability("browserstack.nativeWebTap", "true");
desired_cap = {
"os_version" : "15",
"device" : "iPhone 13 Pro",
"browserstack.resignApp" : "false",
"browserstack.enableApplePay" : "true",
"browserstack.nativeWebTap", "true"
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["os_version"] = "15"
caps["device"] = "iPhone 13 Pro"
caps["browserstack.resignApp"] = "false"
caps["browserstack.enableApplePay"] = "true"
caps["browserstack.nativeWebTap"] = "true"
You need to set the browserstack.resignApp
capability to false
when testing Apple Pay to disable re-signing of Enterprise signed app uploaded on BrowserStack. Checkout Disable re-signing iOS apps documentation for more information.
Test Apple Pay payment using Javascript executor
Trigger the payment workflow that uses Apple Pay as the payment method using your framework-specific commands.
If you want to add Apple Pay details such as shipping, billing, or contact information, use the following JavaScript executor with the applePayDetails
action.
For the Apple Pay details, ensure the details meet the following conditions:
- In your shipping and billing addresses, only include parameters that apply to the addresses and remove the parameters that are not applicable. For example, if your test address doesn’t have a value for the
province
parameter, remove the parameter from the script. - For the geographical codes in your shipping and billing addresses, use only one of these parameters based on what your address requires and the device accepts:
postalCode
,postCode
,zip
. In the following code snippet, we have usedpostalCode
. - The phone number must have the country code prefix with the
+
character. For example, use this+1-212-456-7890
or+12124567890
.
Your session may fail if your test addresses don’t have the fields that the device requires. For example, if your test addresses have the zip
parameter, but the device requires a different geographical code parameter, the session will fail. In this case, you can re-run the script with either postalCode
or postCode
and see which geographical code parameter the device accepts.
driver.executeScript("browserstack_executor: {\"action\":\"applePayDetails\",
\"arguments\": {
\"shippingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"billingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"contact\" : {
\"email\" : \"user input\",
\"phone\" : \"user input\"
}
}
}”);
await driver.execute("browserstack_executor: {\"action\":\"applePayDetails\",
\"arguments\": {
\"shippingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"billingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"contact\" : {
\"email\" : \"user input\",
\"phone\" : \"user input\"
}
} }”)
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\":\"applePayDetails\",
\"arguments\": {
\"shippingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"billingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"contact\" : {
\"email\" : \"user input\",
\"phone\" : \"user input\"
}
}
}”);
driver.execute_script("browserstack_executor: {\"action\":\"applePayDetails\",
\"arguments\": {
\"shippingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"billingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"contact\" : {
\"email\" : \"user input\",
\"phone\" : \"user input\"
}
} }”)
driver.execute_script("browserstack_executor: {\"action\":\"applePayDetails\",
\"arguments\": {
\"shippingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"billingDetails\" : {
\"firstName\" : \"user input\",
\"lastName\" : \"user input\",
\"street\" : \"user input\",
\"addressLine2\" : \"user input\",
\"city\" : \"user input\",
\"state\" : \"user input\",
\"zip\" : \"user input\",
\"province\" : \"user input\",
\"islandName\" : \"user input\",
\"country\" : \"user input\"
},
\"contact\" : {
\"email\" : \"user input\",
\"phone\" : \"user input\"
}
}}”)
Example for adding shipping, billing, and contact details in the Java language
Confirm the payment transaction using the following Javascript executor in your tests. The executor command automates the click on Apple Pay
option inside the Assistive Touch menu.
driver.execute_script("browserstack_executor: {\"action\":\"applePay\",
\"arguments\": {
\"confirmPayment\" : \"true\"
}
}”);
await driver.execute("browserstack_executor: {\"action\":\"applePay\", \"arguments\": { \"confirmPayment\" : \"true\"} }”)
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\":\"applePay\",
\"arguments\": {
\"confirmPayment\" : \"true\"
}
}”);
driver.execute_script("browserstack_executor: {\"action\":\"applePay\", \"arguments\": { \"confirmPayment\" : \"true\"} }”)
driver.execute_script("browserstack_executor: {\"action\:"\"applePay\", \"arguments\": { \"confirmPayment\" : \"true\"}}”)
Related topics
Check this page for a list of various JavaScript Executors that BrowserStack offers.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!