Skip to content
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

Specify how to construct PaymentRequestDetailsUpdate from PaymentDetailsUpdate #376

Open
danyao opened this issue Jul 17, 2020 · 1 comment

Comments

@danyao
Copy link
Contributor

danyao commented Jul 17, 2020

The "paymentmethodchange" event allow a payment handler to communicate with the merchant before the payment request completes. It involves the following interfaces:

  1. Payment handler side:
partial interface PaymentRequestEvent {
  Promise<PaymentRequestDetailsUpdate?> changePaymentMethod(DOMString methodName, optional object? methodDetails = null);
}
  1. Merchant side:
partial interface PaymentRequestUpdateEvent : Event {
  void updateWith(Promise<PaymentDetailsUpdate> detailsPromise);
};

The Payment Handler API spec is unspecific about how to turn the PaymentDetailsUpdate object the merchant provides to the PaymentRequestDetailsUpdate object the payment handler receives. Section 7.2 Change Payment Method Algorithm [1] simply says:

5. Construct and return a PaymentRequestDetailsUpdate from the detailsPromise in event.updateWith(detailsPromise).

Proposal:
I think we should either merge the two object definition, or specify clearly how to convert one object from another. We should also do the same for the "shippingaddresschange" and "shippingoptionchange" events.

[1] https://w3c.github.io/payment-handler/#dfn-change-payment-method-algorithm

@sahel-sh
Copy link
Contributor

The reason that both "PaymentDetailsUpdate" and "PaymentRequestDetailsUpdate" dictionaries exist is that the two dictionaries have different fields; The former inherits displayItems[1] from "PaymentDetailsBase" dictionary while displayItems is redacted in the latter (i.e. Payment handlers do not recieve displayItems).

Another difference between the two dictionaries is the type of "total" field: "PaymentItem" vs "PaymentCurrencyAmount". Again Payment Handlers get the redacted version of the total.

The third and last difference between the two is that "payerError"[2] is redacted from "PaymentRequestDetailsUpdate" since the "payerdetailchange"[3] is not implemented for Payment Handlers.

[1] https://www.w3.org/TR/payment-request/#dom-paymentdetailsbase-displayitems
[2] https://www.w3.org/TR/payment-request/#dom-paymentdetailsupdate-payererrors
[3] https://www.w3.org/TR/payment-request/#summary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants