这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
id
read-only attribute of the
PaymentRequest
interface returns a unique identifier for a particular
PaymentRequest
实例。
When constructing an instance of the
PaymentRequest
, you are able to supply an custom id via
PaymentDetailsInit
dictionary's
id
member. If none is provided, the browser automatically sets the id value to a UUID.
This example shows how to give a
PaymentRequest
instance a custom id.
const details = {
id: "super-store-order-123-12312",
total: {
label: "Total due",
amount: { currency: "USD", value: "65.00" },
},
};
const request = new PaymentRequest(methodData, details);
console.log(request.id); // super-store-order-123-12312
id
is then also available in the
PaymentResponse
returned from the
show()
method, but under the
requestId
属性。
const response = await request.show(); console.log(response.requestId === request.id); // And in serialized form too const json = response.toJSON(); console.log(json.requestId,response.requestId, request.id);
var id = paymentRequest.id
A
DOMString
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
支付请求 API
The definition of 'id' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
id
|
Chrome 61 | Edge 16 |
Firefox
55
注意事项
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari 11.1 | WebView Android 不支持 No | Chrome Android 60 |
Firefox Android
55
注意事项
Disabled
|
Opera Android 不支持 No | Safari iOS 11.3 | Samsung Internet Android 8.0 |
完整支持
不支持
见实现注意事项。
用户必须明确启用此特征。
PaymentRequest