Can I automate apple pay using the safari mobile user agent
I have an e-commerce application that uses google play and apple pay for payments. And I develop automation suites using Puppeteer. With google play, I faced no issue, but for the apple pay, you need to use Safari. I use the user agent to say the application that users come form iOS safari: await page.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/83.0.4103.88 Mobile/15E148 Safari/604.1");
But that does not help. I not see the apple pay button.
It is really possible to do Apple Pay payments using Puppeteer? Because I can not find any question about it.
I would suppose it is not possible at the moment. The closest you can get to simulate a real iOS device is not with puppeteer, but with microsoft/playwright which is a successor of puppeteer (made by the same team as puppeteer back then at Google) and it supports WebKit browser engine.
If I visit https://applepaydemo.apple.com/ with an emulated iPhone 11 device it gives:
Your browser or device does not support Apple Pay on the web. To try out this demo, open this page in Safari on a compatible device.
You can test it here without local npm install: https://try.playwright.tech/
const playwright = require('playwright') async function fn() { const { webkit, devices } = playwright const iPhone11 = devices['iPhone 11 Pro'] const browser = await webkit.launch() const context = await browser.newContext({ viewport: iPhone11.viewport, userAgent: iPhone11.userAgent, ignoreHTTPSErrors: true }) const page = await context.newPage() await page.goto('https://applepaydemo.apple.com/') await page.screenshot({ path: 'example-iphone.png' }) await browser.close() } fn()
I am not aware of any workarounds at the moment to make Apple Pay work with non-iOS devices.