Skip to main content
🚀 Self Healing AI Agent now live in App Automate! Auto-fix flaky tests instantly with zero code changes. Enable now!
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

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.

To test Apple Pay on Private Devices, refer to our Private Devices Apple pay documentation.

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 16 18
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 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.
applePayPreferredNetworks Set this capability if you want to set preferred payment networks for Apple Pay to improve stability. For example, ["Visa", "Mastercard"].
This capability is optional.
nativeWebTap Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button.

BrowserStack uses sandboxed cards provided by Apple for Apple Pay testing. These cards may occasionally fail due to card network instability or limitations.
To improve test stability, you can use the applePayPreferredNetworks capability to specify your preferred payment networks. BrowserStack automatically selects the most stable cards from your preferred networks and adds them to the test session.
This capability is optional, and if not specified, BrowserStack will use a default set of networks.

Example

browserstack.yml
Copy icon Copy

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.
applePayPreferredNetworks Set this capability if you want to set preferred payment networks for Apple Pay to improve stability. For example, ["Visa", "Mastercard"].
This capability is optional.
nativeWebTap Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button.

BrowserStack uses sandboxed cards provided by Apple for Apple Pay testing. These cards may occasionally fail due to card network instability or limitations.
To improve test stability, you can use the applePayPreferredNetworks capability to specify your preferred payment networks. BrowserStack automatically selects the most stable cards from your preferred networks and adds them to the test session.
This capability is optional, and if not specified, BrowserStack will use a default set of networks.

Example:

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("resignApp", "false");
browserstackOptions.put("enableApplePay", true);
browserstackOptions.put("applePayPreferredNetworks", new String[] {"Visa", "Mastercard"});
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",
    "nativeWebTap": true,
    "bstack:options": {
        "resignApp": false,
        "enableApplePay": true,
        "applePayPreferredNetworks": ["Visa", "Mastercard"]
    }
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("resignApp", false);
browserstackOptions.Add("enableApplePay", true);
browserstackOptions.Add("applePayPreferredNetworks", new string[] { "Visa", "Mastercard" });
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",
    "nativeWebTap": True,
    "bstack:options": {
        "resignApp": False,
        "enableApplePay": True,
        "applePayPreferredNetworks": ["Visa", "Mastercard"]
    }
}
capabilities = {
  "platformName" => "ios",
  "platformVersion" => "15",
  "deviceName" => "iPhone 13 Pro",
  "nativeWebTap" => true,
  "bstack:options" => {
    "resignApp" => false,
    "enableApplePay" => false,
    "applePayPreferredNetworks" => ["Visa", "Mastercard"]
  }
}
Capability Description
browserstack.enableApplePay Set this capability to "true" if you want to test Apple Pay in your test session.
browserstack.applePayPreferredNetworks Set this capability if you want to set preferred payment networks for Apple Pay to improve stability. For example, ["Visa", "Mastercard"].
This capability is optional.
browserstack.nativeWebTap Set this capability to "true" to display the Apple Pay payment screen after clicking Apple Pay.

BrowserStack uses sandboxed cards provided by Apple for Apple Pay testing. These cards may occasionally fail due to card network instability or limitations.
To improve test stability, you can use the applePayPreferredNetworks capability to specify your preferred payment networks. BrowserStack automatically selects the most stable cards from your preferred networks and adds them to the test session.
This capability is optional, and if not specified, BrowserStack will use a default set of networks.

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.applePayPreferredNetworks", new String[] {"Visa", "Mastercard"});
capabilities.setCapability("browserstack.nativeWebTap", true);
var capabilities = {
    "os_version" : "15",
    "device" : "iPhone 13 Pro",
    "browserstack.resignApp" : false,
    "browserstack.enableApplePay" : true,
    "browserstack.applePayPreferredNetworks" : ["Visa", "Mastercard"],
    "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.applePayPreferredNetworks", new string[] { "Visa", "Mastercard" });
capabilities.AddAdditionalCapability("browserstack.nativeWebTap", true);
desired_cap = {
    "os_version" : "15",
    "device" : "iPhone 13 Pro",
    "browserstack.resignApp" : False,
    "browserstack.enableApplePay" : True,
    "browserstack.applePayPreferredNetworks" : ["Visa", "Mastercard"],
    "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.applePayPreferredNetworks"] = ["Visa", "Mastercard"]
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 used postalCode.
  • 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

Copy icon Copy

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





Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle