You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已验证双域名下iFrame内Apple Pay无法显示问题求助

Apple Pay嵌入iFrame后消失的原因及解决办法

以下是可能导致该问题的核心原因及对应的解决措施:

  • Apple Pay的跨域iFrame权限限制
    Apple Pay默认不允许在跨域iFrame中启用支付功能。需要两步配置:

    1. 在sample.com的页面响应头中添加Permissions-Policy,明确授权second-website.com调用支付API:
      Permissions-Policy: payment=(self "https://second-website.com")
      
    2. 在second-website.com的iFrame标签中添加allow="payment"属性,授予嵌入页面支付权限:
      <iframe src="https://sample.com/payment-page" allow="payment"></iframe>
      
  • Stripe Elements默认禁用iFrame环境下的支付请求
    Stripe的Payment Request Button(包含Apple Pay入口)默认在iFrame中是关闭状态,必须初始化Elements时显式开启allowPaymentRequest参数:

    const elements = stripe.elements({
      clientSecret: 'YOUR_CLIENT_SECRET',
      allowPaymentRequest: true // 强制开启iFrame下的支付请求支持
    });
    
  • Cookie SameSite策略阻碍会话识别
    若sample.com的Stripe相关Cookie设置了SameSite=Strict,跨域iFrame环境下浏览器会拒绝发送该Cookie,导致Stripe无法正常验证会话。需将Cookie的SameSite属性修改为Lax,或设置为None(同时必须启用Secure属性,确保仅在HTTPS环境下传输)。

  • Apple Pay商家ID的域名关联不全
    尽管两个域名均通过基础验证,但需确认Apple Pay商家ID是否同时关联了second-website.com。登录Apple Developer后台,检查对应商家ID的关联域名列表,确保包含second-website.com及其子域名(如有)。

内容的提问来源于stack exchange,提问作者Azianmike

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 04:40:35