PaymentRequest: id-Eigenschaft

Limited availability

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

Sicherer Kontext: Diese Funktion ist nur in sicheren Kontexten (HTTPS) in einigen oder allen unterstützenden Browsern verfügbar.

Das schreibgeschützte Attribut id des PaymentRequest-Interfaces gibt eine eindeutige Kennung für eine bestimmte PaymentRequest-Instanz zurück.

Beim Erstellen einer Instanz von PaymentRequest können Sie eine benutzerdefinierte Kennung angeben. Wenn keine angegeben wird, setzt der Browser automatisch den Wert der Kennung auf eine UUID.

Beispiel

Dieses Beispiel zeigt, wie einer PaymentRequest-Instanz eine benutzerdefinierte Kennung gegeben wird.

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

Die id ist dann auch in der PaymentResponse verfügbar, die von der show()-Methode zurückgegeben wird, jedoch unter dem Attribut requestId.

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

Wert

Ein String.

Spezifikationen

Specification
Payment Request API
# dom-paymentrequest-id

Browser-Kompatibilität

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.