Skip to content
This repository has been archived by the owner on Aug 27, 2021. It is now read-only.

Behavior when method-specific data is invalid #20

Closed
rsolomakhin opened this issue Nov 23, 2016 · 11 comments
Closed

Behavior when method-specific data is invalid #20

rsolomakhin opened this issue Nov 23, 2016 · 11 comments

Comments

@rsolomakhin
Copy link
Collaborator

rsolomakhin commented Nov 23, 2016

If someone writes this:

new PaymentRequest(
    [{supportedMethods: ["basic-card"], data: {supportedNetworks: 0}}],
    shoppingCart);

Should the constructor throw, because supportedNetworks must be a list according to this spec? The alternative is to pass this information to the payment app as-is and let it decide what to do with it. If we pass to the app, it would be great to clearly define the expected behavior for invalid method-specific data.

@zkoch
Copy link
Contributor

zkoch commented Dec 1, 2016

Seems like throwing is the right call to me. We should probably clearly define that behavior. @adrianba thoughts?

@rsolomakhin
Copy link
Collaborator Author

@marcoscaceres opinion would also be good to hear.

@marcoscaceres
Copy link
Member

Should the constructor throw, because supportedNetworks must be a list according to this spec?

Yeah, it will throw. The IDL binding layer will cause it to throw automagically with a TypeError.

@marcoscaceres
Copy link
Member

Wait, sorry, I misread the code (though the second supportedNetworks was a new entry).

@marcoscaceres
Copy link
Member

Got confused, because PaymentRequest() defines PaymentMethodData.data to be an object 😳

Looking at the right spec now: Yes, it will throw... but PaymentRequest() will obviously need to be updated to support this type.

@rsolomakhin
Copy link
Collaborator Author

I propose we update the basic-card spec like with this phrasing:

If supportedMethods contains "basic-card" and data is not in correct format, then user agent MAY throw TypeError.

For PaymentRequest spec:

If data format does not match the specification of its supportedMethods, then user agent MAY throw TypeError.

I'm using MAY instead of MUST because throwing works only for built-in payment methods, where user agent knows the format beforehand. Today that's "basic-card" and "https://android.com/pay" for Chrome, for example. However, when we have payment apps like "https://samsung.com/pay" or "https://alipay.com", then the user agent will not know the right format of data, so it cannot throw in constructor. It can, however, reject the show() promise in that case.

@zkoch
Copy link
Contributor

zkoch commented Dec 6, 2016

@adrianba thoughts?

@rsolomakhin
Copy link
Collaborator Author

Ping...

domenic added a commit to domenic/browser-payment-api that referenced this issue Dec 14, 2016
This is part of w3c/payment-method-basic-card#20. What remains is for the basic-card specification to define its validate payment method data algorithm.
domenic added a commit to domenic/webpayments-methods-card that referenced this issue Dec 14, 2016
@rsolomakhin
Copy link
Collaborator Author

@domenic: Did we come to a conclusion of whether invalid "basic-card" method data should throw in PaymentRequest constructor?

@domenic
Copy link
Collaborator

domenic commented Dec 22, 2016

I believe the conclusion was that it should not. The data needs to be serialized and sent to the payment app, which then is responsible for validating and processing it.

@rsolomakhin
Copy link
Collaborator Author

rsolomakhin commented Dec 22, 2016

Excellent, thank you.

domenic added a commit to domenic/webpayments-methods-card that referenced this issue Jan 10, 2017
This follows w3c/payment-request#382 so that instead of simply defining the dictionaries in this spec, we say how they are used, and how invalid incoming data is processed. (See w3c#20.)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants