-
Notifications
You must be signed in to change notification settings - Fork 42
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
Support delegating collection of shipping address and other user data to Payment Handler #337
Comments
A payment handler should specify their own capabilities. registration.paymentManager.capabilities.set(
['requestShipping', 'requestPayerEmail'])
.then(handleDoneSettingCapabilities)
.catch(handleError); This will allow user agents to re-use the keys of the PaymentOptions dictionary. The self.addEventListener('paymentrequest', evt => {
if (evt.requestShipping) {
doSomethingForShippingAddresses();
}
}); A payment handler should also be able to fire the relevant events for the merchants. registration.paymentManager.fireEvent(
paymentRequestIdentifier, 'shippingaddresschange', {country: 'CA'})
.then(handleUpdateWith)
.catch(handleError); User agents can reuse event names from Payment Request, such as The event firing method should be on the |
Passing the registration.paymentManager.paymentRequestEvent
.then((evt) => {
console.log('Firing the method change event for payment request ' +
evt.paymentRequestId);
evt.changePaymentMethod('https://bobpay.xyz', {billingAddress: {country: 'CA'}})
.then(handleUpdateWith)
.catch(handleError);
}).catch(handleError); The @romandev : This is similar to your idea of delegating the full payment lifecycle to the payment handler window, right? This would allow the payment handler window to respond to the Payment Request without looping back into the service worker: registration.paymentManager.paymentRequestEvent
.then((evt) => {
console.log('Responding to payment request ' +
evt.paymentRequestId);
evt.respondWith({methodName: 'https://bobpay.xyz', details: {token: '123'}});
}).catch(handleError); This design still allows for UI-less payment handler, which might be necessary for some use cases. |
@danyao and @rsolomakhin, I am rereading this issue in light of this Basic Card issue: Suppose we were to make changes to Payment Request as @marcoscaceres suggested: In order for a payment handler (e.g., a third party payment handler doing Basic Card, but also any third party payment handler for any payment method) to know which fields of the response data to return (or not), we need to pass the array to the payment handler. Thus, I think we should prepare for the mediator to hand "request*" to the payment handler, whether a mere boolean or an array. Make sense? Ian |
@ianbjacobs : Yep, it makes sense to pass such booleans as "requestShipping", "requestPayerEmail", "requestPayerName", and "requestPayerPhone" to a payment handler. Is that what you had in mind? |
@rsolomakhin, yes, that's what I have in mind. In some cases they will be booleans (e.g., requestPayerEmail) but there's a chance we might also start using arrays (e.g., for requestBillingAddress)...we aren't yet but if we do I want to be sure PH API can handle that. |
I don't see any blockers here, so go ahead :-D |
See related pull request in PR API: |
Delegation of data collection, as described above, would be particularly useful for SRC Payment Method we've been working on. Apart from payment credentials, In SRC the following data can be provided to the merchant on request:
Furthermore, the model for requesting the specific data element is largely in line with PR API. |
I wonder if the proposed API would allow the browser to pull addresses and contact details from registered Payment Handlers to present combined data as part of payment sheet experience to the user for selection? Alternatively, the API could allow delegation of a user to dedicated UX of Payment Handler to complete the selection of data addresses and other requested data elements. That approach would require address selection to be deferred after the payment instrument is selected so it's known which PH to delegate the user to. |
@tblachowicz : My thinking is along the lines of delegating the full payment flow to your payment handler, if you're able to provide all of the requested data. The browser's sheet will be skipped, similar to the current Google Pay implementation. |
@rsolomakhin: In case there is more than single capable payment handler installed in the browser the appearance of the payment sheet in some shape or form is unavoidable. The consumer must be able to select the desired payment instrument e.g. SRC or Google Pay. In general, skipping the browser's sheet sounds like a great idea, but it's limited to the case where there is only single PH installed or Merchant requests a single specific payment method. Am I getting it right? |
@tblachowicz : That's right. In addition, it would be great to introduce a user setting for a default payment handler (per merchant origin, for example), so the sheet can be skipped more often. |
@rsolomakhin: I was wondering whether end user should be able to select preferred/default payment handler e.g. wallet or preferred/default payment instrument e.g. specific card with the wallet. |
@tblachowicz : Yep, I think the end user should be able to select preferred/default payment handler. We are trying to stay out of what happens inside of the wallet, so it would be up to the wallet provider to let the end user select the default instrument within the wallet. Payment apps already do this today, AFAIK. |
(I deleted that comment unintentionally yesterday, posting again) @rsolomakhin : OK. I understand your point. Would you consider embedded Payment Handler e.g. an implementation of the basic card also as a wallet? I've just double checked the current version of the specification to compare the approaches. In the initial section 2. Overview of Handling Payment Requests there is a description of the flow that assumes that payment handler sets a list of payment instruments, such as individual cards, that are used by the user-agent to facilitate selection of payment credentials by the consumer. I understand the flow that the payment instrument is presented to the end-user by the browser, not the wallet or payment handler. I wonder if my reading of the specification is in line with the intent of the authors and the interpretation of others. |
@tblachowicz wrote:
Yes, that's an autofill wallet.
The spec allows for this, but does not require it. We wanted to keep the API consistent for both use cases, while giving the browser implementers some freedom to experiment with actual UI. Exposing individual instruments from payment handlers is not high on our priority list, although we have heard calls for it from the industry, so it's not out of the question entirely. |
While I believe it's an important discussion to have I think we've diverged from the main topic that'd been the delegation of collection of shipping, billing and contact details from the end-user. I suggest we get back to the topic here. If there is any other thread related to the subject of wallet vs payment instrument I'm happy to jump there. |
Today the Payment Handler API supports instrument level presentation and selection by the user:
We don't have any implementations today of the latter feature (that I'm aware of). I don't think we have any open issue on this topic because it is already in the specification. I think shedding light on the importance of these features for various payment methods is a good way to restart the conversation. If you think there are additional specific features needed to address the desired capability, I encourage you to raise new issues. Thanks for weighing in! Ian [1] https://w3c.github.io/payment-handler/#paymentinstrument-dictionary |
Thanks for clarifications @ianbjacobs. |
Chrome is proposing changes to Payment Handler API to enable shipping and contact info delegation. Please see the WIP Explainer below: |
The Explainer has been updated with JIT installation, and skip the sheet: |
closes #337 The following tasks have been completed: [x] web platform tests ( enable-shipping-contact-delegation, change-shipping-option, change-shipping-address) [ ] MDN Docs added. Implementation commitment: [ ] Safari [x] Chrome (https://crbug.com/984694) [ ] Firefox [ ] Edge
Today if a merchant requests shipping address or payer's contact information, the data collection is always handled by the browser. At last week's WPWG FTF in Foster City, there was interest among payment providers to be able to provide this information. Supporting this delegation can lead to better user experience because the payment app may have more accurate information than the browser.
We should support delegation for all fields that are currently requested via
PaymentOptions
: https://w3c.github.io/payment-request/#dom-paymentoptionsThe text was updated successfully, but these errors were encountered: