Changeset 241105 in webkit


Ignore:
Timestamp:
Feb 6, 2019 3:18:07 PM (5 years ago)
Author:
aestes@apple.com
Message:

[Payment Request] It should be possible to require a phonetic name for shipping contacts
https://bugs.webkit.org/show_bug.cgi?id=194311
<rdar://46733045>

Reviewed by Alex Christensen.

Source/WebCore:

It should be possible to require that a shipping contact has a phonetic name in Payment Request.
To accomplish this, move requiredShippingContactFields from ApplePayPaymentRequest to
ApplePayRequestBase so that it can be used as part of an Apple Pay payment method data.

Since required shipping contact fields can now be specified both in
requiredShippingContactFields and PaymentOptions, we merge the required fields from these
two sources such that, e.g., email is required if it is specified in either place.

So that clients can detect this new feature, the API version number is bumped from 5 to 6.

Added test cases to ApplePayRequestShippingContact.https.html and ApplePayRequestShippingContactV3.https.html.

  • DerivedSources.make:
  • Modules/applepay/ApplePayPaymentRequest.h:
  • Modules/applepay/ApplePayPaymentRequest.idl:
  • Modules/applepay/ApplePayRequestBase.cpp:

(WebCore::convertAndValidate):

  • Modules/applepay/ApplePayRequestBase.h:
  • Modules/applepay/ApplePayRequestBase.idl:
  • Modules/applepay/ApplePaySession.cpp:

(WebCore::convertAndValidate):

  • Modules/applepay/PaymentCoordinatorClient.cpp: Added.

(WebCore::PaymentCoordinatorClient::supportsVersion):

  • Modules/applepay/PaymentCoordinatorClient.h:
  • Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:

(WebCore::mergePaymentOptions):
(WebCore::ApplePayPaymentHandler::show):

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • loader/EmptyClients.cpp:
  • testing/MockPaymentContactFields.h: Added.

(WebCore::MockPaymentContactFields::MockPaymentContactFields):

  • testing/MockPaymentContactFields.idl: Added.
  • testing/MockPaymentCoordinator.cpp:

(WebCore::MockPaymentCoordinator::showPaymentUI):
(WebCore::MockPaymentCoordinator::supportsVersion): Deleted.

  • testing/MockPaymentCoordinator.h:
  • testing/MockPaymentCoordinator.idl:

Source/WebKit:

  • WebProcess/ApplePay/WebPaymentCoordinator.cpp:

(WebKit::WebPaymentCoordinator::supportsVersion): Deleted.

  • WebProcess/ApplePay/WebPaymentCoordinator.h:

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebPaymentCoordinatorClient.h:
  • WebCoreSupport/WebPaymentCoordinatorClient.mm:

(WebPaymentCoordinatorClient::supportsVersion): Deleted.

LayoutTests:

  • http/tests/ssl/applepay/ApplePayRequestShippingContact.https-expected.txt:
  • http/tests/ssl/applepay/ApplePayRequestShippingContact.https.html:
  • http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https-expected.txt:
  • http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html:
  • http/tests/ssl/applepay/PaymentRequest.https-expected.txt:
  • http/tests/ssl/applepay/PaymentRequest.https.html:
Location:
trunk
Files:
29 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r241104 r241105  
     12019-02-06  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] It should be possible to require a phonetic name for shipping contacts
     4        https://bugs.webkit.org/show_bug.cgi?id=194311
     5        <rdar://46733045>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/tests/ssl/applepay/ApplePayRequestShippingContact.https-expected.txt:
     10        * http/tests/ssl/applepay/ApplePayRequestShippingContact.https.html:
     11        * http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https-expected.txt:
     12        * http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html:
     13        * http/tests/ssl/applepay/PaymentRequest.https-expected.txt:
     14        * http/tests/ssl/applepay/PaymentRequest.https.html:
     15
    1162019-02-06  Yusuke Suzuki  <ysuzuki@apple.com>
    217
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContact.https-expected.txt

    r235607 r241105  
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
     5
     6Test setting required contact fields in a version 2 request.
     7PASS internals.mockPaymentCoordinator.requiredBillingContactFields.name is true
     8PASS internals.mockPaymentCoordinator.requiredBillingContactFields.email is false
     9PASS internals.mockPaymentCoordinator.requiredBillingContactFields.phone is false
     10PASS internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress is true
     11PASS internals.mockPaymentCoordinator.requiredShippingContactFields.name is true
     12PASS internals.mockPaymentCoordinator.requiredShippingContactFields.email is true
     13PASS internals.mockPaymentCoordinator.requiredShippingContactFields.phone is false
     14PASS internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress is true
    515
    616Test setting a default shipping contact in a version 2 request.
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContact.https.html

    r235607 r241105  
    8484async function runTests() {
    8585    await new Promise((resolve, reject) => {
     86        debug("Test setting required contact fields in a version 2 request.");
     87
     88        var paymentMethod = validPaymentMethod(2, validShippingContact());
     89        paymentMethod.data.requiredBillingContactFields = ["name", "postalAddress"];
     90        paymentMethod.data.requiredShippingContactFields = ["email"];
     91
     92        var paymentOptions = validPaymentOptions();
     93        paymentOptions.requestPayerEmail = false;
     94        paymentOptions.requestPayerPhone = false;
     95
     96        var paymentRequest = new PaymentRequest([paymentMethod], validPaymentDetails(), paymentOptions);
     97
     98        activateThen(() => {
     99            paymentRequest.show().then((response) => {
     100                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.name", "true");
     101                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.email", "false");
     102                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.phone", "false");
     103                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress", "true");
     104
     105                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.name", "true");
     106                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.email", "true");
     107                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.phone", "false");
     108                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress", "true");
     109
     110                response.complete("success");
     111                resolve();
     112            });
     113
     114            internals.mockPaymentCoordinator.acceptPayment();
     115        });
     116    });
     117    debug("");
     118
     119    await new Promise((resolve, reject) => {
    86120        debug("Test setting a default shipping contact in a version 2 request.");
    87121
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https-expected.txt

    r227260 r241105  
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
     5
     6Test setting required contact fields in a version 3 request.
     7PASS internals.mockPaymentCoordinator.requiredBillingContactFields.name is false
     8PASS internals.mockPaymentCoordinator.requiredBillingContactFields.phoneticName is false
     9PASS internals.mockPaymentCoordinator.requiredBillingContactFields.email is false
     10PASS internals.mockPaymentCoordinator.requiredBillingContactFields.phone is false
     11PASS internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress is false
     12PASS internals.mockPaymentCoordinator.requiredShippingContactFields.name is true
     13PASS internals.mockPaymentCoordinator.requiredShippingContactFields.phoneticName is true
     14PASS internals.mockPaymentCoordinator.requiredShippingContactFields.email is true
     15PASS internals.mockPaymentCoordinator.requiredShippingContactFields.phone is true
     16PASS internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress is true
    517
    618Test setting a default shipping contact in a version 3 request.
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html

    r227260 r241105  
    8484async function runTests() {
    8585    await new Promise((resolve, reject) => {
     86        debug("Test setting required contact fields in a version 3 request.");
     87
     88        var paymentMethod = validPaymentMethod(3, validShippingContact());
     89        paymentMethod.data.requiredShippingContactFields = ["phoneticName"];
     90
     91        var paymentRequest = new PaymentRequest([paymentMethod], validPaymentDetails(), validPaymentOptions());
     92
     93        activateThen(() => {
     94            paymentRequest.show().then((response) => {
     95                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.name", "false");
     96                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.phoneticName", "false");
     97                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.email", "false");
     98                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.phone", "false");
     99                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress", "false");
     100
     101                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.name", "true");
     102                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.phoneticName", "true");
     103                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.email", "true");
     104                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.phone", "true");
     105                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress", "true");
     106
     107                response.complete("success");
     108                resolve();
     109            });
     110
     111            internals.mockPaymentCoordinator.acceptPayment();
     112        });
     113    });
     114    debug("");
     115
     116    await new Promise((resolve, reject) => {
    86117        debug("Test setting a default shipping contact in a version 3 request.");
    87118
  • trunk/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt

    r235342 r241105  
    125125PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with InvalidStateError: The object is in an invalid state..
    126126
     127Testing ApplePayRequest.requiredShippingContactFields
     128
     129SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = '';
     130PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Value is not a sequence.
     131
     132SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = null;
     133PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Value is not a sequence.
     134
     135SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = 7;
     136PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Value is not a sequence.
     137
     138SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = { };
     139PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
     140
     141SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [''];
     142PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
     143
     144SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [null];
     145PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
     146
     147SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [undefined];
     148PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
     149
     150SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [{}];
     151PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
     152
     153SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = ['invalid'];
     154PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
     155
     156Testing ApplePayRequest.shippingContact
     157
     158SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = '';
     159PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with InvalidStateError: The object is in an invalid state..
     160
     161SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = 7;
     162PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with InvalidStateError: The object is in an invalid state..
     163
    127164Testing ApplePayRequest.applicationData
    128165
  • trunk/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html

    r235342 r241105  
    142142    debug("")
    143143    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.billingContact = 7;", "new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     144    debug("")
     145
     146    debug("Testing ApplePayRequest.requiredShippingContactFields")
     147    debug("")
     148    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = '';", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     149    debug("")
     150    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = null;", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     151    debug("")
     152    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = 7;", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     153    debug("")
     154    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = { };", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     155    debug("")
     156    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [''];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     157    debug("")
     158    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [null];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     159    debug("")
     160    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [undefined];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     161    debug("")
     162    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [{}];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     163    debug("")
     164    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = ['invalid'];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     165    debug("")
     166
     167    debug("Testing ApplePayRequest.shippingContact")
     168    debug("")
     169    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = '';", "new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     170    debug("")
     171    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = 7;", "new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
    144172    debug("")
    145173   
  • trunk/Source/WebCore/ChangeLog

    r241104 r241105  
     12019-02-06  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] It should be possible to require a phonetic name for shipping contacts
     4        https://bugs.webkit.org/show_bug.cgi?id=194311
     5        <rdar://46733045>
     6
     7        Reviewed by Alex Christensen.
     8
     9        It should be possible to require that a shipping contact has a phonetic name in Payment Request.
     10        To accomplish this, move requiredShippingContactFields from ApplePayPaymentRequest to
     11        ApplePayRequestBase so that it can be used as part of an Apple Pay payment method data.
     12
     13        Since required shipping contact fields can now be specified both in
     14        requiredShippingContactFields and PaymentOptions, we merge the required fields from these
     15        two sources such that, e.g., email is required if it is specified in either place.
     16
     17        So that clients can detect this new feature, the API version number is bumped from 5 to 6.
     18
     19        Added test cases to ApplePayRequestShippingContact.https.html and ApplePayRequestShippingContactV3.https.html.
     20
     21        * DerivedSources.make:
     22        * Modules/applepay/ApplePayPaymentRequest.h:
     23        * Modules/applepay/ApplePayPaymentRequest.idl:
     24        * Modules/applepay/ApplePayRequestBase.cpp:
     25        (WebCore::convertAndValidate):
     26        * Modules/applepay/ApplePayRequestBase.h:
     27        * Modules/applepay/ApplePayRequestBase.idl:
     28        * Modules/applepay/ApplePaySession.cpp:
     29        (WebCore::convertAndValidate):
     30        * Modules/applepay/PaymentCoordinatorClient.cpp: Added.
     31        (WebCore::PaymentCoordinatorClient::supportsVersion):
     32        * Modules/applepay/PaymentCoordinatorClient.h:
     33        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
     34        (WebCore::mergePaymentOptions):
     35        (WebCore::ApplePayPaymentHandler::show):
     36        * SourcesCocoa.txt:
     37        * WebCore.xcodeproj/project.pbxproj:
     38        * loader/EmptyClients.cpp:
     39        * testing/MockPaymentContactFields.h: Added.
     40        (WebCore::MockPaymentContactFields::MockPaymentContactFields):
     41        * testing/MockPaymentContactFields.idl: Added.
     42        * testing/MockPaymentCoordinator.cpp:
     43        (WebCore::MockPaymentCoordinator::showPaymentUI):
     44        (WebCore::MockPaymentCoordinator::supportsVersion): Deleted.
     45        * testing/MockPaymentCoordinator.h:
     46        * testing/MockPaymentCoordinator.idl:
     47
    1482019-02-06  Yusuke Suzuki  <ysuzuki@apple.com>
    249
  • trunk/Source/WebCore/DerivedSources.make

    r241048 r241105  
    10551055    $(WebCore)/testing/MockPageOverlay.idl \
    10561056    $(WebCore)/testing/MockPaymentAddress.idl \
     1057    $(WebCore)/testing/MockPaymentContactFields.idl \
    10571058    $(WebCore)/testing/MockPaymentCoordinator.idl \
    10581059    $(WebCore)/testing/MockPaymentError.idl \
  • trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h

    r239427 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141    String currencyCode;
    4242
    43     Optional<Vector<ApplePayContactField>> requiredShippingContactFields;
    44 
    4543    ShippingType shippingType { ShippingType::Shipping };
    4644    Optional<Vector<ApplePayShippingMethod>> shippingMethods;
  • trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl

    r227140 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141    required DOMString currencyCode;
    4242
    43     sequence<ApplePayContactField> requiredShippingContactFields;
    44 
    4543    ApplePayShippingType shippingType = "shipping";
    4644    sequence<ApplePayShippingMethod> shippingMethods;
  • trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp

    r235494 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7979    if (request.billingContact)
    8080        result.setBillingContact(PaymentContact::fromApplePayPaymentContact(version, *request.billingContact));
     81   
     82    if (request.requiredShippingContactFields) {
     83        auto requiredShippingContactFields = convertAndValidate(version, *request.requiredShippingContactFields);
     84        if (requiredShippingContactFields.hasException())
     85            return requiredShippingContactFields.releaseException();
     86        result.setRequiredShippingContactFields(requiredShippingContactFields.releaseReturnValue());
     87    }
    8188
    8289    if (request.shippingContact)
  • trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.h

    r239427 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444    Optional<ApplePayPaymentContact> billingContact;
    4545
     46    Optional<Vector<ApplePayContactField>> requiredShippingContactFields;
    4647    Optional<ApplePayPaymentContact> shippingContact;
    4748
  • trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.idl

    r227140 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434    ApplePayPaymentContact billingContact;
    3535
     36    sequence<ApplePayContactField> requiredShippingContactFields;
    3637    ApplePayPaymentContact shippingContact;
    3738
  • trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp

    r240237 r241105  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    228228    result.setLineItems(lineItems.releaseReturnValue());
    229229
    230     if (paymentRequest.requiredShippingContactFields) {
    231         auto requiredShippingContactFields = convertAndValidate(version, WTFMove(*paymentRequest.requiredShippingContactFields));
    232         if (requiredShippingContactFields.hasException())
    233             return requiredShippingContactFields.releaseException();
    234         result.setRequiredShippingContactFields(requiredShippingContactFields.releaseReturnValue());
    235     }
    236 
    237230    result.setShippingType(paymentRequest.shippingType);
    238231
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.cpp

    r241104 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 [
    27     Conditional=APPLE_PAY,
    28 ] enum ApplePayShippingType {
    29     "shipping",
    30     "delivery",
    31     "storePickup",
    32     "servicePickup"
    33 };
     26#include "config.h"
     27#include "PaymentCoordinatorClient.h"
    3428
    35 [
    36     Conditional=APPLE_PAY,
    37 ] dictionary ApplePayPaymentRequest : ApplePayRequestBase {
    38     required ApplePayLineItem total;
    39     sequence<ApplePayLineItem> lineItems;
     29#if ENABLE(APPLE_PAY)
    4030
    41     required DOMString currencyCode;
     31namespace WebCore {
    4232
    43     sequence<ApplePayContactField> requiredShippingContactFields;
     33bool PaymentCoordinatorClient::supportsVersion(unsigned version)
     34{
     35    ASSERT(version > 0);
    4436
    45     ApplePayShippingType shippingType = "shipping";
    46     sequence<ApplePayShippingMethod> shippingMethods;
    47 };
     37#if !ENABLE(APPLE_PAY_SESSION_V3)
     38    static const unsigned currentVersion = 2;
     39#elif !ENABLE(APPLE_PAY_SESSION_V4)
     40    static const unsigned currentVersion = 3;
     41#else
     42    static const unsigned currentVersion = 6;
     43#endif
     44
     45    return version <= currentVersion;
     46}
     47
     48} // namespace WebCore
     49
     50#endif // ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h

    r239427 r241105  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4646class PaymentCoordinatorClient {
    4747public:
    48     virtual bool supportsVersion(unsigned version) = 0;
     48    bool supportsVersion(unsigned version);
     49
    4950    virtual Optional<String> validatedPaymentNetwork(const String&) = 0;
    5051    virtual bool canMakePayments() = 0;
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp

    r239461 r241105  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    130130}
    131131
    132 static ApplePaySessionPaymentRequest::ContactFields convert(const PaymentOptions& options)
    133 {
    134     ApplePaySessionPaymentRequest::ContactFields result;
    135     result.email = options.requestPayerEmail;
    136     result.name = options.requestPayerName;
    137     result.phone = options.requestPayerPhone;
    138     result.postalAddress = options.requestShipping;
    139     return result;
    140 }
    141 
    142132static ApplePaySessionPaymentRequest::ShippingType convert(PaymentShippingType type)
    143133{
     
    183173}
    184174
     175static void mergePaymentOptions(const PaymentOptions& options, ApplePaySessionPaymentRequest& request)
     176{
     177    auto requiredShippingContactFields = request.requiredShippingContactFields();
     178    requiredShippingContactFields.email |= options.requestPayerEmail;
     179    requiredShippingContactFields.name |= options.requestPayerName;
     180    requiredShippingContactFields.phone |= options.requestPayerPhone;
     181    requiredShippingContactFields.postalAddress |= options.requestShipping;
     182    request.setRequiredShippingContactFields(requiredShippingContactFields);
     183
     184    if (options.requestShipping)
     185        request.setShippingType(convert(options.shippingType));
     186}
     187
    185188ExceptionOr<void> ApplePayPaymentHandler::show()
    186189{
     
    204207    request.setLineItems(convertedLineItems.releaseReturnValue());
    205208
    206     request.setRequiredShippingContactFields(convert(m_paymentRequest->paymentOptions()));
    207     if (m_paymentRequest->paymentOptions().requestShipping)
    208         request.setShippingType(convert(m_paymentRequest->paymentOptions().shippingType));
     209    mergePaymentOptions(m_paymentRequest->paymentOptions(), request);
    209210
    210211    auto shippingMethods = computeShippingMethods();
  • trunk/Source/WebCore/SourcesCocoa.txt

    r240963 r241105  
    1 // Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     1// Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    22//
    33// Redistribution and use in source and binary forms, with or without
     
    589589    Modules/applepay/ApplePayValidateMerchantEvent.cpp
    590590    Modules/applepay/PaymentCoordinator.cpp
     591    Modules/applepay/PaymentCoordinatorClient.cpp
    591592    Modules/applepay/PaymentRequestValidator.mm
    592593    Modules/applepay/PaymentSession.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r241048 r241105  
    29432943                A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0EE0DF3144F825500F80B0D /* WebGLDebugShaders.cpp */; };
    29442944                A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = A0EE0DF4144F825500F80B0D /* WebGLDebugShaders.h */; };
     2945                A104EC5A220A3DE000CBF67A /* MockPaymentContactFields.h in Headers */ = {isa = PBXBuildFile; fileRef = A104EC55220A39B400CBF67A /* MockPaymentContactFields.h */; };
     2946                A104EC5D220A3E4B00CBF67A /* JSMockPaymentContactFields.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */; };
     2947                A104EC5E220A3E4E00CBF67A /* JSMockPaymentContactFields.h in Headers */ = {isa = PBXBuildFile; fileRef = A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */; };
    29452948                A104F24414C71F7A009E2C23 /* CachedSVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
    29462949                A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* RenderSVGRect.h */; };
     
    1114011143                A0EE0DF3144F825500F80B0D /* WebGLDebugShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLDebugShaders.cpp; sourceTree = "<group>"; };
    1114111144                A0EE0DF4144F825500F80B0D /* WebGLDebugShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLDebugShaders.h; sourceTree = "<group>"; };
     11145                A104EC53220A017400CBF67A /* PaymentCoordinatorClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PaymentCoordinatorClient.cpp; sourceTree = "<group>"; };
     11146                A104EC55220A39B400CBF67A /* MockPaymentContactFields.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentContactFields.h; sourceTree = "<group>"; };
     11147                A104EC57220A39B400CBF67A /* MockPaymentContactFields.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockPaymentContactFields.idl; sourceTree = "<group>"; };
     11148                A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockPaymentContactFields.cpp; sourceTree = "<group>"; };
     11149                A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSMockPaymentContactFields.h; sourceTree = "<group>"; };
    1114211150                A104F24114C71F7A009E2C23 /* CachedSVGDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedSVGDocument.cpp; sourceTree = "<group>"; };
    1114311151                A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGDocument.h; sourceTree = "<group>"; };
     
    1675516763                                1A58E86B1D19E42D00C0EA73 /* PaymentCoordinator.cpp */,
    1675616764                                1A58E86C1D19E42D00C0EA73 /* PaymentCoordinator.h */,
     16765                                A104EC53220A017400CBF67A /* PaymentCoordinatorClient.cpp */,
    1675716766                                1A58E8621D19D3BF00C0EA73 /* PaymentCoordinatorClient.h */,
    1675816767                                7CF930E61E01F9AD00BAFFBE /* PaymentHeaders.h */,
     
    1786117870                                A146D31E1F99C9C200D29196 /* MockPaymentAddress.idl */,
    1786217871                                A146D3241F99D69800D29196 /* MockPaymentContact.h */,
     17872                                A104EC55220A39B400CBF67A /* MockPaymentContactFields.h */,
     17873                                A104EC57220A39B400CBF67A /* MockPaymentContactFields.idl */,
    1786317874                                A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */,
    1786417875                                A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */,
     
    1790217913                                A146D3201F99CA3E00D29196 /* JSMockPaymentAddress.cpp */,
    1790317914                                A146D31F1F99CA3D00D29196 /* JSMockPaymentAddress.h */,
     17915                                A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */,
     17916                                A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */,
    1790417917                                A146D3191F99BCBB00D29196 /* JSMockPaymentCoordinator.cpp */,
    1790517918                                A146D3181F99BCBA00D29196 /* JSMockPaymentCoordinator.h */,
     
    2826428277                                538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */,
    2826528278                                A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
     28279                                A104EC5E220A3E4E00CBF67A /* JSMockPaymentContactFields.h in Headers */,
    2826628280                                A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
    2826728281                                A1BB85B92159B3AE0067E07D /* JSMockPaymentError.h in Headers */,
     
    2827928293                                A146D3211F99CB1A00D29196 /* MockPaymentAddress.h in Headers */,
    2828028294                                A146D3251F99D69800D29196 /* MockPaymentContact.h in Headers */,
     28295                                A104EC5A220A3DE000CBF67A /* MockPaymentContactFields.h in Headers */,
    2828128296                                A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */,
    2828228297                                A1CBEF641F9F11290028DE7C /* MockPaymentMethod.h in Headers */,
     
    3283832853                                2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
    3283932854                                A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
     32855                                A104EC5D220A3E4B00CBF67A /* JSMockPaymentContactFields.cpp in Sources */,
    3284032856                                A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
    3284132857                                A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */,
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r240909 r241105  
    11/*
    22 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
    3  * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
     3 * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
    44 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    55 *
     
    313313
    314314class EmptyPaymentCoordinatorClient final : public PaymentCoordinatorClient {
    315     bool supportsVersion(unsigned) final { return false; }
    316315    Optional<String> validatedPaymentNetwork(const String&) final { return WTF::nullopt; }
    317316    bool canMakePayments() final { return false; }
  • trunk/Source/WebCore/testing/MockPaymentContactFields.h

    r241104 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 [
    27     Conditional=APPLE_PAY,
    28 ] enum ApplePayShippingType {
    29     "shipping",
    30     "delivery",
    31     "storePickup",
    32     "servicePickup"
     26#pragma once
     27
     28#if ENABLE(APPLE_PAY)
     29
     30#include "ApplePaySessionPaymentRequest.h"
     31
     32namespace WebCore {
     33
     34struct MockPaymentContactFields : public ApplePaySessionPaymentRequest::ContactFields {
     35    MockPaymentContactFields() = default;
     36    MockPaymentContactFields(const ApplePaySessionPaymentRequest::ContactFields& contactFields)
     37        : ApplePaySessionPaymentRequest::ContactFields { contactFields }
     38    {
     39    }
    3340};
    3441
    35 [
    36     Conditional=APPLE_PAY,
    37 ] dictionary ApplePayPaymentRequest : ApplePayRequestBase {
    38     required ApplePayLineItem total;
    39     sequence<ApplePayLineItem> lineItems;
     42} // namespace WebCore
    4043
    41     required DOMString currencyCode;
    42 
    43     sequence<ApplePayContactField> requiredShippingContactFields;
    44 
    45     ApplePayShippingType shippingType = "shipping";
    46     sequence<ApplePayShippingMethod> shippingMethods;
    47 };
     44#endif // ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/testing/MockPaymentContactFields.idl

    r241104 r241105  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626[
    2727    Conditional=APPLE_PAY,
    28 ] enum ApplePayShippingType {
    29     "shipping",
    30     "delivery",
    31     "storePickup",
    32     "servicePickup"
     28    JSGenerateToJSObject,
     29] dictionary MockPaymentContactFields {
     30    boolean postalAddress = false;
     31    boolean phone = false;
     32    boolean email = false;
     33    boolean name = false;
     34    boolean phoneticName = false;
    3335};
    34 
    35 [
    36     Conditional=APPLE_PAY,
    37 ] dictionary ApplePayPaymentRequest : ApplePayRequestBase {
    38     required ApplePayLineItem total;
    39     sequence<ApplePayLineItem> lineItems;
    40 
    41     required DOMString currencyCode;
    42 
    43     sequence<ApplePayContactField> requiredShippingContactFields;
    44 
    45     ApplePayShippingType shippingType = "shipping";
    46     sequence<ApplePayShippingMethod> shippingMethods;
    47 };
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp

    r239427 r241105  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5454}
    5555
    56 bool MockPaymentCoordinator::supportsVersion(unsigned version)
    57 {
    58     ASSERT(version > 0);
    59 
    60 #if !ENABLE(APPLE_PAY_SESSION_V3)
    61     static const unsigned currentVersion = 2;
    62 #elif !ENABLE(APPLE_PAY_SESSION_V4)
    63     static const unsigned currentVersion = 3;
    64 #else
    65     static const unsigned currentVersion = 5;
    66 #endif
    67 
    68     return version <= currentVersion;
    69 }
    70 
    7156Optional<String> MockPaymentCoordinator::validatedPaymentNetwork(const String& paymentNetwork)
    7257{
     
    120105        m_shippingAddress = request.shippingContact().toApplePayPaymentContact(request.version());
    121106    m_shippingMethods = convert(request.shippingMethods());
     107    m_requiredBillingContactFields = request.requiredBillingContactFields();
     108    m_requiredShippingContactFields = request.requiredShippingContactFields();
    122109
    123110    ASSERT(showCount == hideCount);
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.h

    r239427 r241105  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include "ApplePayShippingMethod.h"
    3232#include "MockPaymentAddress.h"
     33#include "MockPaymentContactFields.h"
    3334#include "MockPaymentError.h"
    3435#include "PaymentCoordinatorClient.h"
     
    5758    const Vector<MockPaymentError>& errors() const { return m_errors; }
    5859    const Vector<ApplePayShippingMethod>& shippingMethods() const { return m_shippingMethods; }
     60    const MockPaymentContactFields& requiredBillingContactFields() const { return m_requiredBillingContactFields; }
     61    const MockPaymentContactFields& requiredShippingContactFields() const { return m_requiredShippingContactFields; }
    5962
    6063    void ref() const { }
     
    6265
    6366private:
    64     bool supportsVersion(unsigned) final;
    6567    Optional<String> validatedPaymentNetwork(const String&) final;
    6668    bool canMakePayments() final;
     
    9092    Vector<ApplePayShippingMethod> m_shippingMethods;
    9193    HashSet<String, ASCIICaseInsensitiveHash> m_availablePaymentNetworks;
     94    MockPaymentContactFields m_requiredBillingContactFields;
     95    MockPaymentContactFields m_requiredShippingContactFields;
    9296};
    9397
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.idl

    r237594 r241105  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040    readonly attribute sequence<MockPaymentError> errors;
    4141    readonly attribute sequence<ApplePayShippingMethod> shippingMethods;
     42    readonly attribute MockPaymentContactFields requiredBillingContactFields;
     43    readonly attribute MockPaymentContactFields requiredShippingContactFields;
    4244};
  • trunk/Source/WebKit/ChangeLog

    r241103 r241105  
     12019-02-06  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] It should be possible to require a phonetic name for shipping contacts
     4        https://bugs.webkit.org/show_bug.cgi?id=194311
     5        <rdar://46733045>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
     10        (WebKit::WebPaymentCoordinator::supportsVersion): Deleted.
     11        * WebProcess/ApplePay/WebPaymentCoordinator.h:
     12
    1132019-02-06  Keith Rollin  <krollin@apple.com>
    214
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp

    r239427 r241105  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5252}
    5353
    54 bool WebPaymentCoordinator::supportsVersion(unsigned version)
    55 {
    56     ASSERT(version > 0);
    57 
    58 #if !ENABLE(APPLE_PAY_SESSION_V3)
    59     static const unsigned currentVersion = 2;
    60 #elif !ENABLE(APPLE_PAY_SESSION_V4)
    61     static const unsigned currentVersion = 3;
    62 #else
    63     static const unsigned currentVersion = 5;
    64 #endif
    65 
    66     return version <= currentVersion;
    67 }
    68 
    6954const WebPaymentCoordinator::AvailablePaymentNetworksSet& WebPaymentCoordinator::availablePaymentNetworks()
    7055{
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h

    r239427 r241105  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5656private:
    5757    // WebCore::PaymentCoordinatorClient.
    58     bool supportsVersion(unsigned version) override;
    5958    Optional<String> validatedPaymentNetwork(const String&) override;
    6059    bool canMakePayments() override;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r240949 r241105  
     12019-02-06  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] It should be possible to require a phonetic name for shipping contacts
     4        https://bugs.webkit.org/show_bug.cgi?id=194311
     5        <rdar://46733045>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebCoreSupport/WebPaymentCoordinatorClient.h:
     10        * WebCoreSupport/WebPaymentCoordinatorClient.mm:
     11        (WebPaymentCoordinatorClient::supportsVersion): Deleted.
     12
    1132019-02-04  Said Abou-Hallawa  <said@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h

    r239427 r241105  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737    ~WebPaymentCoordinatorClient();
    3838
    39     bool supportsVersion(unsigned) override;
    4039    Optional<String> validatedPaymentNetwork(const String&) override;
    4140    bool canMakePayments() override;
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm

    r239427 r241105  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737WebPaymentCoordinatorClient::~WebPaymentCoordinatorClient()
    3838{
    39 }
    40 
    41 bool WebPaymentCoordinatorClient::supportsVersion(unsigned)
    42 {
    43     return false;
    4439}
    4540
Note: See TracChangeset for help on using the changeset viewer.