Javascript 苹果支付支付请求API iframe
有一个页面实现了付款请求api,它有一个Applepay按钮,一切正常。但一旦页面嵌入iframe,就会出现安全错误:试图从一个安全源与顶层框架不同的文档启动Apple Pay会话。 属性allowpaymentrequest='true' HtmlFrameElement接口的allowPaymentRequest属性返回一个布尔值,指示是否可以在跨源iframe上调用付款请求API 两个页面都是https example.com:Javascript 苹果支付支付请求API iframe,javascript,html,iframe,applepay,payment-request-api,Javascript,Html,Iframe,Applepay,Payment Request Api,有一个页面实现了付款请求api,它有一个Applepay按钮,一切正常。但一旦页面嵌入iframe,就会出现安全错误:试图从一个安全源与顶层框架不同的文档启动Apple Pay会话。 属性allowpaymentrequest='true' HtmlFrameElement接口的allowPaymentRequest属性返回一个布尔值,指示是否可以在跨源iframe上调用付款请求API 两个页面都是https example.com: const applePayMeth
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)
}
使用iframe.com编码
Allowpaymentrequest属性已被弃用,浏览器不再支持该属性