PaymentRequest: id プロパティ

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

idPaymentRequest インターフェイスの読み取り専用プロパティで、特定の PaymentRequest インスタンスに固有の識別子を返します。

PaymentRequest のインスタンスを構築する際に、独自の id を指定することが可能です。指定されなかった場合、ブラウザーは自動的に id 値を UUID に設定します。

この例は、PaymentRequest インスタンスに独自の ID を付与する方法を示します。

js
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

The id is then also available in the PaymentResponse returned from the show() method, but under the requestId attribute.

js
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);

文字列です。

仕様書

Specification
Payment Request API
# dom-paymentrequest-id

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
id

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
User must explicitly enable this feature.