Test Apple Pay on iOS devices using BrowserStack App Automate
Test Apple Pay on remote BrowserStack iOS devices using App Automate.
- 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.
- Enabling this feature increases the session start time by 100-180 seconds. BrowserStack recommends using this feature only when needed.
Apple Pay enables one-click payments and purchases on iOS devices while providing additional security. Using BrowserStack App Automate, you can integrate Apple Pay into your mobile apps on selected remote iOS devices.
Supported apps
App Automate 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 test 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. |
enableApplePay: true
resignApp: false
appium: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
driver.executeScript('browserstack_executor: {"action": "applePayDetails", "arguments": { "billingDetails": { "firstName": "John", "lastName": "Doe", "state": "California", "city": "Mountain View", "street": "160 Amphitheatre","zip": "94043", "country": "United States"}, "shippingDetails": {"firstName": "John", "lastName": "Doe", "state": "California", "city": "Mountain View", "street": "160 Amphitheatre", "zip": "94043", "country": "United States" }, "contact": {"email": "random@gmail.com", "phone": "+1-212-456-7890"}}}')
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\"}}”)
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!