简体   繁体   English

我可以使用 safari 移动用户代理自动执行 Apple Pay

[英]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.

相关问题 在移动Safari上重定向后,Apple Pay界面会冻结页面 - Apple Pay interface freezes the page after redirect on mobile Safari 与 Safari 和 Apple Pay 模式交互 - Interacting with Safari and Apple Pay modal Regex-除safari外的所有移动浏览器的用户代理 - Regex - User Agent for all mobile browsers apart from safari 有什么方法可以使用 HTML 或 JavaScript 设置用户代理? - Is there any way that I can set a user agent by using HTML or JavaScript? 用户代理移动不起作用 - User agent mobile not working 如何在移动Safari中提交表单后重置缩放,同时保持用户可扩展性? - How can I reset the zoom after form submission in mobile Safari, while maintaining user scalability afterwards? 如何使用JavaScript在Mobile Safari(iphone)VS UIWebView(WebKit)上检测到用户? - can I detect a user on Mobile Safari (iphone) VS UIWebView (WebKit) with javascript? 我可以在 Mobile Safari 上使用 user-css 覆盖 CSS 吗? - Can I over-ride CSS with user-css on Mobile Safari? Apple Pay:在显示订单信息之前如何获得“ shippingAddress”? - Apple Pay: How can I get `shippingAddress` before show the order information? 从 Safari 浏览器调用 Apple Pay 时,Apple 付款表未显示在 iOS13 中 - Apple Payment sheet not displaying in iOS13 when Apple Pay is invoked from a Safari browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM