[英]Apple Pay Payment Request API iframe
有一個頁面實現了支付請求 api,它有一個 Applepay 按鈕,一切正常。 但是一旦頁面嵌入到 iframe 中,就會發生 SecurityError 錯誤:嘗試從安全來源與其頂級框架不同的文檔啟動 Apple Pay session。
屬性 allowpaymentrequest = 'true'
HTMLIFrameElement 接口的 allowPaymentRequest 屬性返回一個 Boolean 指示是否可以在跨域 iframe 上調用付款請求 API。
這兩頁都是 https。
示例.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)
}
代碼與 iframe.com
<iframe allowpaymentrequest='true' src="https://example.com/" frameborder="0"></iframe>
Allowpaymentrequest 屬性已棄用,瀏覽器不再支持
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.