Changeset 236552 in webkit


Ignore:
Timestamp:
Sep 27, 2018, 9:44:49 AM (6 years ago)
Author:
aestes@apple.com
Message:

[Apple Pay] Support granular errors in PaymentDetailsUpdate
https://bugs.webkit.org/show_bug.cgi?id=189938

Reviewed by Youenn Fablet.

Source/WebCore:

Implemented the shippingAddressErrors, payerErrors, and paymentMethodErrors properties on
PaymentDetailsUpdate, as specified in the Payment Request API W3C Editor's Draft of
26 September 2018.

When these errors are specified in a PaymentDetailsUpdate, map them to PaymentErrors. For
shippingAddressErrors and payerErrors, we use the "shippingContactInvalid" code and a
contact field that matches the shippingAddressError or payerError property specified.

For paymentMethodErrors, we interpret this as a sequence of ApplePayErrors, which are
converted to PaymentErrors as in Apple Pay JS.

Tests: http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https.html

http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html

  • DerivedSources.make: Removed some tabs and added new .idl files.
  • Modules/applepay/ApplePayError.idl: Moved ApplePayErrorCode and ApplePayErrorContactField

into their own .idl files so they can be used in MockPaymentError.

  • Modules/applepay/ApplePayErrorCode.h: Added.
  • Modules/applepay/ApplePayErrorCode.idl: Added.
  • Modules/applepay/ApplePayErrorContactField.h: Added.
  • Modules/applepay/ApplePayErrorContactField.idl: Added.
  • Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:

(WebCore::appendShippingContactInvalidError): Appended a "shippingContactInvalid"
PaymentError to errors if the message is non-null.
(WebCore::ApplePayPaymentHandler::computeErrors const):
(WebCore::ApplePayPaymentHandler::detailsUpdated):
(WebCore::ApplePayPaymentHandler::shippingAddressUpdated): Computed a vector of PaymentErrors
based on shippingAddressErrors, payerErrors, and paymentMethodErrors.

  • Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
  • Modules/paymentrequest/PaymentDetailsUpdate.h:
  • Modules/paymentrequest/PaymentDetailsUpdate.idl: Defined shippingAddressErrors,

payerErrors, and paymentMethodErrors.

  • Modules/paymentrequest/PaymentHandler.h:
  • Modules/paymentrequest/PaymentRequest.cpp:

(WebCore::PaymentRequest::paymentMethodChanged):
(WebCore::PaymentRequest::settleDetailsPromise): Passed shippingAddressErrors, payerErrors,
and paymentMethodErrors to the payment handler.

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • testing/MockPaymentCoordinator.cpp:

(WebCore::MockPaymentCoordinator::completeShippingContactSelection): Stored errors in m_errors.

  • testing/MockPaymentCoordinator.h:
  • testing/MockPaymentCoordinator.idl: Added an errors attribute.
  • testing/MockPaymentError.h: Added.
  • testing/MockPaymentError.idl: Added.

LayoutTests:

  • http/tests/resources/payment-request.js:

(validPaymentDetails):
(updateDetailsOnShippingAddressChange):

  • http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https-expected.txt: Added.
  • http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https.html: Added.
  • http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-expected.txt: Added.
  • http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html: Added.
  • platform/mac-wk2/TestExpectations:
Location:
trunk
Files:
4 added
17 edited
6 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r236550 r236552  
     12018-09-27  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Support granular errors in PaymentDetailsUpdate
     4        https://bugs.webkit.org/show_bug.cgi?id=189938
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * http/tests/resources/payment-request.js:
     9        (validPaymentDetails):
     10        (updateDetailsOnShippingAddressChange):
     11        * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https-expected.txt: Added.
     12        * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https.html: Added.
     13        * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-expected.txt: Added.
     14        * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html: Added.
     15        * platform/mac-wk2/TestExpectations:
     16
    1172018-09-27  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/LayoutTests/http/tests/resources/payment-request.js

    r224402 r236552  
    1919    }, name);
    2020}
     21
     22function validPaymentMethod()
     23{
     24    return {
     25        supportedMethods: 'https://apple.com/apple-pay',
     26        data: {
     27            version: 2,
     28            merchantIdentifier: '',
     29            countryCode: 'US',
     30            supportedNetworks: ['visa', 'masterCard'],
     31            merchantCapabilities: ['supports3DS'],
     32        },
     33    }
     34}
     35
     36function validPaymentDetails()
     37{
     38    return {
     39        total: {
     40            label: 'Total',
     41            amount: {
     42                currency: 'USD',
     43                value: '10.00',
     44            },
     45        },
     46        displayItems: [{
     47            label: 'Item',
     48            amount: {
     49                currency: 'USD',
     50                value: '10.00',
     51            },
     52        }],
     53    }
     54}
     55
     56function updateDetailsOnShippingAddressChange(paymentDetailsInit, paymentOptions, detailsUpdate)
     57{
     58    return new Promise((resolve, reject) => {
     59        activateThen(() => {
     60            var request = new PaymentRequest([validPaymentMethod()], paymentDetailsInit, paymentOptions);
     61            request.onmerchantvalidation = (event) => {
     62                event.complete({ });
     63            };
     64            request.onshippingaddresschange = (event) => {
     65                var detailsUpdatePromise = new Promise((resolve, reject) => {
     66                    resolve(detailsUpdate);
     67                });
     68                event.updateWith(detailsUpdatePromise);
     69                detailsUpdatePromise.then(() => {
     70                    resolve();
     71                    request.abort();
     72                });
     73            };
     74            request.show().catch(error => error);
     75        });
     76    });
     77}
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r236481 r236552  
    2727[ Sierra ] http/tests/ssl/applepay/ApplePaySessionV4.html [ Skip ]
    2828[ Sierra ] http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html [ Skip ]
     29[ Sierra ] http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html [ Skip ]
    2930[ HighSierra ] http/tests/ssl/applepay/ApplePayButtonV4.html [ Skip ]
    3031[ HighSierra ] http/tests/ssl/applepay/ApplePaySessionV4.html [ Skip ]
     
    758759[ Mojave+ ] http/tests/ssl/applepay/ApplePaySessionV4.html [ Pass ]
    759760[ HighSierra+ ] http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html [ Pass ]
     761[ HighSierra+ ] http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html [ Pass ]
    760762# <rdar://problem/31634451>
    761763[ HighSierra+ ] http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r236551 r236552  
     12018-09-27  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Support granular errors in PaymentDetailsUpdate
     4        https://bugs.webkit.org/show_bug.cgi?id=189938
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Implemented the shippingAddressErrors, payerErrors, and paymentMethodErrors properties on
     9        PaymentDetailsUpdate, as specified in the Payment Request API W3C Editor's Draft of
     10        26 September 2018.
     11
     12        When these errors are specified in a PaymentDetailsUpdate, map them to PaymentErrors. For
     13        shippingAddressErrors and payerErrors, we use the "shippingContactInvalid" code and a
     14        contact field that matches the shippingAddressError or payerError property specified.
     15
     16        For paymentMethodErrors, we interpret this as a sequence of ApplePayErrors, which are
     17        converted to PaymentErrors as in Apple Pay JS.
     18
     19        Tests: http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https.html
     20               http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html
     21
     22        * DerivedSources.make: Removed some tabs and added new .idl files.
     23        * Modules/applepay/ApplePayError.idl: Moved ApplePayErrorCode and ApplePayErrorContactField
     24        into their own .idl files so they can be used in MockPaymentError.
     25        * Modules/applepay/ApplePayErrorCode.h: Added.
     26        * Modules/applepay/ApplePayErrorCode.idl: Added.
     27        * Modules/applepay/ApplePayErrorContactField.h: Added.
     28        * Modules/applepay/ApplePayErrorContactField.idl: Added.
     29
     30        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
     31        (WebCore::appendShippingContactInvalidError): Appended a "shippingContactInvalid"
     32        PaymentError to errors if the message is non-null.
     33        (WebCore::ApplePayPaymentHandler::computeErrors const):
     34        (WebCore::ApplePayPaymentHandler::detailsUpdated):
     35        (WebCore::ApplePayPaymentHandler::shippingAddressUpdated): Computed a vector of PaymentErrors
     36        based on shippingAddressErrors, payerErrors, and paymentMethodErrors.
     37
     38        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
     39
     40        * Modules/paymentrequest/PaymentDetailsUpdate.h:
     41        * Modules/paymentrequest/PaymentDetailsUpdate.idl: Defined shippingAddressErrors,
     42        payerErrors, and paymentMethodErrors.
     43
     44        * Modules/paymentrequest/PaymentHandler.h:
     45        * Modules/paymentrequest/PaymentRequest.cpp:
     46        (WebCore::PaymentRequest::paymentMethodChanged):
     47        (WebCore::PaymentRequest::settleDetailsPromise): Passed shippingAddressErrors, payerErrors,
     48        and paymentMethodErrors to the payment handler.
     49
     50        * SourcesCocoa.txt:
     51        * WebCore.xcodeproj/project.pbxproj:
     52
     53        * testing/MockPaymentCoordinator.cpp:
     54        (WebCore::MockPaymentCoordinator::completeShippingContactSelection): Stored errors in m_errors.
     55        * testing/MockPaymentCoordinator.h:
     56        * testing/MockPaymentCoordinator.idl: Added an errors attribute.
     57
     58        * testing/MockPaymentError.h: Added.
     59        * testing/MockPaymentError.idl: Added.
     60
    1612018-09-27  Alex Christensen  <achristensen@webkit.org>
    262
  • trunk/Source/WebCore/DerivedSources.make

    r236481 r236552  
    1 # Copyright (C) 2006-2017 Apple Inc. All rights reserved.
     1# Copyright (C) 2006-2018 Apple Inc. All rights reserved.
    22# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
    33# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
     
    9191    $(WebCore)/Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.idl \
    9292    $(WebCore)/Modules/applepay/ApplePayContactField.idl \
    93         $(WebCore)/Modules/applepay/ApplePayError.idl \
     93    $(WebCore)/Modules/applepay/ApplePayError.idl \
     94    $(WebCore)/Modules/applepay/ApplePayErrorCode.idl \
     95    $(WebCore)/Modules/applepay/ApplePayErrorContactField.idl \
    9496    $(WebCore)/Modules/applepay/ApplePayLineItem.idl \
    9597    $(WebCore)/Modules/applepay/ApplePayMerchantCapability.idl \
    9698    $(WebCore)/Modules/applepay/ApplePayPayment.idl \
    9799    $(WebCore)/Modules/applepay/ApplePayPaymentAuthorizedEvent.idl \
    98         $(WebCore)/Modules/applepay/ApplePayPaymentAuthorizationResult.idl \
     100    $(WebCore)/Modules/applepay/ApplePayPaymentAuthorizationResult.idl \
    99101    $(WebCore)/Modules/applepay/ApplePayPaymentContact.idl \
    100102    $(WebCore)/Modules/applepay/ApplePayPaymentMethod.idl \
    101103    $(WebCore)/Modules/applepay/ApplePayPaymentMethodSelectedEvent.idl \
    102104    $(WebCore)/Modules/applepay/ApplePayPaymentMethodType.idl \
    103         $(WebCore)/Modules/applepay/ApplePayPaymentMethodUpdate.idl \
     105    $(WebCore)/Modules/applepay/ApplePayPaymentMethodUpdate.idl \
    104106    $(WebCore)/Modules/applepay/ApplePayPaymentPass.idl \
    105107    $(WebCore)/Modules/applepay/ApplePayPaymentRequest.idl \
     
    107109    $(WebCore)/Modules/applepay/ApplePaySession.idl \
    108110    $(WebCore)/Modules/applepay/ApplePayShippingContactSelectedEvent.idl \
    109         $(WebCore)/Modules/applepay/ApplePayShippingContactUpdate.idl \
     111    $(WebCore)/Modules/applepay/ApplePayShippingContactUpdate.idl \
    110112    $(WebCore)/Modules/applepay/ApplePayShippingMethod.idl \
    111113    $(WebCore)/Modules/applepay/ApplePayShippingMethodSelectedEvent.idl \
    112         $(WebCore)/Modules/applepay/ApplePayShippingMethodUpdate.idl \
     114    $(WebCore)/Modules/applepay/ApplePayShippingMethodUpdate.idl \
    113115    $(WebCore)/Modules/applepay/ApplePayValidateMerchantEvent.idl \
    114116    $(WebCore)/Modules/applepay/paymentrequest/ApplePayModifier.idl \
     
    983985    $(WebCore)/testing/MockPaymentAddress.idl \
    984986    $(WebCore)/testing/MockPaymentCoordinator.idl \
     987    $(WebCore)/testing/MockPaymentError.idl \
    985988    $(WebCore)/testing/ServiceWorkerInternals.idl \
    986989    $(WebCore)/testing/TypeConversions.idl \
  • trunk/Source/WebCore/Modules/applepay/ApplePayError.idl

    r223580 r236552  
    2525
    2626[
    27     Conditional=APPLE_PAY_SESSION_V3,
    28 ] enum ApplePayErrorCode {
    29     "unknown",
    30     "shippingContactInvalid",
    31     "billingContactInvalid",
    32     "addressUnserviceable"
    33 };
    34 
    35 [
    36     Conditional=APPLE_PAY_SESSION_V3,
    37 ] enum ApplePayErrorContactField {
    38     "phoneNumber",
    39     "emailAddress",
    40     "name",
    41     "phoneticName",
    42     "postalAddress",
    43     "addressLines",
    44     "subLocality",
    45     "locality",
    46     "postalCode",
    47     "subAdministrativeArea",
    48     "administrativeArea",
    49     "country",
    50     "countryCode"
    51 };
    52 
    53 [
    5427    Constructor(ApplePayErrorCode errorCode, optional ApplePayErrorContactField contactField, optional DOMString message = ""),
    5528    Conditional=APPLE_PAY_SESSION_V3,
  • trunk/Source/WebCore/Modules/applepay/ApplePayErrorCode.h

    r236551 r236552  
    2424 */
    2525
    26 [
    27     Conditional=PAYMENT_REQUEST
    28 ] dictionary PaymentDetailsUpdate : PaymentDetailsBase {
    29     DOMString error;
    30     PaymentItem total;
    31 };
     26#pragma once
     27
     28#if ENABLE(APPLE_PAY)
     29
     30#include "ApplePaySessionPaymentRequest.h"
     31
     32namespace WebCore {
     33
     34using ApplePayErrorCode = PaymentError::Code;
     35
     36} // namespace WebCore
     37
     38#endif // ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/Modules/applepay/ApplePayErrorCode.idl

    r236551 r236552  
    2525
    2626[
    27     Conditional=PAYMENT_REQUEST
    28 ] dictionary PaymentDetailsUpdate : PaymentDetailsBase {
    29     DOMString error;
    30     PaymentItem total;
     27    Conditional=APPLE_PAY,
     28    ExportMacro=WEBCORE_EXPORT,
     29] enum ApplePayErrorCode {
     30    "unknown",
     31    "shippingContactInvalid",
     32    "billingContactInvalid",
     33    "addressUnserviceable"
    3134};
  • trunk/Source/WebCore/Modules/applepay/ApplePayErrorContactField.h

    r236551 r236552  
    2424 */
    2525
    26 [
    27     Conditional=PAYMENT_REQUEST
    28 ] dictionary PaymentDetailsUpdate : PaymentDetailsBase {
    29     DOMString error;
    30     PaymentItem total;
    31 };
     26#pragma once
     27
     28#if ENABLE(APPLE_PAY)
     29
     30#include "ApplePaySessionPaymentRequest.h"
     31
     32namespace WebCore {
     33
     34using ApplePayErrorContactField = PaymentError::ContactField;
     35
     36} // namespace WebCore
     37
     38#endif // ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/Modules/applepay/ApplePayErrorContactField.idl

    r236551 r236552  
    2525
    2626[
    27     Conditional=PAYMENT_REQUEST
    28 ] dictionary PaymentDetailsUpdate : PaymentDetailsBase {
    29     DOMString error;
    30     PaymentItem total;
     27    Conditional=APPLE_PAY,
     28    ExportMacro=WEBCORE_EXPORT,
     29] enum ApplePayErrorContactField {
     30    "phoneNumber",
     31    "emailAddress",
     32    "name",
     33    "phoneticName",
     34    "postalAddress",
     35    "addressLines",
     36    "subLocality",
     37    "locality",
     38    "postalCode",
     39    "subAdministrativeArea",
     40    "administrativeArea",
     41    "country",
     42    "countryCode"
    3143};
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp

    r236429 r236552  
    2929#if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
    3030
     31#include "AddressErrors.h"
    3132#include "ApplePayContactField.h"
    3233#include "ApplePayMerchantCapability.h"
     
    3738#include "EventNames.h"
    3839#include "Frame.h"
     40#include "JSApplePayError.h"
    3941#include "JSApplePayPayment.h"
    4042#include "JSApplePayPaymentMethod.h"
     
    4345#include "MerchantValidationEvent.h"
    4446#include "Page.h"
     47#include "PayerErrorFields.h"
    4548#include "Payment.h"
    4649#include "PaymentAuthorizationStatus.h"
     
    310313}
    311314
    312 ExceptionOr<void> ApplePayPaymentHandler::detailsUpdated(PaymentRequest::UpdateReason reason, const String& error)
     315static inline void appendShippingContactInvalidError(String&& message, std::optional<PaymentError::ContactField> contactField, Vector<PaymentError>& errors)
     316{
     317    if (!message.isNull())
     318        errors.append({ PaymentError::Code::ShippingContactInvalid, WTFMove(message), WTFMove(contactField) });
     319}
     320
     321Vector<PaymentError> ApplePayPaymentHandler::computeErrors(String&& error, AddressErrors&& addressErrors, PayerErrorFields&& payerErrors, JSC::JSObject* paymentMethodErrors) const
     322{
     323    Vector<PaymentError> errors;
     324
     325    auto& options = m_paymentRequest->paymentOptions();
     326    using ContactField = PaymentError::ContactField;
     327
     328    if (options.requestShipping && m_paymentRequest->paymentDetails().shippingOptions.isEmpty()) {
     329        appendShippingContactInvalidError(WTFMove(error), std::nullopt, errors);
     330        appendShippingContactInvalidError(WTFMove(addressErrors.addressLine), ContactField::AddressLines, errors);
     331        appendShippingContactInvalidError(WTFMove(addressErrors.city), ContactField::Locality, errors);
     332        appendShippingContactInvalidError(WTFMove(addressErrors.country), ContactField::Country, errors);
     333        appendShippingContactInvalidError(WTFMove(addressErrors.dependentLocality), ContactField::SubLocality, errors);
     334        appendShippingContactInvalidError(WTFMove(addressErrors.phone), ContactField::PhoneNumber, errors);
     335        appendShippingContactInvalidError(WTFMove(addressErrors.postalCode), ContactField::PostalCode, errors);
     336        appendShippingContactInvalidError(WTFMove(addressErrors.recipient), ContactField::Name, errors);
     337        appendShippingContactInvalidError(WTFMove(addressErrors.region), ContactField::AdministrativeArea, errors);
     338    }
     339
     340    if (options.requestPayerName)
     341        appendShippingContactInvalidError(WTFMove(payerErrors.name), ContactField::Name, errors);
     342
     343    if (options.requestPayerEmail)
     344        appendShippingContactInvalidError(WTFMove(payerErrors.email), ContactField::EmailAddress, errors);
     345
     346    if (options.requestPayerPhone)
     347        appendShippingContactInvalidError(WTFMove(payerErrors.phone), ContactField::PhoneNumber, errors);
     348
     349#if ENABLE(APPLE_PAY_SESSION_V3)
     350    if (paymentMethodErrors) {
     351        auto& context = *scriptExecutionContext();
     352        auto throwScope = DECLARE_THROW_SCOPE(context.vm());
     353        auto applePayErrors = convert<IDLSequence<IDLInterface<ApplePayError>>>(*context.execState(), paymentMethodErrors);
     354        if (!throwScope.exception()) {
     355            for (auto& applePayError : applePayErrors) {
     356                if (applePayError)
     357                    errors.append({ applePayError->code(), applePayError->message(), applePayError->contactField() });
     358            }
     359        }
     360    }
     361#else
     362    UNUSED_PARAM(paymentMethodErrors);
     363#endif
     364
     365    return errors;
     366}
     367
     368ExceptionOr<void> ApplePayPaymentHandler::detailsUpdated(PaymentRequest::UpdateReason reason, String&& error, AddressErrors&& addressErrors, PayerErrorFields&& payerErrors, JSC::JSObject* paymentMethodErrors)
    313369{
    314370    using Reason = PaymentRequest::UpdateReason;
     
    317373        return { };
    318374    case Reason::ShippingAddressChanged:
    319         return shippingAddressUpdated(error);
     375        return shippingAddressUpdated(computeErrors(WTFMove(error), WTFMove(addressErrors), WTFMove(payerErrors), paymentMethodErrors));
    320376    case Reason::ShippingOptionChanged:
    321377        return shippingOptionUpdated();
     
    345401}
    346402
    347 ExceptionOr<void> ApplePayPaymentHandler::shippingAddressUpdated(const String& error)
     403ExceptionOr<void> ApplePayPaymentHandler::shippingAddressUpdated(Vector<PaymentError>&& errors)
    348404{
    349405    ASSERT(m_isUpdating);
     
    351407
    352408    ShippingContactUpdate update;
    353 
    354     if (m_paymentRequest->paymentOptions().requestShipping && m_paymentRequest->paymentDetails().shippingOptions.isEmpty()) {
    355         PaymentError paymentError;
    356         paymentError.code = PaymentError::Code::ShippingContactInvalid;
    357         paymentError.message = error;
    358         update.errors.append(WTFMove(paymentError));
    359     }
     409    update.errors = WTFMove(errors);
    360410
    361411    auto newTotalAndLineItems = computeTotalAndLineItems();
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h

    r236429 r236552  
    5454
    5555    ExceptionOr<ApplePaySessionPaymentRequest::TotalAndLineItems> computeTotalAndLineItems();
     56    Vector<PaymentError> computeErrors(String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) const;
    5657
    57     ExceptionOr<void> shippingAddressUpdated(const String& error);
     58    ExceptionOr<void> shippingAddressUpdated(Vector<PaymentError>&& errors);
    5859    ExceptionOr<void> shippingOptionUpdated();
    5960    ExceptionOr<void> paymentMethodUpdated();
     
    6465    void hide() final;
    6566    void canMakePayment(WTF::Function<void(bool)>&& completionHandler) final;
    66     ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, const String& error) final;
     67    ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) final;
    6768    ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) final;
    6869    void complete(std::optional<PaymentComplete>&&) final;
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentDetailsUpdate.h

    r220955 r236552  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(PAYMENT_REQUEST)
    2929
     30#include "AddressErrors.h"
     31#include "PayerErrorFields.h"
    3032#include "PaymentDetailsBase.h"
    3133#include "PaymentItem.h"
     
    3436namespace WebCore {
    3537
    36 struct PaymentDetailsUpdate final : public PaymentDetailsBase {
     38struct PaymentDetailsUpdate final : PaymentDetailsBase {
    3739    String error;
    3840    PaymentItem total;
     41    AddressErrors shippingAddressErrors;
     42    PayerErrorFields payerErrors;
     43    JSC::Strong<JSC::JSObject> paymentMethodErrors;
    3944};
    4045
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentDetailsUpdate.idl

    r220955 r236552  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929    DOMString error;
    3030    PaymentItem total;
     31    AddressErrors shippingAddressErrors;
     32    PayerErrorFields payerErrors;
     33    object paymentMethodErrors;
    3134};
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h

    r228195 r236552  
    3939
    4040class Document;
     41struct AddressErrors;
     42struct PayerErrorFields;
    4143
    4244class PaymentHandler : public virtual PaymentSessionBase {
     
    5052    virtual void hide() = 0;
    5153    virtual void canMakePayment(WTF::Function<void(bool)>&& completionHandler) = 0;
    52     virtual ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, const String& error) = 0;
     54    virtual ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) = 0;
    5355    virtual ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) = 0;
    5456    virtual void complete(std::optional<PaymentComplete>&&) = 0;
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp

    r236429 r236552  
    560560            dispatchEvent(PaymentMethodChangeEvent::create(eventName, methodName, WTFMove(methodDetailsFunction)));
    561561        else
    562             m_activePaymentHandler->detailsUpdated(UpdateReason::PaymentMethodChanged, { });
     562            m_activePaymentHandler->detailsUpdated(UpdateReason::PaymentMethodChanged, { }, { }, { }, { });
    563563    });
    564564}
     
    628628    auto& context = *m_detailsPromise->scriptExecutionContext();
    629629    auto throwScope = DECLARE_THROW_SCOPE(context.vm());
    630     auto paymentDetailsUpdate = convertDictionary<PaymentDetailsUpdate>(*context.execState(), m_detailsPromise->result());
     630    auto detailsUpdate = convertDictionary<PaymentDetailsUpdate>(*context.execState(), m_detailsPromise->result());
    631631    if (throwScope.exception()) {
    632632        abortWithException(Exception { ExistingExceptionError });
     
    634634    }
    635635
    636     auto totalResult = checkAndCanonicalizeTotal(paymentDetailsUpdate.total.amount);
     636    auto totalResult = checkAndCanonicalizeTotal(detailsUpdate.total.amount);
    637637    if (totalResult.hasException()) {
    638638        abortWithException(totalResult.releaseException());
     
    640640    }
    641641
    642     auto detailsResult = checkAndCanonicalizeDetails(*context.execState(), paymentDetailsUpdate, m_options.requestShipping, ShouldValidatePaymentMethodIdentifier::Yes);
     642    auto detailsResult = checkAndCanonicalizeDetails(*context.execState(), detailsUpdate, m_options.requestShipping, ShouldValidatePaymentMethodIdentifier::Yes);
    643643    if (detailsResult.hasException()) {
    644644        abortWithException(detailsResult.releaseException());
     
    648648    auto shippingOptionAndModifierData = detailsResult.releaseReturnValue();
    649649
    650     m_details.total = WTFMove(paymentDetailsUpdate.total);
    651     m_details.displayItems = WTFMove(paymentDetailsUpdate.displayItems);
     650    m_details.total = WTFMove(detailsUpdate.total);
     651    m_details.displayItems = WTFMove(detailsUpdate.displayItems);
    652652    if (m_options.requestShipping) {
    653         m_details.shippingOptions = WTFMove(paymentDetailsUpdate.shippingOptions);
     653        m_details.shippingOptions = WTFMove(detailsUpdate.shippingOptions);
    654654        m_shippingOption = WTFMove(std::get<0>(shippingOptionAndModifierData));
    655655    }
    656656
    657     m_details.modifiers = WTFMove(paymentDetailsUpdate.modifiers);
     657    m_details.modifiers = WTFMove(detailsUpdate.modifiers);
    658658    m_serializedModifierData = WTFMove(std::get<1>(shippingOptionAndModifierData));
    659659
    660     auto result = m_activePaymentHandler->detailsUpdated(reason, paymentDetailsUpdate.error);
     660    auto result = m_activePaymentHandler->detailsUpdated(reason, WTFMove(detailsUpdate.error), WTFMove(detailsUpdate.shippingAddressErrors), WTFMove(detailsUpdate.payerErrors), detailsUpdate.paymentMethodErrors.get());
    661661    if (result.hasException()) {
    662662        abortWithException(result.releaseException());
  • trunk/Source/WebCore/SourcesCocoa.txt

    r236494 r236552  
    1 // Copyright (C) 2017 Apple Inc. All rights reserved.
     1// Copyright (C) 2017-2018 Apple Inc. All rights reserved.
    22//
    33// Redistribution and use in source and binary forms, with or without
     
    588588    JSApplePayContactField.cpp
    589589    JSApplePayError.cpp
     590    JSApplePayErrorCode.cpp
     591    JSApplePayErrorContactField.cpp
    590592    JSApplePayLineItem.cpp
    591593    JSApplePayMerchantCapability.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r236494 r236552  
    29562956                A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */; };
    29572957                A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2958                A1BB859C2159AEA10067E07D /* ApplePayErrorCode.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BB85992159AEA10067E07D /* ApplePayErrorCode.h */; };
     2959                A1BB85A32159AF570067E07D /* ApplePayErrorContactField.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BB85A02159AF570067E07D /* ApplePayErrorContactField.h */; };
     2960                A1BB85A92159B02C0067E07D /* MockPaymentError.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BB85A62159B02C0067E07D /* MockPaymentError.h */; };
     2961                A1BB85B22159B1A10067E07D /* JSApplePayErrorCode.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BB85AE2159B1A00067E07D /* JSApplePayErrorCode.h */; };
     2962                A1BB85B32159B1A10067E07D /* JSApplePayErrorContactField.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BB85AF2159B1A00067E07D /* JSApplePayErrorContactField.h */; };
     2963                A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1BB85B42159B3890067E07D /* JSMockPaymentError.cpp */; };
     2964                A1BB85B92159B3AE0067E07D /* JSMockPaymentError.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BB85B52159B38A0067E07D /* JSMockPaymentError.h */; };
    29582965                A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */; };
    29592966                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BF6B811AA96C7D00AF4A8A /* MockContentFilter.h */; };
     
    1104711054                A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockContentFilterSettings.cpp; sourceTree = "<group>"; };
    1104811055                A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockContentFilterSettings.h; sourceTree = "<group>"; };
     11056                A1BB85992159AEA10067E07D /* ApplePayErrorCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayErrorCode.h; sourceTree = "<group>"; };
     11057                A1BB859B2159AEA10067E07D /* ApplePayErrorCode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayErrorCode.idl; sourceTree = "<group>"; };
     11058                A1BB85A02159AF570067E07D /* ApplePayErrorContactField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayErrorContactField.h; sourceTree = "<group>"; };
     11059                A1BB85A22159AF570067E07D /* ApplePayErrorContactField.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayErrorContactField.idl; sourceTree = "<group>"; };
     11060                A1BB85A62159B02C0067E07D /* MockPaymentError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentError.h; sourceTree = "<group>"; };
     11061                A1BB85A82159B02C0067E07D /* MockPaymentError.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockPaymentError.idl; sourceTree = "<group>"; };
     11062                A1BB85AC2159B19F0067E07D /* JSApplePayErrorContactField.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayErrorContactField.cpp; sourceTree = "<group>"; };
     11063                A1BB85AD2159B1A00067E07D /* JSApplePayErrorCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayErrorCode.cpp; sourceTree = "<group>"; };
     11064                A1BB85AE2159B1A00067E07D /* JSApplePayErrorCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayErrorCode.h; sourceTree = "<group>"; };
     11065                A1BB85AF2159B1A00067E07D /* JSApplePayErrorContactField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayErrorContactField.h; sourceTree = "<group>"; };
     11066                A1BB85B42159B3890067E07D /* JSMockPaymentError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockPaymentError.cpp; sourceTree = "<group>"; };
     11067                A1BB85B52159B38A0067E07D /* JSMockPaymentError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockPaymentError.h; sourceTree = "<group>"; };
    1104911068                A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockContentFilter.cpp; sourceTree = "<group>"; };
    1105011069                A1BF6B811AA96C7D00AF4A8A /* MockContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockContentFilter.h; sourceTree = "<group>"; };
     
    1609616115                                1ADFDFD61E71D8DF008F5D34 /* ApplePayError.h */,
    1609716116                                1ADFDFD71E71D8DF008F5D34 /* ApplePayError.idl */,
     16117                                A1BB85992159AEA10067E07D /* ApplePayErrorCode.h */,
     16118                                A1BB859B2159AEA10067E07D /* ApplePayErrorCode.idl */,
     16119                                A1BB85A02159AF570067E07D /* ApplePayErrorContactField.h */,
     16120                                A1BB85A22159AF570067E07D /* ApplePayErrorContactField.idl */,
    1609816121                                7C6579E21E00827000E3A27A /* ApplePayLineItem.h */,
    1609916122                                7C6579E41E0082C800E3A27A /* ApplePayLineItem.idl */,
     
    1626916292                                1ADFDFE11E71DCA0008F5D34 /* JSApplePayError.cpp */,
    1627016293                                1ADFDFE21E71DCA0008F5D34 /* JSApplePayError.h */,
     16294                                A1BB85AD2159B1A00067E07D /* JSApplePayErrorCode.cpp */,
     16295                                A1BB85AE2159B1A00067E07D /* JSApplePayErrorCode.h */,
     16296                                A1BB85AC2159B19F0067E07D /* JSApplePayErrorContactField.cpp */,
     16297                                A1BB85AF2159B1A00067E07D /* JSApplePayErrorContactField.h */,
    1627116298                                7C6579E91E00856600E3A27A /* JSApplePayLineItem.cpp */,
    1627216299                                7C6579EA1E00856600E3A27A /* JSApplePayLineItem.h */,
     
    1704017067                                A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */,
    1704117068                                A146D3161F99B53D00D29196 /* MockPaymentCoordinator.idl */,
     17069                                A1BB85A62159B02C0067E07D /* MockPaymentError.h */,
     17070                                A1BB85A82159B02C0067E07D /* MockPaymentError.idl */,
    1704217071                                A1CBEF631F9F11290028DE7C /* MockPaymentMethod.h */,
    1704317072                                A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */,
     
    1708017109                                A146D3191F99BCBB00D29196 /* JSMockPaymentCoordinator.cpp */,
    1708117110                                A146D3181F99BCBA00D29196 /* JSMockPaymentCoordinator.h */,
     17111                                A1BB85B42159B3890067E07D /* JSMockPaymentError.cpp */,
     17112                                A1BB85B52159B38A0067E07D /* JSMockPaymentError.h */,
    1708217113                                427DA71B13735DFA007C57FB /* JSServiceWorkerInternals.cpp */,
    1708317114                                427DA71C13735DFA007C57FB /* JSServiceWorkerInternals.h */,
     
    2711427145                                A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
    2711527146                                A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
     27147                                A1BB85B92159B3AE0067E07D /* JSMockPaymentError.h in Headers */,
    2711627148                                427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
    2711727149                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
     
    2720827240                                A1DF5A941F7EC4320058A477 /* ApplePayContactField.h in Headers */,
    2720927241                                A12C59EE2035FC9B0012236B /* ApplePayError.h in Headers */,
     27242                                A1BB859C2159AEA10067E07D /* ApplePayErrorCode.h in Headers */,
     27243                                A1BB85A32159AF570067E07D /* ApplePayErrorContactField.h in Headers */,
    2721027244                                7C6579E31E00827000E3A27A /* ApplePayLineItem.h in Headers */,
    2721127245                                A1DF5A861F7EBDF20058A477 /* ApplePayMerchantCapability.h in Headers */,
     
    2855528589                                A1DF5A991F7EC8C00058A477 /* JSApplePayContactField.h in Headers */,
    2855628590                                A12C59F920360ACB0012236B /* JSApplePayError.h in Headers */,
     28591                                A1BB85B22159B1A10067E07D /* JSApplePayErrorCode.h in Headers */,
     28592                                A1BB85B32159B1A10067E07D /* JSApplePayErrorContactField.h in Headers */,
    2855728593                                7C6579F01E00856600E3A27A /* JSApplePayLineItem.h in Headers */,
    2855828594                                A1DF5A8E1F7EC0020058A477 /* JSApplePayMerchantCapability.h in Headers */,
     
    2961929655                                CDF2B0131820540600F2B424 /* MockMediaPlayerMediaSource.h in Headers */,
    2962029656                                CDF2B0151820540600F2B424 /* MockMediaSourcePrivate.h in Headers */,
     29657                                A1BB85A92159B02C0067E07D /* MockPaymentError.h in Headers */,
    2962129658                                07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */,
    2962229659                                4A0FFA9E1AAF5E7E0062803B /* MockRealtimeMediaSourceCenter.h in Headers */,
     
    3153731574                                A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
    3153831575                                A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
     31576                                A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */,
    3153931577                                427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
    3154031578                                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp

    r235251 r236552  
    152152void MockPaymentCoordinator::completeShippingContactSelection(std::optional<ShippingContactUpdate>&& shippingContactUpdate)
    153153{
    154     if (shippingContactUpdate)
    155         updateTotalAndLineItems(shippingContactUpdate->newTotalAndLineItems);
    156 }
    157    
     154    if (!shippingContactUpdate)
     155        return;
     156
     157    updateTotalAndLineItems(shippingContactUpdate->newTotalAndLineItems);
     158    m_errors = WTFMove(shippingContactUpdate->errors);
     159}
     160
    158161void MockPaymentCoordinator::completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&& paymentMethodUpdate)
    159162{
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.h

    r230211 r236552  
    3030#include "ApplePayLineItem.h"
    3131#include "MockPaymentAddress.h"
     32#include "MockPaymentError.h"
    3233#include "PaymentCoordinatorClient.h"
    3334#include <wtf/HashSet.h>
     
    5152    const ApplePayLineItem& total() const { return m_total; }
    5253    const Vector<ApplePayLineItem>& lineItems() const { return m_lineItems; }
     54    const Vector<MockPaymentError>& errors() const { return m_errors; }
    5355
    5456    void ref() const { }
     
    7779    ApplePayLineItem m_total;
    7880    Vector<ApplePayLineItem> m_lineItems;
     81    Vector<MockPaymentError> m_errors;
    7982    HashSet<String, ASCIICaseInsensitiveHash> m_availablePaymentNetworks;
    8083};
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.idl

    r225849 r236552  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636    readonly attribute ApplePayLineItem total;
    3737    readonly attribute sequence<ApplePayLineItem> lineItems;
     38    readonly attribute sequence<MockPaymentError> errors;
    3839};
  • trunk/Source/WebCore/testing/MockPaymentError.h

    r236551 r236552  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 [
    27     Conditional=PAYMENT_REQUEST
    28 ] dictionary PaymentDetailsUpdate : PaymentDetailsBase {
    29     DOMString error;
    30     PaymentItem total;
    31 };
     26#pragma once
     27
     28#if ENABLE(APPLE_PAY)
     29
     30#include "ApplePaySessionPaymentRequest.h"
     31
     32namespace WebCore {
     33
     34using MockPaymentError = PaymentError;
     35
     36} // namespace WebCore
     37
     38#endif // ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/testing/MockPaymentError.idl

    r236551 r236552  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626[
    27     Conditional=PAYMENT_REQUEST
    28 ] dictionary PaymentDetailsUpdate : PaymentDetailsBase {
    29     DOMString error;
    30     PaymentItem total;
     27    Conditional=APPLE_PAY,
     28    JSGenerateToJSObject,
     29] dictionary MockPaymentError {
     30    required ApplePayErrorCode code;
     31    required DOMString message;
     32    ApplePayErrorContactField contactField;
    3133};
Note: See TracChangeset for help on using the changeset viewer.