这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

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.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
id Chrome 61 Edge 16 Firefox 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 11.1 WebView Android 不支持 No Chrome Android 60 Firefox Android 55 注意事项 Disabled
55 注意事项 Disabled
Available only in nightly builds.
Disabled ). To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 11.3 Samsung Internet Android 8.0

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

元数据

  • 最后修改: