w3c / payment-request

Payment Request API
https://www.w3.org/TR/payment-request/
Other
486 stars 133 forks source link

fix: convert PaymentMethodData.data #812

Closed marcoscaceres closed 5 years ago

marcoscaceres commented 5 years ago

Closes #813

Part 1 of #753

Converts PaymentMethodData.data to IDL type or object.

The following tasks have been completed:

Implementation commitment:

Optional, Impact on Payment Handler spec?


Preview | Diff

marcoscaceres commented 5 years ago

Both Chrome and Firefox do the IDL conversion already.

marcoscaceres commented 5 years ago

@domenic hopefully good now.

marcoscaceres commented 5 years ago

@domenic, because in implementations, PaymentMethod.data's JS-to-IDL conversion happens in the PaymentRequest constructor (instead of on .show()), it means we don't need the [[serialized*]] data internal slots because:

This also fixes what would otherwise be a mess when show()ing or updateWith()ing a payment sheet: the [[serializedModifierData]] array positions would need to match the position of the deleted .data members.

So, with this PR, when a payment handler shows or gets updated, it always operates on its expected IDL type, without needing to redo any redundant JSON parsing, re-conversions, etc.

marcoscaceres commented 5 years ago

Went back to look at https://github.com/w3c/payment-request/issues/346 ... I'd forgotten that the ideas was to support actually sending the JSON-serialized data no just across process boundaries (which I was imagining was just as per-origin process isolation) - but to other native applications acting as payment handlers.

As such, I concur that it still makes sense to keep the JSON serialization.