[英]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.我有一个使用 google play 和 apple pay 进行支付的电子商务应用程序。 And I develop automation suites using Puppeteer.
我使用 Puppeteer 开发自动化套件。 With google play, I faced no issue, but for the apple pay, you need to use Safari.
使用google play,我没有遇到任何问题,但是对于apple pay,您需要使用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");
我使用用户代理来表示用户来自 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?真的可以使用 Puppeteer 进行 Apple Pay 支付吗? 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.
最接近模拟真实 iOS 设备的方法不是使用 puppeteer,而是使用microsoft/playwright ,它是 puppeteer 的继任者(由当时在 Google 的 puppeteer 由同一团队制作),它支持WebKit 浏览器引擎。
If I visit https://applepaydemo.apple.com/ with an emulated iPhone 11 device it gives:如果我使用模拟的 iPhone 11 设备访问https://applepaydemo.apple.com/它会给出:
Your browser or device does not support Apple Pay on the web.
您的浏览器或设备不支持 web 上的 Apple Pay。 To try out this demo, open this page in Safari on a compatible device.
要试用此演示,请在兼容设备上的 Safari 中打开此页面。
You can test it here without local npm install: https://try.playwright.tech/你可以在这里测试它没有本地 npm 安装: 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.我目前不知道有任何解决方法可以让 Apple Pay 与非 iOS 设备一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.