Stripe Checkout 无法在 iFrame 中运行。请重定向至顶层结账

问题描述 投票:0回答:2

我正在尝试在 iframe 中加载 checkout.stripe,但它不起作用,我收到以下消息:

Stripe Checkout 无法在 iFrame 中运行。请重定向至顶层结账。

我之前读过 Stripe 不允许这样做。

有人知道这是真的吗? 有官方文档吗?

我尝试使用标签对象,但它也不起作用。

html iframe stripe-payments
2个回答
1
投票

是的,目前您必须将客户重定向到结帐会话

url

但是,主要 Checkout 文档 上有一条注释,表明正在开展允许嵌入选项的工作,因此如果您对此感兴趣,应该联系 Stripe。


0
投票

当将 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
    });
© www.soinside.com 2019 - 2024. All rights reserved.