[Payment Request] Remove ApplePayPaymentMethodUpdateEvent and use PaymentDetailsModif...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Dec 2017 18:02:28 +0000 (18:02 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Dec 2017 18:02:28 +0000 (18:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180737
<rdar://problem/36013152>

Reviewed by Brady Eidson.

Source/WebCore:

Instead of firing a non-standard "applepaypaymentmethodupdate" event when the payment method
changes, use the PaymentDetailsModifier mechanism to allow the merchant to specify override
totals and additional display items per payment method type.

Test: http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html

* DerivedSources.make:
* Modules/applepay/ApplePayLineItem.idl:
* Modules/applepay/ApplePayPaymentMethod.h:
* Modules/applepay/ApplePayPaymentMethod.idl:
* Modules/applepay/ApplePayPaymentMethodType.h: Added.
* Modules/applepay/ApplePayPaymentMethodType.idl: Added.
* Modules/applepay/cocoa/PaymentMethodCocoa.mm:
* Modules/applepay/paymentrequest/ApplePayModifier.h: Added.
* Modules/applepay/paymentrequest/ApplePayModifier.idl: Added.
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::show):
(WebCore::ApplePayPaymentHandler::computeTotalAndLineItems):
(WebCore::ApplePayPaymentHandler::detailsUpdated):
(WebCore::ApplePayPaymentHandler::shippingAddressUpdated):
(WebCore::ApplePayPaymentHandler::shippingOptionUpdated):
(WebCore::ApplePayPaymentHandler::paymentMethodUpdated):
(WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp: Removed.
* Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h: Removed.
* Modules/paymentrequest/PaymentRequest.h:
* Modules/paymentrequest/PaymentRequest.idl:
* WebCore.xcodeproj/project.pbxproj:
* dom/EventNames.h:
* dom/EventNames.in:
* testing/MockPaymentCoordinator.cpp:
(WebCore::convert):
(WebCore::MockPaymentCoordinator::updateTotalAndLineItems):
(WebCore::MockPaymentCoordinator::completeShippingMethodSelection):
(WebCore::MockPaymentCoordinator::completeShippingContactSelection):
(WebCore::MockPaymentCoordinator::completePaymentMethodSelection):
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.idl:

LayoutTests:

* http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https-expected.txt: Added.
* http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html: Added.
* http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt: Removed.
* http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html: Removed.

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

25 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html [new file with mode: 0644]
LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt [deleted file]
LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/applepay/ApplePayLineItem.idl
Source/WebCore/Modules/applepay/ApplePayPaymentMethod.h
Source/WebCore/Modules/applepay/ApplePayPaymentMethod.idl
Source/WebCore/Modules/applepay/ApplePayPaymentMethodType.h [moved from Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h with 64% similarity]
Source/WebCore/Modules/applepay/ApplePayPaymentMethodType.idl [new file with mode: 0644]
Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm
Source/WebCore/Modules/applepay/paymentrequest/ApplePayModifier.h [moved from Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp with 75% similarity]
Source/WebCore/Modules/applepay/paymentrequest/ApplePayModifier.idl [moved from Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl with 88% similarity]
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h
Source/WebCore/Modules/paymentrequest/PaymentRequest.h
Source/WebCore/Modules/paymentrequest/PaymentRequest.idl
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventNames.in
Source/WebCore/testing/MockPaymentCoordinator.cpp
Source/WebCore/testing/MockPaymentCoordinator.h
Source/WebCore/testing/MockPaymentCoordinator.idl

index d9c4af6..5613614 100644 (file)
@@ -1,3 +1,16 @@
+2017-12-13  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Remove ApplePayPaymentMethodUpdateEvent and use PaymentDetailsModifiers instead
+        https://bugs.webkit.org/show_bug.cgi?id=180737
+        <rdar://problem/36013152>
+
+        Reviewed by Brady Eidson.
+
+        * http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https-expected.txt: Added.
+        * http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html: Added.
+        * http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt: Removed.
+        * http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html: Removed.
+
 2017-12-13  Matt Lewis  <jlewis3@apple.com>
 
         Added missing expectation file for fast/text/user-installed-fonts/shadow-postscript-family.html
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https-expected.txt b/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https-expected.txt
new file mode 100644 (file)
index 0000000..997a093
--- /dev/null
@@ -0,0 +1,34 @@
+Test PaymentDetailsModifier with Apple Pay.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing PaymentDetailsModifier after selecting a 'credit' payment method type.
+PASS internals.mockPaymentCoordinator.total.label is 'Credit total override'
+PASS internals.mockPaymentCoordinator.total.amount is '15.00'
+PASS internals.mockPaymentCoordinator.lineItems.length is 2
+PASS internals.mockPaymentCoordinator.lineItems[0].label is 'Item'
+PASS internals.mockPaymentCoordinator.lineItems[0].amount is '10.00'
+PASS internals.mockPaymentCoordinator.lineItems[1].label is 'Credit surcharge'
+PASS internals.mockPaymentCoordinator.lineItems[1].amount is '5.00'
+
+Testing PaymentDetailsModifier after selecting a 'debit' payment method type.
+PASS internals.mockPaymentCoordinator.total.label is 'Debit total override'
+PASS internals.mockPaymentCoordinator.total.amount is '13.00'
+PASS internals.mockPaymentCoordinator.lineItems.length is 2
+PASS internals.mockPaymentCoordinator.lineItems[0].label is 'Item'
+PASS internals.mockPaymentCoordinator.lineItems[0].amount is '10.00'
+PASS internals.mockPaymentCoordinator.lineItems[1].label is 'Debit surcharge'
+PASS internals.mockPaymentCoordinator.lineItems[1].amount is '3.00'
+
+Testing PaymentDetailsModifier after selecting an unmodified payment method type.
+PASS internals.mockPaymentCoordinator.total.label is 'Total'
+PASS internals.mockPaymentCoordinator.total.amount is '10.00'
+PASS internals.mockPaymentCoordinator.lineItems.length is 1
+PASS internals.mockPaymentCoordinator.lineItems[0].label is 'Item'
+PASS internals.mockPaymentCoordinator.lineItems[0].amount is '10.00'
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html b/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html
new file mode 100644 (file)
index 0000000..6a22065
--- /dev/null
@@ -0,0 +1,184 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="/js-test-resources/ui-helper.js"></script>
+<script src="/resources/js-test-pre.js"></script>
+<script src="/resources/payment-request.js"></script>
+</head>
+<body>
+<script>
+
+description("Test PaymentDetailsModifier with Apple Pay.");
+
+window.jsTestIsAsync = true;
+
+function validPaymentMethod() {
+    return {
+        supportedMethods: 'https://apple.com/apple-pay',
+        data: {
+            version: 2,
+            merchantIdentifier: '',
+            countryCode: 'US',
+            supportedNetworks: ['visa', 'masterCard'],
+            merchantCapabilities: ['supports3DS'],
+        },
+    }
+}
+
+function validPaymentDetails() {
+    return {
+        total: {
+            label: 'Total',
+            amount: {
+                currency: 'USD',
+                value: '10.00',
+            },
+        },
+        displayItems: [{
+            label: 'Item',
+            amount: {
+                currency: 'USD',
+                value: '10.00',
+            },
+        }],
+        modifiers: [{
+            supportedMethods: 'https://apple.com/apple-pay',
+            total: {
+                label: 'Credit total override',
+                amount: {
+                    currency: 'USD',
+                    value: '15.00',
+                },
+            },
+            additionalDisplayItems: [{
+                label: 'Credit surcharge',
+                amount: {
+                    currency: 'USD',
+                    value: '5.00',
+                },
+            }],
+            data: {
+                paymentMethodType: 'credit',
+            },
+        }, {
+            supportedMethods: 'https://apple.com/apple-pay',
+            total: {
+                label: 'Duplicate credit total override',
+                amount: {
+                    currency: 'USD',
+                    value: '17.00',
+                },
+            },
+            additionalDisplayItems: [{
+                label: 'Duplicate credit surcharge',
+                amount: {
+                    currency: 'USD',
+                    value: '7.00',
+                },
+            }],
+            data: {
+                paymentMethodType: 'credit',
+            },
+        }, {
+            supportedMethods: 'https://apple.com/apple-pay',
+            total: {
+                label: 'Debit total override',
+                amount: {
+                    currency: 'USD',
+                    value: '13.00',
+                },
+            },
+            additionalDisplayItems: [{
+                label: 'Debit surcharge',
+                amount: {
+                    currency: 'USD',
+                    value: '3.00',
+                },
+            }],
+            data: {
+                paymentMethodType: 'debit',
+            },
+        }],
+    }
+}
+
+async function runTests() {
+    await new Promise((resolve, reject) => {
+        debug("Testing PaymentDetailsModifier after selecting a 'credit' payment method type.");
+
+        var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+
+        activateThen(() => {
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.total.label", "'Credit total override'");
+                shouldBe("internals.mockPaymentCoordinator.total.amount", "'15.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems.length", "2");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].label", "'Item'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].amount", "'10.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[1].label", "'Credit surcharge'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[1].amount", "'5.00'");
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.changePaymentMethod({ type: 'credit' });
+            internals.mockPaymentCoordinator.acceptPayment();
+        });
+    });
+    debug("");
+    
+    await new Promise((resolve, reject) => {
+        debug("Testing PaymentDetailsModifier after selecting a 'debit' payment method type.");
+
+        var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+
+        activateThen(() => {
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.total.label", "'Debit total override'");
+                shouldBe("internals.mockPaymentCoordinator.total.amount", "'13.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems.length", "2");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].label", "'Item'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].amount", "'10.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[1].label", "'Debit surcharge'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[1].amount", "'3.00'");
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.changePaymentMethod({ type: 'debit' });
+            internals.mockPaymentCoordinator.acceptPayment();
+        });
+    });
+    debug("");
+
+    await new Promise((resolve, reject) => {
+        debug("Testing PaymentDetailsModifier after selecting an unmodified payment method type.");
+
+        var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+
+        activateThen(() => {
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.total.label", "'Total'");
+                shouldBe("internals.mockPaymentCoordinator.total.amount", "'10.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems.length", "1");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].label", "'Item'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].amount", "'10.00'");
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.changePaymentMethod({ type: 'prepaid' });
+            internals.mockPaymentCoordinator.acceptPayment();
+        });
+    });
+    debug("");
+
+    finishJSTest();
+}
+
+runTests();
+</script>
+<script src="/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt b/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt
deleted file mode 100644 (file)
index 807b18c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Test the applepaypaymentmethodchanged event.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Testing ApplePayMerchantValidationEvent
-
-PASS event.paymentMethod.displayName is expectedPaymentMethod.displayName
-PASS event.paymentMethod.network is expectedPaymentMethod.network
-PASS event.paymentMethod.type is expectedPaymentMethod.type
-PASS event.paymentMethod.paymentPass.primaryAccountIdentifier is expectedPaymentMethod.paymentPass.primaryAccountIdentifier
-PASS event.paymentMethod.paymentPass.primaryAccountNumberSuffix is expectedPaymentMethod.paymentPass.primaryAccountNumberSuffix
-PASS event.paymentMethod.paymentPass.deviceAccountIdentifier is expectedPaymentMethod.paymentPass.deviceAccountIdentifier
-PASS event.paymentMethod.paymentPass.deviceAccountNumberSuffix is expectedPaymentMethod.paymentPass.deviceAccountNumberSuffix
-PASS event.paymentMethod.paymentPass.activationState is expectedPaymentMethod.paymentPass.activationState
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html b/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html
deleted file mode 100644 (file)
index 6464b99..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src="/js-test-resources/ui-helper.js"></script>
-<script src="/resources/js-test-pre.js"></script>
-<script src="/resources/payment-request.js"></script>
-</head>
-<body>
-<script>
-
-description("Test the applepaypaymentmethodchanged event.");
-
-window.jsTestIsAsync = true;
-
-function validPaymentMethod() {
-    return {
-        supportedMethods: 'https://apple.com/apple-pay',
-        data: {
-            version: 2,
-            merchantIdentifier: '',
-            countryCode: 'US',
-            supportedNetworks: ['visa', 'masterCard'],
-            merchantCapabilities: ['supports3DS'],
-        },
-    }
-}
-
-function validPaymentDetails() {
-    return {
-        total: { label: 'Your label', amount: { currency: 'USD', value: '10.00' } },
-    }
-}
-
-async function go() {
-    debug("Testing ApplePayMerchantValidationEvent");
-    debug("");
-
-    expectedPaymentMethod = {
-        displayName: 'test',
-        network: 'test',
-        type: 'prepaid',
-        paymentPass: {
-            primaryAccountIdentifier: 'test',
-            primaryAccountNumberSuffix: 'test',
-            deviceAccountIdentifier: 'test',
-            deviceAccountNumberSuffix: 'test',
-            activationState: 'requiresActivation',
-        },
-    };
-
-    var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
-    paymentRequest.onapplepaypaymentmethodchanged = (event) => {
-        shouldBe("event.paymentMethod.displayName", "expectedPaymentMethod.displayName");
-        shouldBe("event.paymentMethod.network", "expectedPaymentMethod.network");
-        shouldBe("event.paymentMethod.type", "expectedPaymentMethod.type");
-        shouldBe("event.paymentMethod.paymentPass.primaryAccountIdentifier", "expectedPaymentMethod.paymentPass.primaryAccountIdentifier");
-        shouldBe("event.paymentMethod.paymentPass.primaryAccountNumberSuffix", "expectedPaymentMethod.paymentPass.primaryAccountNumberSuffix");
-        shouldBe("event.paymentMethod.paymentPass.deviceAccountIdentifier", "expectedPaymentMethod.paymentPass.deviceAccountIdentifier");
-        shouldBe("event.paymentMethod.paymentPass.deviceAccountNumberSuffix", "expectedPaymentMethod.paymentPass.deviceAccountNumberSuffix");
-        shouldBe("event.paymentMethod.paymentPass.activationState", "expectedPaymentMethod.paymentPass.activationState");
-
-        document.querySelector("button").remove();
-        finishJSTest();
-    };
-
-    activateThen(() => {
-        paymentRequest.show();
-        internals.mockPaymentCoordinator.changePaymentMethod(expectedPaymentMethod);
-    });
-}
-
-window.onload = function() {
-    var button = document.querySelector("button");
-    let x = button.offsetLeft + 2;
-    let y = button.offsetTop + 2;
-    UIHelper.activateAt(x, y);
-}
-
-</script>
-<button onclick='go()'>Go</button>
-<script src="/resources/js-test-post.js"></script>
-</body>
-</html>
index 96fe1fc..3907357 100644 (file)
@@ -1,3 +1,51 @@
+2017-12-13  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Remove ApplePayPaymentMethodUpdateEvent and use PaymentDetailsModifiers instead
+        https://bugs.webkit.org/show_bug.cgi?id=180737
+        <rdar://problem/36013152>
+
+        Reviewed by Brady Eidson.
+
+        Instead of firing a non-standard "applepaypaymentmethodupdate" event when the payment method
+        changes, use the PaymentDetailsModifier mechanism to allow the merchant to specify override
+        totals and additional display items per payment method type.
+
+        Test: http/tests/ssl/applepay/ApplePayPaymentDetailsModifier.https.html
+
+        * DerivedSources.make:
+        * Modules/applepay/ApplePayLineItem.idl:
+        * Modules/applepay/ApplePayPaymentMethod.h:
+        * Modules/applepay/ApplePayPaymentMethod.idl:
+        * Modules/applepay/ApplePayPaymentMethodType.h: Added.
+        * Modules/applepay/ApplePayPaymentMethodType.idl: Added.
+        * Modules/applepay/cocoa/PaymentMethodCocoa.mm:
+        * Modules/applepay/paymentrequest/ApplePayModifier.h: Added.
+        * Modules/applepay/paymentrequest/ApplePayModifier.idl: Added.
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::show):
+        (WebCore::ApplePayPaymentHandler::computeTotalAndLineItems):
+        (WebCore::ApplePayPaymentHandler::detailsUpdated):
+        (WebCore::ApplePayPaymentHandler::shippingAddressUpdated):
+        (WebCore::ApplePayPaymentHandler::shippingOptionUpdated):
+        (WebCore::ApplePayPaymentHandler::paymentMethodUpdated):
+        (WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+        * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp: Removed.
+        * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h: Removed.
+        * Modules/paymentrequest/PaymentRequest.h:
+        * Modules/paymentrequest/PaymentRequest.idl:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/EventNames.h:
+        * dom/EventNames.in:
+        * testing/MockPaymentCoordinator.cpp:
+        (WebCore::convert):
+        (WebCore::MockPaymentCoordinator::updateTotalAndLineItems):
+        (WebCore::MockPaymentCoordinator::completeShippingMethodSelection):
+        (WebCore::MockPaymentCoordinator::completeShippingContactSelection):
+        (WebCore::MockPaymentCoordinator::completePaymentMethodSelection):
+        * testing/MockPaymentCoordinator.h:
+        * testing/MockPaymentCoordinator.idl:
+
 2017-12-12  Zalan Bujtas  <zalan@apple.com>
 
         is<HTMLTextFormControlElement> reports the input type.
index d7fd041..df23839 100644 (file)
@@ -97,6 +97,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/applepay/ApplePayPaymentContact.idl \
     $(WebCore)/Modules/applepay/ApplePayPaymentMethod.idl \
     $(WebCore)/Modules/applepay/ApplePayPaymentMethodSelectedEvent.idl \
+    $(WebCore)/Modules/applepay/ApplePayPaymentMethodType.idl \
        $(WebCore)/Modules/applepay/ApplePayPaymentMethodUpdate.idl \
     $(WebCore)/Modules/applepay/ApplePayPaymentPass.idl \
     $(WebCore)/Modules/applepay/ApplePayPaymentRequest.idl \
@@ -109,7 +110,7 @@ JS_BINDING_IDLS = \
        $(WebCore)/Modules/applepay/ApplePayShippingMethodUpdate.idl \
     $(WebCore)/Modules/applepay/ApplePayValidateMerchantEvent.idl \
     $(WebCore)/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl \
-    $(WebCore)/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl \
+    $(WebCore)/Modules/applepay/paymentrequest/ApplePayModifier.idl \
     $(WebCore)/Modules/applepay/paymentrequest/ApplePayRequest.idl \
     $(WebCore)/Modules/beacon/NavigatorBeacon.idl \
     $(WebCore)/Modules/cache/DOMWindowCaches.idl \
index 2c58037..da5f2ee 100644 (file)
@@ -32,6 +32,8 @@
 
 [
     Conditional=APPLE_PAY,
+    ExportMacro=WEBCORE_EXPORT,
+    JSGenerateToJSObject,
 ] dictionary ApplePayLineItem {
     ApplePayLineItemType type = "final";
     DOMString label;
index 7bf917c..3095845 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-enum class ApplePayPaymentMethodType { Debit, Credit, Prepaid, Store };
+enum class ApplePayPaymentMethodType;
 
 struct ApplePayPaymentMethod {    
     using Type = ApplePayPaymentMethodType;
index e090940..6d5442d 100644 (file)
 
 [
     Conditional=APPLE_PAY,
-] enum ApplePayPaymentMethodType { 
-    "debit", 
-    "credit",
-    "prepaid",
-    "store" 
-};
-
-[
-    Conditional=APPLE_PAY,
     ExportMacro=WEBCORE_EXPORT,
     JSGenerateToJSObject
 ] dictionary ApplePayPaymentMethod {
 
 #pragma once
 
-#if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
-
-#include "ApplePayPaymentMethod.h"
-#include "PaymentRequestUpdateEvent.h"
+#if ENABLE(APPLE_PAY)
 
 namespace WebCore {
 
-class ApplePayPaymentMethodUpdateEvent final : public PaymentRequestUpdateEvent {
-public:
-    template <typename... Args> static Ref<ApplePayPaymentMethodUpdateEvent> create(Args&&... args)
-    {
-        return adoptRef(*new ApplePayPaymentMethodUpdateEvent(std::forward<Args>(args)...));
-    }
-
-    const ApplePayPaymentMethod& paymentMethod() const { return m_paymentMethod; }
-
-private:
-    ApplePayPaymentMethodUpdateEvent(const AtomicString& type, const ApplePayPaymentMethod&, PaymentRequest&);
-
-    // Event
-    EventInterface eventInterface() const final;
-
-    const ApplePayPaymentMethod m_paymentMethod;
+enum class ApplePayPaymentMethodType {
+    Debit,
+    Credit,
+    Prepaid,
+    Store,
 };
 
 } // namespace WebCore
 
-#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
+#endif // ENABLE(APPLE_PAY)
diff --git a/Source/WebCore/Modules/applepay/ApplePayPaymentMethodType.idl b/Source/WebCore/Modules/applepay/ApplePayPaymentMethodType.idl
new file mode 100644 (file)
index 0000000..fbb5be9
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 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,
+] enum ApplePayPaymentMethodType {
+    "debit",
+    "credit",
+    "prepaid",
+    "store"
+};
index ad0859e..6ae68cd 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(APPLE_PAY)
 
 #import "ApplePayPaymentMethod.h"
+#import "ApplePayPaymentMethodType.h"
 #import <pal/spi/cocoa/PassKitSPI.h>
 
 namespace WebCore {
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "ApplePayPaymentMethodUpdateEvent.h"
+#pragma once
 
 #if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
 
-#include "PaymentRequest.h"
+#include "ApplePayPaymentMethodType.h"
 
 namespace WebCore {
 
-ApplePayPaymentMethodUpdateEvent::ApplePayPaymentMethodUpdateEvent(const AtomicString& type, const ApplePayPaymentMethod& paymentMethod, PaymentRequest& paymentRequest)
-    : PaymentRequestUpdateEvent { type, paymentRequest }
-    , m_paymentMethod { paymentMethod }
-{
-}
-
-EventInterface ApplePayPaymentMethodUpdateEvent::eventInterface() const
-{
-    return ApplePayPaymentMethodUpdateEventInterfaceType;
-}
+struct ApplePayModifier {
+    ApplePayPaymentMethodType paymentMethodType;
+};
 
 } // namespace WebCore
 
@@ -25,7 +25,6 @@
 
 [
     Conditional=APPLE_PAY&PAYMENT_REQUEST,
-    NoInterfaceObject,
-] interface ApplePayPaymentMethodUpdateEvent : PaymentRequestUpdateEvent {
-    [CachedAttribute] readonly attribute ApplePayPaymentMethod paymentMethod;
+] dictionary ApplePayModifier {
+    required ApplePayPaymentMethodType paymentMethodType;
 };
index 1544298..292508c 100644 (file)
@@ -31,8 +31,8 @@
 #include "ApplePayContactField.h"
 #include "ApplePayMerchantCapability.h"
 #include "ApplePayMerchantValidationEvent.h"
+#include "ApplePayModifier.h"
 #include "ApplePayPayment.h"
-#include "ApplePayPaymentMethodUpdateEvent.h"
 #include "ApplePaySessionPaymentRequest.h"
 #include "Document.h"
 #include "EventNames.h"
@@ -190,20 +190,7 @@ ExceptionOr<void> ApplePayPaymentHandler::show()
     auto convertedLineItems = convertAndValidate(m_paymentRequest->paymentDetails().displayItems, expectedCurrency);
     if (convertedLineItems.hasException())
         return convertedLineItems.releaseException();
-
-    auto lineItems = convertedLineItems.releaseReturnValue();
-    for (auto& modifier : m_paymentRequest->paymentDetails().modifiers) {
-        auto convertedIdentifier = convertAndValidatePaymentMethodIdentifier(modifier.supportedMethods);
-        if (!convertedIdentifier || !handlesIdentifier(*convertedIdentifier))
-            continue;
-
-        auto additionalDisplayItems = convertAndValidate(modifier.additionalDisplayItems, expectedCurrency);
-        if (additionalDisplayItems.hasException())
-            return additionalDisplayItems.releaseException();
-
-        lineItems.appendVector(additionalDisplayItems.releaseReturnValue());
-    }
-    request.setLineItems(lineItems);
+    request.setLineItems(convertedLineItems.releaseReturnValue());
 
     request.setRequiredShippingContactFields(convert(m_paymentRequest->paymentOptions()));
     if (m_paymentRequest->paymentOptions().requestShipping)
@@ -255,18 +242,67 @@ void ApplePayPaymentHandler::canMakePayment(Function<void(bool)>&& completionHan
     paymentCoordinator().canMakePaymentsWithActiveCard(m_applePayRequest->merchantIdentifier, document().domain(), WTFMove(completionHandler));
 }
 
-static ExceptionOr<ApplePaySessionPaymentRequest::TotalAndLineItems> convertAndValidate(const PaymentDetailsInit& details)
+ExceptionOr<ApplePaySessionPaymentRequest::TotalAndLineItems> ApplePayPaymentHandler::computeTotalAndLineItems()
 {
+    auto& details = m_paymentRequest->paymentDetails();
     String currency = details.total.amount.currency;
-    auto total = convertAndValidate(details.total, currency);
-    if (total.hasException())
-        return total.releaseException();
 
-    auto lineItems = convertAndValidate(details.displayItems, currency);
-    if (lineItems.hasException())
-        return lineItems.releaseException();
+    auto convertedTotal = convertAndValidate(details.total, currency);
+    if (convertedTotal.hasException())
+        return convertedTotal.releaseException();
+    auto total = convertedTotal.releaseReturnValue();
+
+    auto convertedLineItems = convertAndValidate(details.displayItems, currency);
+    if (convertedLineItems.hasException())
+        return convertedLineItems.releaseException();
+    auto lineItems = convertedLineItems.releaseReturnValue();
+
+    if (!m_selectedPaymentMethodType)
+        return ApplePaySessionPaymentRequest::TotalAndLineItems { WTFMove(total), WTFMove(lineItems) };
 
-    return ApplePaySessionPaymentRequest::TotalAndLineItems { total.releaseReturnValue(), lineItems.releaseReturnValue() };
+    auto& modifiers = details.modifiers;
+    auto& serializedModifierData = m_paymentRequest->serializedModifierData();
+    ASSERT(modifiers.size() == serializedModifierData.size());
+    for (size_t i = 0; i < modifiers.size(); ++i) {
+        auto convertedIdentifier = convertAndValidatePaymentMethodIdentifier(modifiers[i].supportedMethods);
+        if (!convertedIdentifier || !handlesIdentifier(*convertedIdentifier))
+            continue;
+
+        if (serializedModifierData[i].isEmpty())
+            continue;
+
+        auto& execState = *document().execState();
+        auto scope = DECLARE_THROW_SCOPE(execState.vm());
+        JSC::JSValue data;
+        {
+            auto lock = JSC::JSLockHolder { &execState };
+            data = JSONParse(&execState, serializedModifierData[i]);
+            if (scope.exception())
+                return Exception { ExistingExceptionError };
+        }
+
+        auto applePayModifier = convertDictionary<ApplePayModifier>(execState, WTFMove(data));
+        if (scope.exception())
+            return Exception { ExistingExceptionError };
+
+        if (applePayModifier.paymentMethodType != *m_selectedPaymentMethodType)
+            continue;
+
+        if (modifiers[i].total) {
+            auto totalOverride = convertAndValidate(*modifiers[i].total, currency);
+            if (totalOverride.hasException())
+                return totalOverride.releaseException();
+            total = totalOverride.releaseReturnValue();
+        }
+
+        auto additionalDisplayItems = convertAndValidate(modifiers[i].additionalDisplayItems, currency);
+        if (additionalDisplayItems.hasException())
+            return additionalDisplayItems.releaseException();
+        lineItems.appendVector(additionalDisplayItems.releaseReturnValue());
+        break;
+    }
+
+    return ApplePaySessionPaymentRequest::TotalAndLineItems { WTFMove(total), WTFMove(lineItems) };
 }
 
 ExceptionOr<void> ApplePayPaymentHandler::detailsUpdated(const AtomicString& eventType, const String& error)
@@ -277,9 +313,6 @@ ExceptionOr<void> ApplePayPaymentHandler::detailsUpdated(const AtomicString& eve
     if (eventType == eventNames().shippingoptionchangeEvent)
         return shippingOptionUpdated();
 
-    if (eventType == eventNames().applepaypaymentmethodchangedEvent)
-        return paymentMethodUpdated();
-
     ASSERT_NOT_REACHED();
     return { };
 }
@@ -295,7 +328,7 @@ ExceptionOr<void> ApplePayPaymentHandler::shippingAddressUpdated(const String& e
         update.errors.append(WTFMove(paymentError));
     }
 
-    auto newTotalAndLineItems = convertAndValidate(m_paymentRequest->paymentDetails());
+    auto newTotalAndLineItems = computeTotalAndLineItems();
     if (newTotalAndLineItems.hasException())
         return newTotalAndLineItems.releaseException();
     update.newTotalAndLineItems = newTotalAndLineItems.releaseReturnValue();
@@ -308,7 +341,7 @@ ExceptionOr<void> ApplePayPaymentHandler::shippingOptionUpdated()
 {
     ShippingMethodUpdate update;
 
-    auto newTotalAndLineItems = convertAndValidate(m_paymentRequest->paymentDetails());
+    auto newTotalAndLineItems = computeTotalAndLineItems();
     if (newTotalAndLineItems.hasException())
         return newTotalAndLineItems.releaseException();
     update.newTotalAndLineItems = newTotalAndLineItems.releaseReturnValue();
@@ -321,7 +354,7 @@ ExceptionOr<void> ApplePayPaymentHandler::paymentMethodUpdated()
 {
     PaymentMethodUpdate update;
 
-    auto newTotalAndLineItems = convertAndValidate(m_paymentRequest->paymentDetails());
+    auto newTotalAndLineItems = computeTotalAndLineItems();
     if (newTotalAndLineItems.hasException())
         return newTotalAndLineItems.releaseException();
     update.newTotalAndLineItems = newTotalAndLineItems.releaseReturnValue();
@@ -385,8 +418,8 @@ void ApplePayPaymentHandler::didSelectShippingContact(const PaymentContact& ship
 
 void ApplePayPaymentHandler::didSelectPaymentMethod(const PaymentMethod& paymentMethod)
 {
-    auto event = ApplePayPaymentMethodUpdateEvent::create(eventNames().applepaypaymentmethodchangedEvent, paymentMethod.toApplePayPaymentMethod(), m_paymentRequest.get());
-    m_paymentRequest->dispatchEvent(event.get());
+    m_selectedPaymentMethodType = paymentMethod.toApplePayPaymentMethod().type;
+    paymentMethodUpdated();
 }
 
 void ApplePayPaymentHandler::didCancelPaymentSession()
index 8129cba..c72a9d5 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
 
+#include "ApplePayPaymentMethodType.h"
 #include "ApplePayRequest.h"
 #include "ContextDestructionObserver.h"
 #include "PaymentHandler.h"
@@ -51,6 +52,8 @@ private:
     Document& document();
     PaymentCoordinator& paymentCoordinator();
 
+    ExceptionOr<ApplePaySessionPaymentRequest::TotalAndLineItems> computeTotalAndLineItems();
+
     ExceptionOr<void> shippingAddressUpdated(const String& error);
     ExceptionOr<void> shippingOptionUpdated();
     ExceptionOr<void> paymentMethodUpdated();
@@ -74,6 +77,7 @@ private:
     PaymentRequest::MethodIdentifier m_identifier;
     Ref<PaymentRequest> m_paymentRequest;
     std::optional<ApplePayRequest> m_applePayRequest;
+    std::optional<ApplePayPaymentMethodType> m_selectedPaymentMethodType;
 };
 
 } // namespace WebCore
index 5eff30a..5cd78bf 100644 (file)
@@ -75,6 +75,7 @@ public:
 
     const PaymentOptions& paymentOptions() const { return m_options; }
     const PaymentDetailsInit& paymentDetails() const { return m_details; }
+    const Vector<String>& serializedModifierData() const { return m_serializedModifierData; }
 
     void shippingAddressChanged(Ref<PaymentAddress>&&);
     void shippingOptionChanged(const String& shippingOption);
index 732a743..7fa399a 100644 (file)
@@ -45,5 +45,4 @@
     attribute EventHandler onshippingoptionchange;
 
     [Conditional=APPLE_PAY] attribute EventHandler onapplepayvalidatemerchant;
-    [Conditional=APPLE_PAY] attribute EventHandler onapplepaypaymentmethodchanged;
 };
index 1600b68..aa91e02 100644 (file)
                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BF6B811AA96C7D00AF4A8A /* MockContentFilter.h */; };
                A1C1507A1E3F2B3E0032C98C /* PreviewConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C150781E3F2B3E0032C98C /* PreviewConverter.h */; };
                A1C2C5761FA2851600BA46FA /* PaymentSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1C2C5751FA2851600BA46FA /* PaymentSession.cpp */; };
-               A1CBEF531F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CBEF501F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h */; };
-               A1CBEF541F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1CBEF511F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp */; };
-               A1CBEF611F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1CBEF5F1F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp */; };
-               A1CBEF621F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CBEF601F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.h */; };
                A1CBEF641F9F11290028DE7C /* MockPaymentMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CBEF631F9F11290028DE7C /* MockPaymentMethod.h */; };
                A1CC56671F46147A00A4555B /* JSPaymentAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CC56651F46146800A4555B /* JSPaymentAddress.h */; };
                A1CC56691F46148000A4555B /* JSPaymentComplete.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CC564E1F46145200A4555B /* JSPaymentComplete.h */; };
                A1F600561F4765050077E83F /* JSPaymentRequestUpdateEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F600501F4764FE0077E83F /* JSPaymentRequestUpdateEventInit.h */; };
                A1F600581F4765050077E83F /* JSPaymentRequestUpdateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F600521F4765010077E83F /* JSPaymentRequestUpdateEvent.h */; };
                A1F6005A1F4765050077E83F /* JSPaymentDetailsUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F600541F4765040077E83F /* JSPaymentDetailsUpdate.h */; };
+               A1F6CFFF1FE096210018078C /* ApplePayModifier.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F6CFFC1FE096210018078C /* ApplePayModifier.h */; };
+               A1F6D0061FE096F60018078C /* ApplePayPaymentMethodType.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F6D0031FE096F60018078C /* ApplePayPaymentMethodType.h */; };
+               A1F6D00F1FE099940018078C /* JSApplePayPaymentMethodType.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F6D00E1FE099640018078C /* JSApplePayPaymentMethodType.h */; };
+               A1F6D0101FE099960018078C /* JSApplePayPaymentMethodType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1F6D00D1FE099640018078C /* JSApplePayPaymentMethodType.cpp */; };
+               A1F6D0111FE099B20018078C /* JSApplePayModifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1F6D00A1FE099210018078C /* JSApplePayModifier.cpp */; };
+               A1F6D0121FE099B40018078C /* JSApplePayModifier.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F6D00C1FE099220018078C /* JSApplePayModifier.h */; };
                A1F76B131F44C2450014C318 /* PaymentRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F76B101F44C2450014C318 /* PaymentRequest.h */; };
                A1F76B191F44C3900014C318 /* PaymentMethodData.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F76B161F44C3900014C318 /* PaymentMethodData.h */; };
                A1F76B1F1F44C3FE0014C318 /* PaymentDetailsBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F76B1C1F44C3FE0014C318 /* PaymentDetailsBase.h */; };
                A1C150781E3F2B3E0032C98C /* PreviewConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreviewConverter.h; sourceTree = "<group>"; };
                A1C2C5751FA2851600BA46FA /* PaymentSession.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PaymentSession.cpp; sourceTree = "<group>"; };
                A1C7FAA1133A5D3500D6732D /* JSXPathResultCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXPathResultCustom.cpp; sourceTree = "<group>"; };
-               A1CBEF501F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayPaymentMethodUpdateEvent.h; sourceTree = "<group>"; };
-               A1CBEF511F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ApplePayPaymentMethodUpdateEvent.cpp; sourceTree = "<group>"; };
-               A1CBEF521F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayPaymentMethodUpdateEvent.idl; sourceTree = "<group>"; };
-               A1CBEF5F1F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayPaymentMethodUpdateEvent.cpp; sourceTree = "<group>"; };
-               A1CBEF601F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayPaymentMethodUpdateEvent.h; sourceTree = "<group>"; };
                A1CBEF631F9F11290028DE7C /* MockPaymentMethod.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentMethod.h; sourceTree = "<group>"; };
                A1CC11621E493D0100EFA69C /* FileSystemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystemMac.mm; sourceTree = "<group>"; };
                A1CC564C1F46145000A4555B /* JSPaymentMethodData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentMethodData.h; sourceTree = "<group>"; };
                A1F600521F4765010077E83F /* JSPaymentRequestUpdateEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentRequestUpdateEvent.h; sourceTree = "<group>"; };
                A1F600531F4765020077E83F /* JSPaymentRequestUpdateEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentRequestUpdateEventInit.cpp; sourceTree = "<group>"; };
                A1F600541F4765040077E83F /* JSPaymentDetailsUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentDetailsUpdate.h; sourceTree = "<group>"; };
+               A1F6CFFC1FE096210018078C /* ApplePayModifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayModifier.h; sourceTree = "<group>"; };
+               A1F6CFFE1FE096210018078C /* ApplePayModifier.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayModifier.idl; sourceTree = "<group>"; };
+               A1F6D0031FE096F60018078C /* ApplePayPaymentMethodType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayPaymentMethodType.h; sourceTree = "<group>"; };
+               A1F6D0051FE096F60018078C /* ApplePayPaymentMethodType.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayPaymentMethodType.idl; sourceTree = "<group>"; };
+               A1F6D00A1FE099210018078C /* JSApplePayModifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayModifier.cpp; sourceTree = "<group>"; };
+               A1F6D00C1FE099220018078C /* JSApplePayModifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayModifier.h; sourceTree = "<group>"; };
+               A1F6D00D1FE099640018078C /* JSApplePayPaymentMethodType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayPaymentMethodType.cpp; sourceTree = "<group>"; };
+               A1F6D00E1FE099640018078C /* JSApplePayPaymentMethodType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayPaymentMethodType.h; sourceTree = "<group>"; };
                A1F76B101F44C2450014C318 /* PaymentRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentRequest.h; sourceTree = "<group>"; };
                A1F76B111F44C2450014C318 /* PaymentRequest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PaymentRequest.cpp; sourceTree = "<group>"; };
                A1F76B121F44C2450014C318 /* PaymentRequest.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PaymentRequest.idl; sourceTree = "<group>"; };
                                1A8A64401D19FCFB00D0E00F /* ApplePayPaymentMethodSelectedEvent.cpp */,
                                1A8A64421D19FCFB00D0E00F /* ApplePayPaymentMethodSelectedEvent.h */,
                                1A8A64431D19FCFB00D0E00F /* ApplePayPaymentMethodSelectedEvent.idl */,
+                               A1F6D0031FE096F60018078C /* ApplePayPaymentMethodType.h */,
+                               A1F6D0051FE096F60018078C /* ApplePayPaymentMethodType.idl */,
                                1ADFDFDA1E71D8DF008F5D34 /* ApplePayPaymentMethodUpdate.h */,
                                1ADFDFDB1E71D8DF008F5D34 /* ApplePayPaymentMethodUpdate.idl */,
                                7C6522F21E00A51700677F22 /* ApplePayPaymentPass.h */,
                                A1DF5A8A1F7EC0000058A477 /* JSApplePayMerchantCapability.h */,
                                A1F9296D1F8D9F5A00523AF3 /* JSApplePayMerchantValidationEvent.cpp */,
                                A1F9296E1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h */,
+                               A1F6D00A1FE099210018078C /* JSApplePayModifier.cpp */,
+                               A1F6D00C1FE099220018078C /* JSApplePayModifier.h */,
                                7C65231D1E018B5A00677F22 /* JSApplePayPayment.cpp */,
                                7C65230A1E00DBB400677F22 /* JSApplePayPayment.h */,
                                1ADFDFE31E71DCA0008F5D34 /* JSApplePayPaymentAuthorizationResult.cpp */,
                                7C65230E1E00DBB400677F22 /* JSApplePayPaymentMethod.h */,
                                1AE96A7C1D1A0A8000B86768 /* JSApplePayPaymentMethodSelectedEvent.cpp */,
                                1AE96A7D1D1A0A8000B86768 /* JSApplePayPaymentMethodSelectedEvent.h */,
+                               A1F6D00D1FE099640018078C /* JSApplePayPaymentMethodType.cpp */,
+                               A1F6D00E1FE099640018078C /* JSApplePayPaymentMethodType.h */,
                                1ADFDFE51E71DCA0008F5D34 /* JSApplePayPaymentMethodUpdate.cpp */,
                                1ADFDFE61E71DCA0008F5D34 /* JSApplePayPaymentMethodUpdate.h */,
-                               A1CBEF5F1F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp */,
-                               A1CBEF601F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.h */,
                                7C65230F1E00DBB400677F22 /* JSApplePayPaymentPass.cpp */,
                                7C6523101E00DBB400677F22 /* JSApplePayPaymentPass.h */,
                                7C6579EB1E00856600E3A27A /* JSApplePayPaymentRequest.cpp */,
                                A1F929671F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp */,
                                A1F929661F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h */,
                                A1F929681F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.idl */,
+                               A1F6CFFC1FE096210018078C /* ApplePayModifier.h */,
+                               A1F6CFFE1FE096210018078C /* ApplePayModifier.idl */,
                                A1DF5AA11F7EE1130058A477 /* ApplePayPaymentHandler.cpp */,
                                A1DF5AA01F7EE1130058A477 /* ApplePayPaymentHandler.h */,
-                               A1CBEF511F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp */,
-                               A1CBEF501F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h */,
-                               A1CBEF521F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.idl */,
                                A1DF5A7C1F7EBD0B0058A477 /* ApplePayRequest.h */,
                                A1DF5A7E1F7EBD0B0058A477 /* ApplePayRequest.idl */,
                        );
                                7C6579E31E00827000E3A27A /* ApplePayLineItem.h in Headers */,
                                A1DF5A861F7EBDF20058A477 /* ApplePayMerchantCapability.h in Headers */,
                                A1F929691F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h in Headers */,
+                               A1F6CFFF1FE096210018078C /* ApplePayModifier.h in Headers */,
                                7C6523011E00D03400677F22 /* ApplePayPayment.h in Headers */,
                                1A8A64521D19FCFB00D0E00F /* ApplePayPaymentAuthorizedEvent.h in Headers */,
                                7C6522FB1E00C90900677F22 /* ApplePayPaymentContact.h in Headers */,
                                A1DF5AA21F7EE1130058A477 /* ApplePayPaymentHandler.h in Headers */,
                                7C6522EF1E00A4C700677F22 /* ApplePayPaymentMethod.h in Headers */,
                                1A8A64561D19FCFC00D0E00F /* ApplePayPaymentMethodSelectedEvent.h in Headers */,
-                               A1CBEF531F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h in Headers */,
+                               A1F6D0061FE096F60018078C /* ApplePayPaymentMethodType.h in Headers */,
                                7C6522F51E00A51700677F22 /* ApplePayPaymentPass.h in Headers */,
                                7C6579E01E0079F900E3A27A /* ApplePayPaymentRequest.h in Headers */,
                                A1DF5A7F1F7EBD0B0058A477 /* ApplePayRequest.h in Headers */,
                                7C6579F01E00856600E3A27A /* JSApplePayLineItem.h in Headers */,
                                A1DF5A8E1F7EC0020058A477 /* JSApplePayMerchantCapability.h in Headers */,
                                A1F929701F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h in Headers */,
+                               A1F6D0121FE099B40018078C /* JSApplePayModifier.h in Headers */,
                                7C6523141E00DBB400677F22 /* JSApplePayPayment.h in Headers */,
                                1AE96A8B1D1A0DDD00B86768 /* JSApplePayPaymentAuthorizedEvent.h in Headers */,
                                7C6523161E00DBB500677F22 /* JSApplePayPaymentContact.h in Headers */,
                                7C6523181E00DBB500677F22 /* JSApplePayPaymentMethod.h in Headers */,
                                1AE96A8D1D1A0DDD00B86768 /* JSApplePayPaymentMethodSelectedEvent.h in Headers */,
-                               A1CBEF621F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.h in Headers */,
+                               A1F6D00F1FE099940018078C /* JSApplePayPaymentMethodType.h in Headers */,
                                7C65231A1E00DBB500677F22 /* JSApplePayPaymentPass.h in Headers */,
                                7C6579F21E00856600E3A27A /* JSApplePayPaymentRequest.h in Headers */,
                                A1DF5A8F1F7EC0020058A477 /* JSApplePayRequest.h in Headers */,
                        files = (
                                A9787CB41F5F5C6600C551C6 /* AccessibilityMediaObject.cpp in Sources */,
                                A1F9296A1F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp in Sources */,
-                               A1CBEF541F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp in Sources */,
                                CD0EEE0E14743F39003EAFA2 /* AudioDestinationIOS.cpp in Sources */,
                                CD5596911475B678001D0BD0 /* AudioFileReaderIOS.cpp in Sources */,
                                CDA79827170A279100D45C55 /* AudioSessionIOS.mm in Sources */,
                                CD063F821E23FA8900812BE3 /* InitDataRegistry.cpp in Sources */,
                                6A72798C1F16C29C003F39B8 /* InspectorShaderProgram.cpp in Sources */,
                                A1F9296F1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.cpp in Sources */,
-                               A1CBEF611F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp in Sources */,
+                               A1F6D0111FE099B20018078C /* JSApplePayModifier.cpp in Sources */,
+                               A1F6D0101FE099960018078C /* JSApplePayPaymentMethodType.cpp in Sources */,
                                538EC93E1F99BF5A004D22A8 /* JSQuickTimePluginReplacement.cpp in Sources */,
                                935C477009AC4D7300A6AAB4 /* KeyEventMac.mm in Sources */,
                                CDA98E0B1603CD6000FEA3B1 /* LegacyCDM.cpp in Sources */,
index 9fb045d..9f49570 100644 (file)
@@ -53,7 +53,6 @@ namespace WebCore {
     macro(animationend) \
     macro(animationiteration) \
     macro(animationstart) \
-    macro(applepaypaymentmethodchanged) \
     macro(applepayvalidatemerchant) \
     macro(audioend) \
     macro(audioprocess) \
index 1889069..20b5a13 100644 (file)
@@ -42,7 +42,6 @@ XMLHttpRequestProgressEvent
 ApplePayMerchantValidationEvent conditional=APPLE_PAY
 ApplePayPaymentAuthorizedEvent conditional=APPLE_PAY
 ApplePayPaymentMethodSelectedEvent conditional=APPLE_PAY
-ApplePayPaymentMethodUpdateEvent conditional=APPLE_PAY
 ApplePayShippingContactSelectedEvent conditional=APPLE_PAY
 ApplePayShippingMethodSelectedEvent conditional=APPLE_PAY
 ApplePayValidateMerchantEvent conditional=APPLE_PAY
index 7e675c9..a21cb1f 100644 (file)
@@ -105,6 +105,41 @@ void MockPaymentCoordinator::completeMerchantValidation(const PaymentMerchantSes
     });
 }
 
+static ApplePayLineItem convert(const ApplePaySessionPaymentRequest::LineItem& lineItem)
+{
+    ApplePayLineItem result;
+    result.type = lineItem.type;
+    result.label = lineItem.label;
+    result.amount = lineItem.amount;
+    return result;
+}
+
+void MockPaymentCoordinator::updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems& totalAndLineItems)
+{
+    m_total = convert(totalAndLineItems.total);
+    m_lineItems.clear();
+    for (auto& lineItem : totalAndLineItems.lineItems)
+        m_lineItems.append(convert(lineItem));
+}
+
+void MockPaymentCoordinator::completeShippingMethodSelection(std::optional<ShippingMethodUpdate>&& shippingMethodUpdate)
+{
+    if (shippingMethodUpdate)
+        updateTotalAndLineItems(shippingMethodUpdate->newTotalAndLineItems);
+}
+
+void MockPaymentCoordinator::completeShippingContactSelection(std::optional<ShippingContactUpdate>&& shippingContactUpdate)
+{
+    if (shippingContactUpdate)
+        updateTotalAndLineItems(shippingContactUpdate->newTotalAndLineItems);
+}
+    
+void MockPaymentCoordinator::completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&& paymentMethodUpdate)
+{
+    if (paymentMethodUpdate)
+        updateTotalAndLineItems(paymentMethodUpdate->newTotalAndLineItems);
+}
+
 void MockPaymentCoordinator::changeShippingOption(String&& shippingOption)
 {
     dispatchIfShowing([mainFrame = makeRef(m_mainFrame), shippingOption = WTFMove(shippingOption)]() mutable {
index bbfb398..3214631 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(APPLE_PAY)
 
+#include "ApplePayLineItem.h"
 #include "MockPaymentAddress.h"
 #include "PaymentCoordinatorClient.h"
 
@@ -45,6 +46,9 @@ public:
     void acceptPayment();
     void cancelPayment();
 
+    const ApplePayLineItem& total() const { return m_total; }
+    const Vector<ApplePayLineItem>& lineItems() const { return m_lineItems; }
+
     void ref() const { }
     void deref() const { }
 
@@ -55,16 +59,20 @@ private:
     void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&&);
     bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final;
     void completeMerchantValidation(const PaymentMerchantSession&) final;
-    void completeShippingMethodSelection(std::optional<ShippingMethodUpdate>&&) final { }
-    void completeShippingContactSelection(std::optional<ShippingContactUpdate>&&) final { }
-    void completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&&) final { }
+    void completeShippingMethodSelection(std::optional<ShippingMethodUpdate>&&) final;
+    void completeShippingContactSelection(std::optional<ShippingContactUpdate>&&) final;
+    void completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&&) final;
     void completePaymentSession(std::optional<PaymentAuthorizationResult>&&) final;
     void abortPaymentSession() final;
     void cancelPaymentSession() final;
     void paymentCoordinatorDestroyed() final;
 
+    void updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems&);
+
     MainFrame& m_mainFrame;
     MockPaymentAddress m_shippingAddress;
+    ApplePayLineItem m_total;
+    Vector<ApplePayLineItem> m_lineItems;
 };
 
 } // namespace WebCore
index 99ebf82..2314eed 100644 (file)
@@ -32,4 +32,7 @@
     void changePaymentMethod(ApplePayPaymentMethod paymentMethod);
     void acceptPayment();
     void cancelPayment();
+
+    readonly attribute ApplePayLineItem total;
+    readonly attribute sequence<ApplePayLineItem> lineItems;
 };