diff --git a/index.html b/index.html index f4a886b..d5b3422 100644 --- a/index.html +++ b/index.html @@ -162,7 +162,7 @@

using information (labels and icons) provided at registration or otherwise available from the Web app. -
  • When the user (the payer) selects an When the user (the payer) selects an instrument, the user agent fires a {{PaymentRequestEvent}} (cf. the user interaction task source) in the service worker whose interface PaymentManager { [SameObject] readonly attribute PaymentInstruments instruments; attribute DOMString userHint; + Promise<undefined> enableDelegations(sequence<PaymentDelegation> delegations); };

    The {{PaymentManager}} is used by payment handlers to manage - their associated instruments as well as supported payment methods. + their associated instruments as well as supported payment methods and + delegations.

    @@ -347,6 +349,54 @@

    cause confusion to display the additional hint.

    +
    +

    + enableDelegations() method +

    +

    + This method allows a payment handler to asynchronously + declare its supported PaymentDelegation list. +

    +
    + +
    +

    + PaymentDelegation enum +

    +
    +        enum PaymentDelegation {
    +          "shippingAddress",
    +          "payerName",
    +          "payerPhone",
    +          "payerEmail"
    +        };
    +        
    +
    +
    + "shippingAddress" +
    +
    + The payment handler will provide shipping address whenever needed. +
    +
    + "payerName" +
    +
    + The payment handler will provide payer's name whenever needed. +
    +
    + "payerPhone" +
    +
    + The payment handler will provide payer's phone whenever needed. +
    +
    + "payerEmail" +
    +
    + The payment handler will provide payer's email whenever needed. +
    +

    @@ -366,7 +416,7 @@

    The {{PaymentInstruments}} interface represents a collection of payment instruments, each uniquely identified by an - instrumentKey. The instrumentKey identifier + instrumentKey. The instrumentKey identifier will be passed to the payment handler to indicate the {{PaymentInstrument}} selected by the user, if any.

    @@ -743,6 +793,8 @@

    navigator.serviceWorker.register("/sw.js"); const registration = await navigator.serviceWorker.ready; + await registration.paymentManager.enableDelegations( + ['shippingAddress', 'payerName']); // Excellent, we got it! Let's now set up the user's payment // instruments. @@ -968,15 +1020,18 @@

    The PaymentRequestDetailsUpdate contains the updated - total (optionally with modifiers) and possible errors resulting from - user selection of a payment method. + total (optionally with modifiers and shipping options) and possible + errors resulting from user selection of a payment method, a shipping + address, or a shipping option within a payment handler.

             dictionary PaymentRequestDetailsUpdate {
               DOMString error;
               PaymentCurrencyAmount total;
               sequence<PaymentDetailsModifier> modifiers;
    +          sequence<PaymentShippingOption> shippingOptions;
               object paymentMethodErrors;
    +          AddressErrors shippingAddressErrors;
             };
             
    @@ -985,7 +1040,7 @@

    A human readable string that explains why the user selected payment - method cannot be used. + method, shipping address or shipping option cannot be used.

    @@ -993,9 +1048,12 @@

    total member

    - Updated total based on the changed payment method. The total can - change, for example, because the billing address of the payment - method selected by the user changes the Value Added Tax (VAT). + Updated total based on the changed payment method, shipping + address, or shipping option. The total can change, for example, + because the billing address of the payment method selected by the + user changes the Value Added Tax (VAT); Or because the shipping + option/address selected/provided by the user changes the shipping + cost.

    @@ -1003,10 +1061,21 @@

    modifiers member

    - Updated modifiers based on the changed payment method. For example, - if the overall total has increased by €1.00 based on the billing or - shipping address, then the totals specified in each of the - modifiers should also increase by €1.00. + Updated modifiers based on the changed payment method, shipping + address, or shipping option. For example, if the overall total has + increased by €1.00 based on the billing or shipping address, then + the totals specified in each of the modifiers should also increase + by €1.00. +

    +
    +
    +

    + shippingOptions member +

    +

    + Updated shippingOptions based on the changed shipping address. For + example, it is possible that express shipping is more expensive or + unavailable for the user provided country.

    @@ -1017,6 +1086,14 @@

    Validation errors for the payment method, if any.

    +
    +

    + shippingAddressErrors member +

    +

    + Validation errors for the shipping address, if any. +

    +
    @@ -1039,8 +1116,13 @@

    readonly attribute FrozenArray<PaymentMethodData> methodData; readonly attribute object total; readonly attribute FrozenArray<PaymentDetailsModifier> modifiers; + readonly attribute boolean requestBillingAddress; + readonly attribute object? paymentOptions; + readonly attribute FrozenArray<PaymentShippingOption>? shippingOptions; Promise<WindowClient?> openWindow(USVString url); Promise<PaymentRequestDetailsUpdate?> changePaymentMethod(DOMString methodName, optional object? methodDetails = null); + Promise<PaymentRequestDetailsUpdate?> changeShippingAddress(optional AddressInit shippingAddress = {}); + Promise<PaymentRequestDetailsUpdate?> changeShippingOption(DOMString shippingOption); undefined respondWith(Promise<PaymentHandlerResponse> handlerResponsePromise); }; @@ -1117,6 +1199,40 @@

    Algorithm defined below.

    +
    +

    + requestBillingAddress attribute +

    +

    + The value of PaymentOptions.requestBillingAddress + in the PaymentRequest. +

    +
    +
    +

    + paymentOptions attribute +

    +

    + The value of PaymentOptions in the + PaymentRequest. Available only when shippingAddress and/or + any subset of payer's contact information are requested. +

    +
    +
    +

    + shippingOptions attribute +

    +

    + The value of ShippingOptions + in the PaymentDetailsInit dictionary of the corresponding + PaymentRequest.(PaymentDetailsInit inherits + ShippingOptions from PaymentDetailsBase). Available only + when shipping address is requested. +

    +

    openWindow() method @@ -1138,6 +1254,30 @@

    called, it runs the change payment method algorithm.

    +
    +

    + changeShippingAddress() + method +

    +

    + This method is used by the payment handler to get updated payment + details given the shippingAddress. When called, it runs the + change payment details algorithm. +

    +
    +
    +

    + changeShippingOption() + method +

    +

    + This method is used by the payment handler to get updated payment + details given the shippingOption identifier. When called, it runs + the change payment details algorithm. +

    +

    sequence<PaymentMethodData> methodData; PaymentCurrencyAmount total; sequence<PaymentDetailsModifier> modifiers; + PaymentOptions paymentOptions; + sequence<PaymentShippingOption> shippingOptions; };

    The topOrigin, paymentRequestOrigin, paymentRequestId, methodData, - total, and modifiers members share their - definitions with those defined for {{PaymentRequestEvent}} + total, modifiers, paymentOptions, + and shippingOptions members share their definitions with + those defined for {{PaymentRequestEvent}}

    @@ -1417,6 +1560,23 @@

    \[\[details\]\].id from the PaymentRequest.
    +
    + paymentOptions +
    +
    + A copy of the paymentOptions dictionary passed to the + constructor of the corresponding PaymentRequest. +
    +
    + shippingOptions +
    +
    + A copy of the shippingOptions field on the + PaymentDetailsInit from the corresponding + PaymentRequest. +

    Then run the following steps in parallel, with @@ -1645,6 +1805,11 @@

    dictionary PaymentHandlerResponse { DOMString methodName; object details; + DOMString? payerName; + DOMString? payerEmail; + DOMString? payerPhone; + AddressInit shippingAddress; + DOMString? shippingOption; };
    @@ -1689,6 +1854,46 @@

  • +
    +

    + payerName attribute +

    +

    + The user provided payer's name. +

    +
    +
    +

    + payerEmail attribute +

    +

    + The user provided payer's email. +

    +
    +
    +

    + payerPhone attribute +

    +

    + The user provided payer's phone number. +

    +
    +
    +

    + shippingAddress attribute +

    +

    + The user provided shipping address. +

    +
    +
    +

    + shippingOption attribute +

    +

    + The identifier of the user selected shipping option. +

    +

    @@ -1719,6 +1924,36 @@

    +
    +

    + Change Payment Details Algorithm +

    +

    + When this algorithm is invoked with shippingAddress or + shippingOption the user agent MUST run the following + steps: +

    +
      +
    1. Run the PaymentRequest updated algorithm with + PaymentRequestUpdateEvent |event| constructed using the + updated details (shippingAddress or + shippingOption). +
    2. +
    3. If |event|.updateWith(detailsPromise) is not run, return + null. +
    4. +
    5. If |event|.updateWith(detailsPromise) throws, rethrow the + error. +
    6. +
    7. If |event|.updateWith(detailsPromise) times out + (optional), throw {{"InvalidStateError"}} {{DOMException}}. +
    8. +
    9. Construct and return a PaymentRequestDetailsUpdate from + the detailsPromise in + |event|.updateWith(detailsPromise). +
    10. +
    +

    Respond to PaymentRequest Algorithm @@ -1780,11 +2015,61 @@

    or not JSON-serializable, run the payment app failure algorithm and terminate these steps. +
  • Let shippingRequired be the requestShipping + value of the associated PaymentRequest's + paymentOptions. If shippingRequired and + handlerResponse.shippingAddress + is not present, run the payment app failure algorithm + and terminate these steps. +
  • +
  • If shippingRequired and + handlerResponse.shippingOption is + not present or not set to one of shipping options identifiers + from |event|.shippingOptions, + run the payment app failure algorithm and terminate + these steps. +
  • +
  • Let payerNameRequired be the requestPayerName + value of the associated PaymentRequest's + paymentOptions. If payerNameRequired and + handlerResponse.payerName is not + present, run the payment app failure algorithm and + terminate these steps. +
  • +
  • Let payerEmailRequired be the requestPayerEmail + value of the associated PaymentRequest's + paymentOptions. If payerEmailRequired and + handlerResponse.payerEmail is not + present, run the payment app failure algorithm and + terminate these steps. +
  • +
  • Let payerPhoneRequired be the requestPayerPhone + value of the associated PaymentRequest's + paymentOptions. If payerPhoneRequired and + handlerResponse.payerPhone is not + present, run the payment app failure algorithm and + terminate these steps. +
  • Serialize required members of handlerResponse ( - methodName and details are always - required.): + methodName and details are always required; + shippingAddress and shippingOption are + required when shippingRequired is true; + payerName, payerEmail, and + payerPhone are required when + payerNameRequired, payerEmailRequired, and + payerPhoneRequired are true, respectively.):
    1. For each memberin handlerResponseLet serializeMemberbe @@ -1822,6 +2107,39 @@

      "PaymentResponse">response.details.

    2. +
    3. If shippingRequired, then set the + + shippingAddress attribute of associated + PaymentReqeust's response to + shippingAddress. Otherwise, set it to null. +
    4. +
    5. If shippingRequired, then set the + + shippingOption attribute of associated PaymentReqeust's + response to + shippingOption. Otherwise, set it to null. +
    6. +
    7. If payerNameRequired, then set the + + payerName attribute of associated PaymentReqeust's + response to + payerName. Otherwise, set it to null. +
    8. +
    9. If payerEmailRequired, then set the + payerEmail + attribute of associated PaymentReqeust's response to + payerEmail. Otherwise, set it to null. +
    10. +
    11. If payerPhoneRequired, then set the + payerPhone + attribute of associated PaymentReqeust's response to + payerPhone. Otherwise, set it to null. +
  • @@ -1859,6 +2177,22 @@

    expiryYear : "2020", cardSecurityCode: "123" }, + shippingAddress: { + addressLine: [ + "1875 Explorer St #1000", + ], + city: "Reston", + country: "US", + dependentLocality: "", + organization: "", + phone: "+15555555555", + postalCode: "20190", + recipient: "John Smith", + region: "VA", + sortingCode: "" + }, + shippingOption: "express", + payerEmail: "john.smith@gmail.com", }); })); @@ -1911,7 +2245,8 @@

  • In a browser that supports Payment Handler API, CanMakePaymentEvent will fire in registered payment handlers - that can provide all merchant requested information. + that can provide all merchant requested information including + shipping address and payer's contact information whenever needed.
  • @@ -2109,6 +2444,13 @@

    PaymentMethodData, PaymentOptions, + PaymentShippingOption, + AddressInit, + AddressErrors, + PaymentMethodChangeEvent, PaymentRequestUpdateEvent,