Optional "total" field in PaymentRequest API

The "total" field (together with the "details" field) of PaymentRequest API is optional so that developers can use other information (e.g., product Id) to make the requests when the total amount is unknown or redundant. As an example, when Digital Product Management (DPM) API is used with PaymentRequest API, developers only need to provide product Id to buy digital goods from digital stores.

Motivation

When Digital Product Management (DPM) API is used with PaymentRequest API, developers are allowed to specify product Id instead of the total amount in sending a PaymentRequest to buy digital goods from digital stores. In this use case of PaymentRequest API, the total amount becomes redundant (total can be calculated from product Id) or even unknown (app stores may not inform the merchants of the unit price). By making “total” optional, we can improve the developer ergonomics in these cases. Below demonstrates how developer ergonomics are improved. Without the proposed feature, developers would be forced to put a redundant (if unit prices is unknown) or a fake (if unit price is known) “total” object: new PaymentRequest([{supportedMethods: methodName, data: {productId: ‘abc’}], {total: {amount: “1”, currency: “USD”}}); With the proposed feature, developers could simply write: new PaymentRequest([{supportedMethods: methodName, data: {productId: ‘abc’}]);

Documentation

Status in Chromium

Blink>Payments


In development (tracking bug)

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

  • No signal
  • No signal
  • No signal
  • No signals

Owner

Search tags

Payment Request, Digital Product Management, SKU, optional total,

Last updated on 2020-10-07