问题描述
问题:
我在我的网站(https://www.example.com/order
上有ApplePay,它可以正常工作并获得全额付款。
现在,我尝试将子域(src="https://www.example.com/order"
)中的IFrame(https://sub.example.com
)与包含苹果工资并出现错误的表单进行集成
Trying to start an Apple Pay session from a document with an different security origin than its top-level frame
两个站点都使用Https。
主域(有和没有www
)和子域已在Apple开发人员帐户中验证。
解决方法
这个错误可以在 webkit source
中找到if (!ancestorDocument->securityOrigin().isSameSchemeHostPort(topOrigin))
return Exception { InvalidAccessError,"Trying to start an Apple Pay session from a document with an different security origin than its top-level frame." };
}
isSameSchemeHostPort
函数 checks iframe 和页面的协议、域和端口相同
return a.protocol == b.protocol
&& a.host == b.host
&& a.port == b.port
因此,框架和页面的协议、域和端口必须相同才能将 iframe 与 ApplePay 集成。
,您不能将Frames与Apple Pay一起使用,因为这被认为是不好的做法