-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make "total" and "details" optional #912
Comments
Why not move |
Underlying question here: would any other payment handler apart from Google Pay benefit from |
Note: This isn't just for Google Pay, this is to support any provider using our (as yet woefully under-)proposed Digital Product Management API, which could be any digital purchasing backend. I'm planning to post more details of that in the next few days. Given that, it may be a bit premature to change the Payment Request spec for a use case that doesn't yet have a firm design. @maxlgu would you be happy to sit on this until that solidifies? |
Noting support from Visa for this proposal via the WG's mailing list: |
@mgiuca , I would sit on this until DPM API solidifies. |
There's some confusion on a few threads about this that we would be relaxing the restriction across the board. @maxlgu I think you should update the proposal to be clearer that the individual payment processors can still mandate the total, but that this allows new payment processors to not require a total. Here's the text of my reply on the above thread:
|
@mgiuca , I've incorporated your words into the proposal. Thanks! |
Context: Total is a field in the "new PaymentRequest()" API. It specifies the amount and currency of the payment request. However, when the merchant requests for the app-store billing (e.g., Google Play Store billing - by specifying "https://play.google.com/billing" as the method), the total field becomes unnecessary. This is because app-stores takes the total from elsewhere. Before: The total field is mandatory for PaymentRequest. After: The total field is optional if only app-store methods are requested. When total field is optional and left out, Chrome would add a total of amount 0, currency "ZZZ" and label "AppStoreBillingTotalPlaceHolder". Change: * Added a RuntimeEnabledFeature: PaymentRequestTotalOptional * Added an about flag: payment-request-optional-total * change the optionality of the total field and details field of PaymentRequest API. Related Doc: * Chrome Status: https://www.chromestatus.com/feature/5226111782879232 * Intent to Prototype: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/TJVn0Ps9ugA/3unr2Vo8AgAJ * W3C explainer: w3c/payment-request#912 Bug: 1066531 Change-Id: Id5ad87b9fc452fd41a1ebef066d981737545a235 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2150974 Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Reviewed-by: David Bokan <bokan@chromium.org> Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org> Cr-Commit-Position: refs/heads/master@{#769914}
It seems unnecessary to use the PR API for Digital Goods Services in this way. This change would mean the Payment Request API is no longer for payments but rather for purchases. As I suggested in WICG/digital-goods#5, I recommend adding a If it's important to invoke the payment flow of the digital goods service via PR API then why not simply pass in the amount that was returned from |
Could you please clarify your understanding of differences between payments and purchases? I think I've been working on the wrong API this whole time :-D |
That would give an impression to the web developer that the amount can be modified and is being passed to the payment handler. That is not the case, however, as these types of payment handlers use the product ID to lookup the price in their source of truth database. |
Context: Total is a field in the "new PaymentRequest()" API. It specifies the amount and currency of the payment request. However, when the merchant requests for the app-store billing (e.g., Google Play Store billing - by specifying "https://play.google.com/billing" as the method), the total field becomes unnecessary. This is because app-stores takes the total from elsewhere. Before: The total field is mandatory for PaymentRequest. After: The total field is optional if only app-store methods are requested. When total field is optional and left out, Chrome would add a total of amount 0, currency "ZZZ" and label "AppStoreBillingTotalPlaceHolder". Change: * Added a RuntimeEnabledFeature: PaymentRequestTotalOptional * Added an about flag: payment-request-optional-total * change the optionality of the total field and details field of PaymentRequest API. Related Doc: * Chrome Status: https://www.chromestatus.com/feature/5226111782879232 * Intent to Prototype: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/TJVn0Ps9ugA/3unr2Vo8AgAJ * W3C explainer: w3c/payment-request#912 Bug: 1066531 Change-Id: Id5ad87b9fc452fd41a1ebef066d981737545a235 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2150974 Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Reviewed-by: David Bokan <bokan@chromium.org> Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#769914} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: f8f56a44e023414f59c86350cea68ae4cf8009aa
TL;DR
Given that when Digital Goods API is used with PaymentRequest API, the total amount is unnecessary, we propose to make the “total” field optional in PaymentRequest API spec, along with a few consequent changes.
Make “total” optional
The current PaymentRequest API requires the “total” field (of PaymentDetailsInit) to be mandatory, because any payment must come with a total amount. The mandatory “total” field was reasonable when we assume that developers could specify the “total” only with this field. But this assumption is invalid when the PaymentRequest API is used in conjunction with the proposed Digital Goods API, which connects with the digital store backend where the goods (with product ID) and their prices are specified. With the DPM API, merchants could simply provide the product ID in the PaymentRequest without knowing the total amount. Therefore, we propose to make the “total” field optional in the PaymentRequest API.
Make “details” optional
After “total” becomes optional, required by the WebIdl spec, the “details” field would have to become optional with a default value:
So we propose “details” should become optional and default to “{}”.
Improved developer ergonomics
These changes would improve the developer ergonomics, as developers would be able to write:
new PaymentRequest([{supportedMethods: methodName, data: {productId: ‘abc’}}]);
instead of:
new PaymentRequest([{supportedMethods: methodName, data: {productId: ‘abc’}], {total: {...}});
Asynchronously fail a request missing required “total”
In cases where “total” is required but missing, we propose that canMakePayment(), hasEnrolledInstrument() and show() should return a promise rejected with a "NotAllowedError" DOMException. Before the proposal, missing “total” would cause a TypeError “Missing required member(s): total” in PaymentRequest’s constructor synchronously. Note that after the proposal the failure would become asynchronous.
Why not fail a missing “total” in the constructor any more? Although it’s good for backwards compatibility, we move away from constructor because:
This change of failure may break the usages of PaymentRequest API that handle TypeError for a missing total. But we deem this breakage as trivial because it’s an error-handling for a programming error - the merchants should have always provided “total” instead of relying on the TypeError.
Summary
In summary, we propose these changes to the PaymentRequest API spec:
The text was updated successfully, but these errors were encountered: