[Payment Request] It should be possible to require a phonetic name for shipping contacts
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Feb 2019 23:18:07 +0000 (23:18 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Feb 2019 23:18:07 +0000 (23:18 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241105 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContact.https-expected.txt
LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContact.https.html
LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https-expected.txt
LayoutTests/http/tests/ssl/applepay/ApplePayRequestShippingContactV3.https.html
LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt
LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h
Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl
Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp
Source/WebCore/Modules/applepay/ApplePayRequestBase.h
Source/WebCore/Modules/applepay/ApplePayRequestBase.idl
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/applepay/PaymentCoordinatorClient.cpp [new file with mode: 0644]
Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/testing/MockPaymentContactFields.h [new file with mode: 0644]
Source/WebCore/testing/MockPaymentContactFields.idl [new file with mode: 0644]
Source/WebCore/testing/MockPaymentCoordinator.cpp
Source/WebCore/testing/MockPaymentCoordinator.h
Source/WebCore/testing/MockPaymentCoordinator.idl
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm

index ca65763..d0fda69 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-06  Andy Estes  <aestes@apple.com>
+
+        [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.
+
+        * 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:
+
 2019-02-06  Yusuke Suzuki  <ysuzuki@apple.com>
 
         [JSC] PrivateName to PublicName hash table is wasteful
index 2e87a3c..b364332 100644 (file)
@@ -3,6 +3,16 @@ Test ApplePayRequest.shippingContact.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+Test setting required contact fields in a version 2 request.
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.name is true
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.email is false
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.phone is false
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.name is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.email is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.phone is false
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress is true
+
 Test setting a default shipping contact in a version 2 request.
 PASS paymentResponse.details.shippingContact.phoneNumber is expectedPhoneNumber
 PASS paymentResponse.details.shippingContact.emailAddress is expectedEmailAddress
index 33e2089..957bf43 100644 (file)
@@ -83,6 +83,40 @@ function validPaymentOptions() {
 
 async function runTests() {
     await new Promise((resolve, reject) => {
+        debug("Test setting required contact fields in a version 2 request.");
+
+        var paymentMethod = validPaymentMethod(2, validShippingContact());
+        paymentMethod.data.requiredBillingContactFields = ["name", "postalAddress"];
+        paymentMethod.data.requiredShippingContactFields = ["email"];
+
+        var paymentOptions = validPaymentOptions();
+        paymentOptions.requestPayerEmail = false;
+        paymentOptions.requestPayerPhone = false;
+
+        var paymentRequest = new PaymentRequest([paymentMethod], validPaymentDetails(), paymentOptions);
+
+        activateThen(() => {
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.name", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.email", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.phone", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress", "true");
+
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.name", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.email", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.phone", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress", "true");
+
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.acceptPayment();
+        });
+    });
+    debug("");
+
+    await new Promise((resolve, reject) => {
         debug("Test setting a default shipping contact in a version 2 request.");
 
         var paymentRequest = new PaymentRequest([validPaymentMethod(2, validShippingContact())], validPaymentDetails(), validPaymentOptions());
index 00bf674..f557137 100644 (file)
@@ -3,6 +3,18 @@ Test ApplePayRequest.shippingContact.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+Test setting required contact fields in a version 3 request.
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.name is false
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.phoneticName is false
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.email is false
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.phone is false
+PASS internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress is false
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.name is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.phoneticName is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.email is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.phone is true
+PASS internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress is true
+
 Test setting a default shipping contact in a version 3 request.
 PASS paymentResponse.details.shippingContact.phoneticGivenName is expectedGivenName
 PASS paymentResponse.details.shippingContact.phoneticFamilyName is expectedFamilyName
index da7184c..78535f1 100644 (file)
@@ -83,6 +83,37 @@ function validPaymentOptions() {
 
 async function runTests() {
     await new Promise((resolve, reject) => {
+        debug("Test setting required contact fields in a version 3 request.");
+
+        var paymentMethod = validPaymentMethod(3, validShippingContact());
+        paymentMethod.data.requiredShippingContactFields = ["phoneticName"];
+
+        var paymentRequest = new PaymentRequest([paymentMethod], validPaymentDetails(), validPaymentOptions());
+
+        activateThen(() => {
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.name", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.phoneticName", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.email", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.phone", "false");
+                shouldBe("internals.mockPaymentCoordinator.requiredBillingContactFields.postalAddress", "false");
+
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.name", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.phoneticName", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.email", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.phone", "true");
+                shouldBe("internals.mockPaymentCoordinator.requiredShippingContactFields.postalAddress", "true");
+
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.acceptPayment();
+        });
+    });
+    debug("");
+
+    await new Promise((resolve, reject) => {
         debug("Test setting a default shipping contact in a version 3 request.");
 
         var paymentRequest = new PaymentRequest([validPaymentMethod(3, validShippingContact())], validPaymentDetails(), validPaymentOptions());
index f26c868..c9c4b0e 100644 (file)
@@ -124,6 +124,43 @@ PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()
 SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.billingContact = 7;
 PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with InvalidStateError: The object is in an invalid state..
 
+Testing ApplePayRequest.requiredShippingContactFields
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = '';
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Value is not a sequence.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = null;
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Value is not a sequence.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = 7;
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Value is not a sequence.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = { };
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [''];
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [null];
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [undefined];
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [{}];
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = ['invalid'];
+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with TypeError: Type error.
+
+Testing ApplePayRequest.shippingContact
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = '';
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with InvalidStateError: The object is in an invalid state..
+
+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = 7;
+PASS new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise  with InvalidStateError: The object is in an invalid state..
+
 Testing ApplePayRequest.applicationData
 
 SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.applicationData = { toString: function() { throw '"Error in toString"'; } };
index 9482523..9e979e9 100644 (file)
@@ -142,6 +142,34 @@ async function go() {
     debug("")
     await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.billingContact = 7;", "new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
     debug("")
+
+    debug("Testing ApplePayRequest.requiredShippingContactFields")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = '';", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = null;", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = 7;", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = { };", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [''];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [null];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [undefined];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = [{}];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.requiredShippingContactFields = ['invalid'];", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+
+    debug("Testing ApplePayRequest.shippingContact")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = '';", "new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
+    await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.shippingContact = 7;", "new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()")
+    debug("")
     
     debug("Testing ApplePayRequest.applicationData")
     debug("")
index 7778c32..1770e4b 100644 (file)
@@ -1,3 +1,50 @@
+2019-02-06  Andy Estes  <aestes@apple.com>
+
+        [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.
+
+        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:
+
 2019-02-06  Yusuke Suzuki  <ysuzuki@apple.com>
 
         [JSC] PrivateName to PublicName hash table is wasteful
index 00833b8..0547279 100644 (file)
@@ -1054,6 +1054,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/testing/MockContentFilterSettings.idl \
     $(WebCore)/testing/MockPageOverlay.idl \
     $(WebCore)/testing/MockPaymentAddress.idl \
+    $(WebCore)/testing/MockPaymentContactFields.idl \
     $(WebCore)/testing/MockPaymentCoordinator.idl \
     $(WebCore)/testing/MockPaymentError.idl \
     $(WebCore)/testing/ServiceWorkerInternals.idl \
index e6fb602..3f0b66f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -40,8 +40,6 @@ struct ApplePayPaymentRequest : ApplePayRequestBase {
 
     String currencyCode;
 
-    Optional<Vector<ApplePayContactField>> requiredShippingContactFields;
-
     ShippingType shippingType { ShippingType::Shipping };
     Optional<Vector<ApplePayShippingMethod>> shippingMethods;
 
index 0ec1927..b826bee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -40,8 +40,6 @@
 
     required DOMString currencyCode;
 
-    sequence<ApplePayContactField> requiredShippingContactFields;
-
     ApplePayShippingType shippingType = "shipping";
     sequence<ApplePayShippingMethod> shippingMethods;
 };
index 817d9fa..d626c04 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -78,6 +78,13 @@ ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version,
 
     if (request.billingContact)
         result.setBillingContact(PaymentContact::fromApplePayPaymentContact(version, *request.billingContact));
+    
+    if (request.requiredShippingContactFields) {
+        auto requiredShippingContactFields = convertAndValidate(version, *request.requiredShippingContactFields);
+        if (requiredShippingContactFields.hasException())
+            return requiredShippingContactFields.releaseException();
+        result.setRequiredShippingContactFields(requiredShippingContactFields.releaseReturnValue());
+    }
 
     if (request.shippingContact)
         result.setShippingContact(PaymentContact::fromApplePayPaymentContact(version, *request.shippingContact));
index 2051189..68c66b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,6 +43,7 @@ struct ApplePayRequestBase {
     Optional<Vector<ApplePayContactField>> requiredBillingContactFields;
     Optional<ApplePayPaymentContact> billingContact;
 
+    Optional<Vector<ApplePayContactField>> requiredShippingContactFields;
     Optional<ApplePayPaymentContact> shippingContact;
 
     String applicationData;
index 8c1bf19..342b408 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,6 +33,7 @@
     sequence<ApplePayContactField> requiredBillingContactFields;
     ApplePayPaymentContact billingContact;
 
+    sequence<ApplePayContactField> requiredShippingContactFields;
     ApplePayPaymentContact shippingContact;
 
     DOMString applicationData;
index 06c0fae..c673fcc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -227,13 +227,6 @@ static ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned ve
         return lineItems.releaseException();
     result.setLineItems(lineItems.releaseReturnValue());
 
-    if (paymentRequest.requiredShippingContactFields) {
-        auto requiredShippingContactFields = convertAndValidate(version, WTFMove(*paymentRequest.requiredShippingContactFields));
-        if (requiredShippingContactFields.hasException())
-            return requiredShippingContactFields.releaseException();
-        result.setRequiredShippingContactFields(requiredShippingContactFields.releaseReturnValue());
-    }
-
     result.setShippingType(paymentRequest.shippingType);
 
     if (paymentRequest.shippingMethods) {
diff --git a/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.cpp b/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.cpp
new file mode 100644 (file)
index 0000000..f6682f3
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PaymentCoordinatorClient.h"
+
+#if ENABLE(APPLE_PAY)
+
+namespace WebCore {
+
+bool PaymentCoordinatorClient::supportsVersion(unsigned version)
+{
+    ASSERT(version > 0);
+
+#if !ENABLE(APPLE_PAY_SESSION_V3)
+    static const unsigned currentVersion = 2;
+#elif !ENABLE(APPLE_PAY_SESSION_V4)
+    static const unsigned currentVersion = 3;
+#else
+    static const unsigned currentVersion = 6;
+#endif
+
+    return version <= currentVersion;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)
index 170a4f3..35ac0d1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,7 +45,8 @@ struct ShippingMethodUpdate;
 
 class PaymentCoordinatorClient {
 public:
-    virtual bool supportsVersion(unsigned version) = 0;
+    bool supportsVersion(unsigned version);
+
     virtual Optional<String> validatedPaymentNetwork(const String&) = 0;
     virtual bool canMakePayments() = 0;
     virtual void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) = 0;
index ea44d5f..da71c2f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -129,16 +129,6 @@ static ExceptionOr<Vector<ApplePaySessionPaymentRequest::LineItem>> convertAndVa
     return { WTFMove(result) };
 }
 
-static ApplePaySessionPaymentRequest::ContactFields convert(const PaymentOptions& options)
-{
-    ApplePaySessionPaymentRequest::ContactFields result;
-    result.email = options.requestPayerEmail;
-    result.name = options.requestPayerName;
-    result.phone = options.requestPayerPhone;
-    result.postalAddress = options.requestShipping;
-    return result;
-}
-
 static ApplePaySessionPaymentRequest::ShippingType convert(PaymentShippingType type)
 {
     switch (type) {
@@ -182,6 +172,19 @@ ExceptionOr<void> ApplePayPaymentHandler::convertData(JSC::JSValue&& data)
     return { };
 }
 
+static void mergePaymentOptions(const PaymentOptions& options, ApplePaySessionPaymentRequest& request)
+{
+    auto requiredShippingContactFields = request.requiredShippingContactFields();
+    requiredShippingContactFields.email |= options.requestPayerEmail;
+    requiredShippingContactFields.name |= options.requestPayerName;
+    requiredShippingContactFields.phone |= options.requestPayerPhone;
+    requiredShippingContactFields.postalAddress |= options.requestShipping;
+    request.setRequiredShippingContactFields(requiredShippingContactFields);
+
+    if (options.requestShipping)
+        request.setShippingType(convert(options.shippingType));
+}
+
 ExceptionOr<void> ApplePayPaymentHandler::show()
 {
     auto validatedRequest = convertAndValidate(m_applePayRequest->version, *m_applePayRequest, paymentCoordinator());
@@ -203,9 +206,7 @@ ExceptionOr<void> ApplePayPaymentHandler::show()
         return convertedLineItems.releaseException();
     request.setLineItems(convertedLineItems.releaseReturnValue());
 
-    request.setRequiredShippingContactFields(convert(m_paymentRequest->paymentOptions()));
-    if (m_paymentRequest->paymentOptions().requestShipping)
-        request.setShippingType(convert(m_paymentRequest->paymentOptions().shippingType));
+    mergePaymentOptions(m_paymentRequest->paymentOptions(), request);
 
     auto shippingMethods = computeShippingMethods();
     if (shippingMethods.hasException())
index 0722288..a07b26d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+// Copyright (C) 2017-2019 Apple Inc. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions
@@ -588,6 +588,7 @@ platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp
     Modules/applepay/ApplePayShippingMethodSelectedEvent.cpp
     Modules/applepay/ApplePayValidateMerchantEvent.cpp
     Modules/applepay/PaymentCoordinator.cpp
+    Modules/applepay/PaymentCoordinatorClient.cpp
     Modules/applepay/PaymentRequestValidator.mm
     Modules/applepay/PaymentSession.cpp
 
index 01dcd96..aa3b41d 100644 (file)
                A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A0EE0DF2144F825500F80B0D /* WebGLDebugRendererInfo.h */; };
                A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A0EE0DF3144F825500F80B0D /* WebGLDebugShaders.cpp */; };
                A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = A0EE0DF4144F825500F80B0D /* WebGLDebugShaders.h */; };
+               A104EC5A220A3DE000CBF67A /* MockPaymentContactFields.h in Headers */ = {isa = PBXBuildFile; fileRef = A104EC55220A39B400CBF67A /* MockPaymentContactFields.h */; };
+               A104EC5D220A3E4B00CBF67A /* JSMockPaymentContactFields.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */; };
+               A104EC5E220A3E4E00CBF67A /* JSMockPaymentContactFields.h in Headers */ = {isa = PBXBuildFile; fileRef = A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */; };
                A104F24414C71F7A009E2C23 /* CachedSVGDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A10BB5851484E3A700B2E87A /* RenderSVGRect.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5831484E3A700B2E87A /* RenderSVGRect.h */; };
                A10BB58B1484E3B300B2E87A /* RenderSVGShape.h in Headers */ = {isa = PBXBuildFile; fileRef = A10BB5891484E3B300B2E87A /* RenderSVGShape.h */; };
                A0EE0DF2144F825500F80B0D /* WebGLDebugRendererInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLDebugRendererInfo.h; sourceTree = "<group>"; };
                A0EE0DF3144F825500F80B0D /* WebGLDebugShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLDebugShaders.cpp; sourceTree = "<group>"; };
                A0EE0DF4144F825500F80B0D /* WebGLDebugShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLDebugShaders.h; sourceTree = "<group>"; };
+               A104EC53220A017400CBF67A /* PaymentCoordinatorClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PaymentCoordinatorClient.cpp; sourceTree = "<group>"; };
+               A104EC55220A39B400CBF67A /* MockPaymentContactFields.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentContactFields.h; sourceTree = "<group>"; };
+               A104EC57220A39B400CBF67A /* MockPaymentContactFields.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockPaymentContactFields.idl; sourceTree = "<group>"; };
+               A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockPaymentContactFields.cpp; sourceTree = "<group>"; };
+               A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSMockPaymentContactFields.h; sourceTree = "<group>"; };
                A104F24114C71F7A009E2C23 /* CachedSVGDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedSVGDocument.cpp; sourceTree = "<group>"; };
                A104F24214C71F7A009E2C23 /* CachedSVGDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGDocument.h; sourceTree = "<group>"; };
                A10BB5821484E3A700B2E87A /* RenderSVGRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGRect.cpp; sourceTree = "<group>"; };
                                1A8A64381D19FC5300D0E00F /* PaymentContact.h */,
                                1A58E86B1D19E42D00C0EA73 /* PaymentCoordinator.cpp */,
                                1A58E86C1D19E42D00C0EA73 /* PaymentCoordinator.h */,
+                               A104EC53220A017400CBF67A /* PaymentCoordinatorClient.cpp */,
                                1A58E8621D19D3BF00C0EA73 /* PaymentCoordinatorClient.h */,
                                7CF930E61E01F9AD00BAFFBE /* PaymentHeaders.h */,
                                1AE96A871D1A0CEB00B86768 /* PaymentMerchantSession.h */,
                                A146D31C1F99C9C200D29196 /* MockPaymentAddress.h */,
                                A146D31E1F99C9C200D29196 /* MockPaymentAddress.idl */,
                                A146D3241F99D69800D29196 /* MockPaymentContact.h */,
+                               A104EC55220A39B400CBF67A /* MockPaymentContactFields.h */,
+                               A104EC57220A39B400CBF67A /* MockPaymentContactFields.idl */,
                                A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */,
                                A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */,
                                A146D3161F99B53D00D29196 /* MockPaymentCoordinator.idl */,
                                2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */,
                                A146D3201F99CA3E00D29196 /* JSMockPaymentAddress.cpp */,
                                A146D31F1F99CA3D00D29196 /* JSMockPaymentAddress.h */,
+                               A104EC5B220A3E4300CBF67A /* JSMockPaymentContactFields.cpp */,
+                               A104EC5C220A3E4400CBF67A /* JSMockPaymentContactFields.h */,
                                A146D3191F99BCBB00D29196 /* JSMockPaymentCoordinator.cpp */,
                                A146D3181F99BCBA00D29196 /* JSMockPaymentCoordinator.h */,
                                A1BB85B42159B3890067E07D /* JSMockPaymentError.cpp */,
                                A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
                                538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */,
                                A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
+                               A104EC5E220A3E4E00CBF67A /* JSMockPaymentContactFields.h in Headers */,
                                A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
                                A1BB85B92159B3AE0067E07D /* JSMockPaymentError.h in Headers */,
                                427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
                                A14BB0A01F9813B800605A35 /* MockPayment.h in Headers */,
                                A146D3211F99CB1A00D29196 /* MockPaymentAddress.h in Headers */,
                                A146D3251F99D69800D29196 /* MockPaymentContact.h in Headers */,
+                               A104EC5A220A3DE000CBF67A /* MockPaymentContactFields.h in Headers */,
                                A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */,
                                A1CBEF641F9F11290028DE7C /* MockPaymentMethod.h in Headers */,
                                A140618C1E2ECA0A0032B34E /* MockPreviewLoaderClient.h in Headers */,
                                A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
                                2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
                                A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
+                               A104EC5D220A3E4B00CBF67A /* JSMockPaymentContactFields.cpp in Sources */,
                                A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
                                A1BB85B82159B3A40067E07D /* JSMockPaymentError.cpp in Sources */,
                                427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
index b583221..fb02baf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
- * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -312,7 +312,6 @@ class EmptyInspectorClient final : public InspectorClient {
 #if ENABLE(APPLE_PAY)
 
 class EmptyPaymentCoordinatorClient final : public PaymentCoordinatorClient {
-    bool supportsVersion(unsigned) final { return false; }
     Optional<String> validatedPaymentNetwork(const String&) final { return WTF::nullopt; }
     bool canMakePayments() final { return false; }
     void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)] { completionHandler(false); }); }
diff --git a/Source/WebCore/testing/MockPaymentContactFields.h b/Source/WebCore/testing/MockPaymentContactFields.h
new file mode 100644 (file)
index 0000000..b984536
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY)
+
+#include "ApplePaySessionPaymentRequest.h"
+
+namespace WebCore {
+
+struct MockPaymentContactFields : public ApplePaySessionPaymentRequest::ContactFields {
+    MockPaymentContactFields() = default;
+    MockPaymentContactFields(const ApplePaySessionPaymentRequest::ContactFields& contactFields)
+        : ApplePaySessionPaymentRequest::ContactFields { contactFields }
+    {
+    }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)
diff --git a/Source/WebCore/testing/MockPaymentContactFields.idl b/Source/WebCore/testing/MockPaymentContactFields.idl
new file mode 100644 (file)
index 0000000..6491734
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=APPLE_PAY,
+    JSGenerateToJSObject,
+] dictionary MockPaymentContactFields {
+    boolean postalAddress = false;
+    boolean phone = false;
+    boolean email = false;
+    boolean name = false;
+    boolean phoneticName = false;
+};
index 38241b7..661f180 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,21 +53,6 @@ MockPaymentCoordinator::MockPaymentCoordinator(Page& page)
     m_availablePaymentNetworks.add("visa");
 }
 
-bool MockPaymentCoordinator::supportsVersion(unsigned version)
-{
-    ASSERT(version > 0);
-
-#if !ENABLE(APPLE_PAY_SESSION_V3)
-    static const unsigned currentVersion = 2;
-#elif !ENABLE(APPLE_PAY_SESSION_V4)
-    static const unsigned currentVersion = 3;
-#else
-    static const unsigned currentVersion = 5;
-#endif
-
-    return version <= currentVersion;
-}
-
 Optional<String> MockPaymentCoordinator::validatedPaymentNetwork(const String& paymentNetwork)
 {
     auto result = m_availablePaymentNetworks.find(paymentNetwork);
@@ -119,6 +104,8 @@ bool MockPaymentCoordinator::showPaymentUI(const URL&, const Vector<URL>&, const
     if (request.shippingContact().pkContact())
         m_shippingAddress = request.shippingContact().toApplePayPaymentContact(request.version());
     m_shippingMethods = convert(request.shippingMethods());
+    m_requiredBillingContactFields = request.requiredBillingContactFields();
+    m_requiredShippingContactFields = request.requiredShippingContactFields();
 
     ASSERT(showCount == hideCount);
     ++showCount;
index 8de2a87..a54c21a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 #include "ApplePayLineItem.h"
 #include "ApplePayShippingMethod.h"
 #include "MockPaymentAddress.h"
+#include "MockPaymentContactFields.h"
 #include "MockPaymentError.h"
 #include "PaymentCoordinatorClient.h"
 #include <wtf/HashSet.h>
@@ -56,12 +57,13 @@ public:
     const Vector<ApplePayLineItem>& lineItems() const { return m_lineItems; }
     const Vector<MockPaymentError>& errors() const { return m_errors; }
     const Vector<ApplePayShippingMethod>& shippingMethods() const { return m_shippingMethods; }
+    const MockPaymentContactFields& requiredBillingContactFields() const { return m_requiredBillingContactFields; }
+    const MockPaymentContactFields& requiredShippingContactFields() const { return m_requiredShippingContactFields; }
 
     void ref() const { }
     void deref() const { }
 
 private:
-    bool supportsVersion(unsigned) final;
     Optional<String> validatedPaymentNetwork(const String&) final;
     bool canMakePayments() final;
     void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&&);
@@ -89,6 +91,8 @@ private:
     Vector<MockPaymentError> m_errors;
     Vector<ApplePayShippingMethod> m_shippingMethods;
     HashSet<String, ASCIICaseInsensitiveHash> m_availablePaymentNetworks;
+    MockPaymentContactFields m_requiredBillingContactFields;
+    MockPaymentContactFields m_requiredShippingContactFields;
 };
 
 } // namespace WebCore
index 702d595..785546d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,4 +39,6 @@
     readonly attribute sequence<ApplePayLineItem> lineItems;
     readonly attribute sequence<MockPaymentError> errors;
     readonly attribute sequence<ApplePayShippingMethod> shippingMethods;
+    readonly attribute MockPaymentContactFields requiredBillingContactFields;
+    readonly attribute MockPaymentContactFields requiredShippingContactFields;
 };
index 7b02752..cee0811 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-06  Andy Estes  <aestes@apple.com>
+
+        [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.
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::supportsVersion): Deleted.
+        * WebProcess/ApplePay/WebPaymentCoordinator.h:
+
 2019-02-06  Keith Rollin  <krollin@apple.com>
 
         Really enable the automatic checking and regenerations of .xcfilelists during builds
index 3fcccb4..b375c8e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -51,21 +51,6 @@ WebPaymentCoordinator::~WebPaymentCoordinator()
     WebProcess::singleton().removeMessageReceiver(*this);
 }
 
-bool WebPaymentCoordinator::supportsVersion(unsigned version)
-{
-    ASSERT(version > 0);
-
-#if !ENABLE(APPLE_PAY_SESSION_V3)
-    static const unsigned currentVersion = 2;
-#elif !ENABLE(APPLE_PAY_SESSION_V4)
-    static const unsigned currentVersion = 3;
-#else
-    static const unsigned currentVersion = 5;
-#endif
-
-    return version <= currentVersion;
-}
-
 const WebPaymentCoordinator::AvailablePaymentNetworksSet& WebPaymentCoordinator::availablePaymentNetworks()
 {
     if (m_availablePaymentNetworks)
index 2fe5ec7..6710544 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,7 +55,6 @@ public:
 
 private:
     // WebCore::PaymentCoordinatorClient.
-    bool supportsVersion(unsigned version) override;
     Optional<String> validatedPaymentNetwork(const String&) override;
     bool canMakePayments() override;
     void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;
index 6ea34d3..9a36586 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-06  Andy Estes  <aestes@apple.com>
+
+        [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.
+
+        * WebCoreSupport/WebPaymentCoordinatorClient.h:
+        * WebCoreSupport/WebPaymentCoordinatorClient.mm:
+        (WebPaymentCoordinatorClient::supportsVersion): Deleted.
+
 2019-02-04  Said Abou-Hallawa  <said@apple.com>
 
         [CG] Enable setAdditionalSupportedImageTypes for WK1
index 09da2ee..ec0c34a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,7 +36,6 @@ public:
 private:
     ~WebPaymentCoordinatorClient();
 
-    bool supportsVersion(unsigned) override;
     Optional<String> validatedPaymentNetwork(const String&) override;
     bool canMakePayments() override;
     void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void (bool)>&& completionHandler) override;
index 3b33f49..a565435 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,11 +38,6 @@ WebPaymentCoordinatorClient::~WebPaymentCoordinatorClient()
 {
 }
 
-bool WebPaymentCoordinatorClient::supportsVersion(unsigned)
-{
-    return false;
-}
-
 Optional<String> WebPaymentCoordinatorClient::validatedPaymentNetwork(const String&)
 {
     return WTF::nullopt;