我正在尝试在 iframe 中加载 checkout.stripe,但它不起作用,我收到以下消息:
Stripe Checkout 无法在 iFrame 中运行。请重定向至顶层结账。
我之前读过 Stripe 不允许这样做。
有人知道这是真的吗? 有官方文档吗?
我尝试使用标签对象,但它也不起作用。
当将 Cypress 端到端测试与 Stripe Checkout 集成时抛出此错误时,我最终遇到了这个问题。在
cypress.config.ts
中,您可以启用 experimentalModifyObstructiveThirdPartyCode
,它将解决此错误。然后,您可以使用 cy.origin
与 Stripe Checkout 进行交互:
// UI button that redirects to Stripe Checkout
cy.get("#checkout").click()
// Origin wrapper for cross-origin e2e testing
cy.origin('https://checkout.stripe.com', () => {
// Continue your Cypress code here
});