有一个页面与已实现的支付请求api,它有一个Applepay按钮和所有的工作。但是,一旦页面嵌入到iframe中,就会发生SecurityError错误:试图从与其顶层框架不同的安全来源的文档中启动Apple会话。
属性允许支付请求=“true”
allowPaymentRequest接口的HTMLIFrameElement属性返回一个布尔值,指示是否可以在跨源iframe上调用支付请求API。
这两个页面都是https。
example.com:
const applePayMethod = {
supportedMethods: "https://apple.com/apple-pay",
data: {
version: 3,
merchantIdentifier: "somemerchantid",
merchantCapabilities: ["supports3DS",],
supportedNetworks: ["masterCard", "visa"],
countryCode: "US",
},
};
const paymentDetails = {
total: {
label: "My Merchant",
amount: { value: "27.50", currency: "USD" },
},
}
try {
const request = new PaymentRequest([applePayMethod], paymentDetails, {});
const response = await request.show();
const status = processResponse(response);
response.complete(status);
} catch (e) {
console.log(e)
} code-with-iframe.com
<iframe allowpaymentrequest='true' src="https://example.com/" frameborder="0"></iframe>
发布于 2021-02-24 08:31:11
不再支持Allowpaymentrequest属性,浏览器不再支持
https://stackoverflow.com/questions/62169138
复制相似问题