<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213647] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213647">213647</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2017-03-09 10:33:17 -0800 (Thu, 09 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add new delegate methods
https://bugs.webkit.org/show_bug.cgi?id=169394
Part of rdar://problem/28880714.

Reviewed by Tim Horton.

* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h:
* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(-[WKPaymentAuthorizationViewControllerDelegate invalidate]):
(toShippingMethod):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:handler:]):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:handler:]):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:handler:]):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:handler:]):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:completion:]):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:completion:]):
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:completion:]):
(WebKit::toPKPaymentAuthorizationStatus):
(WebKit::toPKPaymentErrorCode):
(WebKit::toNSError):
(WebKit::toNSErrors):
(WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentSession):
(WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection):
(WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingContactSelection):
(WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessApplePaycocoaWebPaymentCoordinatorProxyCocoah">trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessApplePaycocoaWebPaymentCoordinatorProxyCocoamm">trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213646 => 213647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-09 17:59:46 UTC (rev 213646)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-09 18:33:17 UTC (rev 213647)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2017-03-08  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add new delegate methods
+        https://bugs.webkit.org/show_bug.cgi?id=169394
+        Part of rdar://problem/28880714.
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h:
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (-[WKPaymentAuthorizationViewControllerDelegate invalidate]):
+        (toShippingMethod):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:handler:]):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectPaymentMethod:handler:]):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:handler:]):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:handler:]):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didAuthorizePayment:completion:]):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingMethod:completion:]):
+        (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewController:didSelectShippingContact:completion:]):
+        (WebKit::toPKPaymentAuthorizationStatus):
+        (WebKit::toPKPaymentErrorCode):
+        (WebKit::toNSError):
+        (WebKit::toNSErrors):
+        (WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentSession):
+        (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection):
+        (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingContactSelection):
+        (WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection):
+
</ins><span class="cx"> 2017-03-09  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WKWebView should automatically respect insets from the view controller hierarchy
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessApplePaycocoaWebPaymentCoordinatorProxyCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h (213646 => 213647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h        2017-03-09 17:59:46 UTC (rev 213646)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h        2017-03-09 18:33:17 UTC (rev 213647)
</span><span class="lines">@@ -52,10 +52,17 @@
</span><span class="cx">     BlockPtr&lt;void (PKPaymentMerchantSession *, NSError *)&gt; _sessionBlock;
</span><span class="cx"> 
</span><span class="cx">     BOOL _didReachFinalState;
</span><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+    BlockPtr&lt;void (PKPaymentAuthorizationResult *)&gt; _paymentAuthorizedCompletion;
+    BlockPtr&lt;void (PKPaymentRequestPaymentMethodUpdate *)&gt; _didSelectPaymentMethodCompletion;
+    BlockPtr&lt;void (PKPaymentRequestShippingMethodUpdate *)&gt; _didSelectShippingMethodCompletion;
+    BlockPtr&lt;void (PKPaymentRequestShippingContactUpdate *)&gt; _didSelectShippingContactCompletion;
+#else
</ins><span class="cx">     BlockPtr&lt;void (PKPaymentAuthorizationStatus)&gt; _paymentAuthorizedCompletion;
</span><span class="cx">     BlockPtr&lt;void (NSArray *)&gt; _didSelectPaymentMethodCompletion;
</span><span class="cx">     BlockPtr&lt;void (PKPaymentAuthorizationStatus, NSArray *)&gt; _didSelectShippingMethodCompletion;
</span><span class="cx">     BlockPtr&lt;void (PKPaymentAuthorizationStatus, NSArray *, NSArray *)&gt; _didSelectShippingContactCompletion;
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithPaymentCoordinatorProxy:(WebKit::WebPaymentCoordinatorProxy&amp;)webPaymentCoordinatorProxy;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessApplePaycocoaWebPaymentCoordinatorProxyCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (213646 => 213647)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm        2017-03-09 17:59:46 UTC (rev 213646)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm        2017-03-09 18:33:17 UTC (rev 213647)
</span><span class="lines">@@ -57,6 +57,14 @@
</span><span class="cx"> SOFT_LINK_CONSTANT(PassKit, PKPaymentNetworkPrivateLabel, NSString *);
</span><span class="cx"> SOFT_LINK_CONSTANT(PassKit, PKPaymentNetworkVisa, NSString *);
</span><span class="cx"> 
</span><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+SOFT_LINK_CLASS(PassKit, PKPaymentAuthorizationResult)
+SOFT_LINK_CLASS(PassKit, PKPaymentRequestPaymentMethodUpdate)
+SOFT_LINK_CLASS(PassKit, PKPaymentRequestShippingContactUpdate)
+SOFT_LINK_CLASS(PassKit, PKPaymentRequestShippingMethodUpdate)
+SOFT_LINK_CONSTANT(PassKit, PKPaymentErrorDomain, NSString *);
+#endif
+
</ins><span class="cx"> typedef void (^PKCanMakePaymentsCompletion)(BOOL isValid, NSError *error);
</span><span class="cx"> extern &quot;C&quot; void PKCanMakePaymentsWithMerchantIdentifierAndDomain(NSString *identifier, NSString *domain, PKCanMakePaymentsCompletion completion);
</span><span class="cx"> 
</span><span class="lines">@@ -78,7 +86,11 @@
</span><span class="cx"> {
</span><span class="cx">     _webPaymentCoordinatorProxy = nullptr;
</span><span class="cx">     if (_paymentAuthorizedCompletion) {
</span><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+        _paymentAuthorizedCompletion(adoptNS([allocPKPaymentAuthorizationResultInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:@[ ]]).get());
+#else
</ins><span class="cx">         _paymentAuthorizedCompletion(PKPaymentAuthorizationStatusFailure);
</span><ins>+#endif
</ins><span class="cx">         _paymentAuthorizedCompletion = nullptr;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -109,10 +121,24 @@
</span><span class="cx">     }];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus))completion
</del><ins>+static WebCore::PaymentRequest::ShippingMethod toShippingMethod(PKShippingMethod *shippingMethod)
</ins><span class="cx"> {
</span><ins>+    ASSERT(shippingMethod);
+
+    WebCore::PaymentRequest::ShippingMethod result;
+    result.label = shippingMethod.label;
+    result.detail = shippingMethod.detail;
+    result.amount = [shippingMethod.amount decimalNumberByMultiplyingByPowerOf10:2].integerValue;
+    result.identifier = shippingMethod.identifier;
+
+    return result;
+}
+
+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment handler:(void (^)(PKPaymentAuthorizationResult *result))completion
+{
</ins><span class="cx">     if (!_webPaymentCoordinatorProxy) {
</span><del>-        completion(PKPaymentAuthorizationStatusFailure);
</del><ins>+        completion(adoptNS([allocPKPaymentAuthorizationResultInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:@[ ]]).get());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -122,23 +148,21 @@
</span><span class="cx">     _webPaymentCoordinatorProxy-&gt;didAuthorizePayment(WebCore::Payment(payment));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static WebCore::PaymentRequest::ShippingMethod toShippingMethod(PKShippingMethod *shippingMethod)
</del><ins>+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod handler:(void (^)(PKPaymentRequestPaymentMethodUpdate *update))completion
</ins><span class="cx"> {
</span><del>-    ASSERT(shippingMethod);
</del><ins>+    if (!_webPaymentCoordinatorProxy) {
+        completion(adoptNS([allocPKPaymentRequestPaymentMethodUpdateInstance() initWithStatus:PKPaymentAuthorizationStatusFailure paymentSummaryItems:@[ ]]).get());
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    WebCore::PaymentRequest::ShippingMethod result;
-    result.label = shippingMethod.label;
-    result.detail = shippingMethod.detail;
-    result.amount = [shippingMethod.amount decimalNumberByMultiplyingByPowerOf10:2].integerValue;
-    result.identifier = shippingMethod.identifier;
-
-    return result;
</del><ins>+    ASSERT(!_didSelectPaymentMethodCompletion);
+    _didSelectPaymentMethodCompletion = completion;
+    _webPaymentCoordinatorProxy-&gt;didSelectPaymentMethod(WebCore::PaymentMethod(paymentMethod));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray&lt;PKPaymentSummaryItem *&gt; *summaryItems))completion
-{
</del><ins>+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod handler:(void (^)(PKPaymentRequestShippingMethodUpdate *update))completion {
</ins><span class="cx">     if (!_webPaymentCoordinatorProxy) {
</span><del>-        completion(PKPaymentAuthorizationStatusFailure, @[]);
</del><ins>+        completion(adoptNS([allocPKPaymentRequestShippingMethodUpdateInstance() initWithStatus:PKPaymentAuthorizationStatusFailure paymentSummaryItems:@[ ]]).get());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -147,10 +171,10 @@
</span><span class="cx">     _webPaymentCoordinatorProxy-&gt;didSelectShippingMethod(toShippingMethod(shippingMethod));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray&lt;PKShippingMethod *&gt; *shippingMethods, NSArray&lt;PKPaymentSummaryItem *&gt; *summaryItems))completion
</del><ins>+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact handler:(void (^)(PKPaymentRequestShippingContactUpdate *update))completion
</ins><span class="cx"> {
</span><span class="cx">     if (!_webPaymentCoordinatorProxy) {
</span><del>-        completion(PKPaymentAuthorizationStatusFailure, @[], @[]);
</del><ins>+        completion(adoptNS([allocPKPaymentRequestShippingContactUpdateInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:@[ ] paymentSummaryItems:@[ ] shippingMethods:@[ ]]).get());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -158,11 +182,36 @@
</span><span class="cx">     _didSelectShippingContactCompletion = completion;
</span><span class="cx">     _webPaymentCoordinatorProxy-&gt;didSelectShippingContact(WebCore::PaymentContact(contact));
</span><span class="cx"> }
</span><ins>+#else
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus))completion
+{
+    if (!_webPaymentCoordinatorProxy) {
+        completion(PKPaymentAuthorizationStatusFailure);
+        return;
+    }
</ins><span class="cx"> 
</span><ins>+    ASSERT(!_paymentAuthorizedCompletion);
+    _paymentAuthorizedCompletion = completion;
+
+    _webPaymentCoordinatorProxy-&gt;didAuthorizePayment(WebCore::Payment(payment));
+}
+
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray&lt;PKPaymentSummaryItem *&gt; *summaryItems))completion
+{
+    if (!_webPaymentCoordinatorProxy) {
+        completion(PKPaymentAuthorizationStatusFailure, @[ ]);
+        return;
+    }
+
+    ASSERT(!_didSelectShippingMethodCompletion);
+    _didSelectShippingMethodCompletion = completion;
+    _webPaymentCoordinatorProxy-&gt;didSelectShippingMethod(toShippingMethod(shippingMethod));
+}
+
</ins><span class="cx"> - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod completion:(void (^)(NSArray&lt;PKPaymentSummaryItem *&gt; *summaryItems))completion
</span><span class="cx"> {
</span><span class="cx">     if (!_webPaymentCoordinatorProxy) {
</span><del>-        completion(@[]);
</del><ins>+        completion(@[ ]);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -172,6 +221,19 @@
</span><span class="cx">     _webPaymentCoordinatorProxy-&gt;didSelectPaymentMethod(WebCore::PaymentMethod(paymentMethod));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray&lt;PKShippingMethod *&gt; *shippingMethods, NSArray&lt;PKPaymentSummaryItem *&gt; *summaryItems))completion
+{
+    if (!_webPaymentCoordinatorProxy) {
+        completion(PKPaymentAuthorizationStatusFailure, @[ ], @[ ]);
+        return;
+    }
+
+    ASSERT(!_didSelectShippingContactCompletion);
+    _didSelectShippingContactCompletion = completion;
+    _webPaymentCoordinatorProxy-&gt;didSelectShippingContact(WebCore::PaymentContact(contact));
+}
+#endif
+
</ins><span class="cx"> - (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
</span><span class="cx"> {
</span><span class="cx">     if (!_webPaymentCoordinatorProxy)
</span><span class="lines">@@ -303,6 +365,31 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static PKPaymentAuthorizationStatus toPKPaymentAuthorizationStatus(WebCore::PaymentAuthorizationStatus status)
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
+    switch (status) {
+    case WebCore::PaymentAuthorizationStatus::Success:
+        return PKPaymentAuthorizationStatusSuccess;
+    case WebCore::PaymentAuthorizationStatus::Failure:
+        return PKPaymentAuthorizationStatusFailure;
+    case WebCore::PaymentAuthorizationStatus::InvalidBillingPostalAddress:
+        return PKPaymentAuthorizationStatusInvalidBillingPostalAddress;
+    case WebCore::PaymentAuthorizationStatus::InvalidShippingPostalAddress:
+        return PKPaymentAuthorizationStatusInvalidShippingPostalAddress;
+    case WebCore::PaymentAuthorizationStatus::InvalidShippingContact:
+        return PKPaymentAuthorizationStatusInvalidShippingContact;
+    case WebCore::PaymentAuthorizationStatus::PINRequired:
+        return PKPaymentAuthorizationStatusPINRequired;
+    case WebCore::PaymentAuthorizationStatus::PINIncorrect:
+        return PKPaymentAuthorizationStatusPINIncorrect;
+    case WebCore::PaymentAuthorizationStatus::PINLockout:
+        return PKPaymentAuthorizationStatusPINLockout;
+    }
+#pragma clang diagnostic pop
+}
+
</ins><span class="cx"> #if USE(APPLE_INTERNAL_SDK) &amp;&amp; __has_include(&lt;WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm&gt;)
</span><span class="cx"> #import &lt;WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm&gt;
</span><span class="cx"> #else
</span><span class="lines">@@ -440,31 +527,44 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static PKPaymentAuthorizationStatus toPKPaymentAuthorizationStatus(WebCore::PaymentAuthorizationStatus status)
</del><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+static PKPaymentErrorCode toPKPaymentErrorCode(WebCore::PaymentError::Code code)
</ins><span class="cx"> {
</span><del>-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-    switch (status) {
-    case WebCore::PaymentAuthorizationStatus::Success:
-        return PKPaymentAuthorizationStatusSuccess;
-    case WebCore::PaymentAuthorizationStatus::Failure:
-        return PKPaymentAuthorizationStatusFailure;
-    case WebCore::PaymentAuthorizationStatus::InvalidBillingPostalAddress:
-        return PKPaymentAuthorizationStatusInvalidBillingPostalAddress;
-    case WebCore::PaymentAuthorizationStatus::InvalidShippingPostalAddress:
-        return PKPaymentAuthorizationStatusInvalidShippingPostalAddress;
-    case WebCore::PaymentAuthorizationStatus::InvalidShippingContact:
-        return PKPaymentAuthorizationStatusInvalidShippingContact;
-    case WebCore::PaymentAuthorizationStatus::PINRequired:
-        return PKPaymentAuthorizationStatusPINRequired;
-    case WebCore::PaymentAuthorizationStatus::PINIncorrect:
-        return PKPaymentAuthorizationStatusPINIncorrect;
-    case WebCore::PaymentAuthorizationStatus::PINLockout:
-        return PKPaymentAuthorizationStatusPINLockout;
</del><ins>+    switch (code) {
+    case WebCore::PaymentError::Code::Unknown:
+        return PKPaymentUnknownError;
+    case WebCore::PaymentError::Code::ShippingContactInvalid:
+        return PKPaymentShippingContactInvalidError;
+    case WebCore::PaymentError::Code::BillingContactInvalid:
+        return PKPaymentBillingContactInvalidError;
+    case WebCore::PaymentError::Code::AddressUnservicable:
+        return PKPaymentShippingAddressUnserviceableError;
</ins><span class="cx">     }
</span><del>-#pragma clang diagnostic pop
</del><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static RetainPtr&lt;NSError&gt; toNSError(const WebCore::PaymentError&amp; error)
+{
+    auto userInfo = adoptNS([[NSMutableDictionary alloc] init]);
+    [userInfo setObject:error.message forKey:NSLocalizedDescriptionKey];
+
+    // FIXME: Set the contact field key.
+
+    return adoptNS([[NSError alloc] initWithDomain:getPKPaymentErrorDomain() code:toPKPaymentErrorCode(error.code) userInfo:userInfo.get()]);
+}
+
+static RetainPtr&lt;NSArray&gt; toNSErrors(const Vector&lt;WebCore::PaymentError&gt;&amp; errors)
+{
+    auto result = adoptNS([[NSMutableArray alloc] init]);
+
+    for (auto error : errors) {
+        if (auto nsError = toNSError(error))
+            [result addObject:nsError.get()];
+    }
+
+    return result;
+}
+#endif
+
</ins><span class="cx"> void WebPaymentCoordinatorProxy::platformCompletePaymentSession(const std::optional&lt;WebCore::PaymentAuthorizationResult&gt;&amp; result)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_paymentAuthorizationViewController);
</span><span class="lines">@@ -471,9 +571,14 @@
</span><span class="cx">     ASSERT(m_paymentAuthorizationViewControllerDelegate);
</span><span class="cx"> 
</span><span class="cx">     auto status = result ? result-&gt;status : WebCore::PaymentAuthorizationStatus::Success;
</span><ins>+    m_paymentAuthorizationViewControllerDelegate-&gt;_didReachFinalState = WebCore::isFinalStateStatus(status);
</ins><span class="cx"> 
</span><del>-    m_paymentAuthorizationViewControllerDelegate-&gt;_didReachFinalState = WebCore::isFinalStateStatus(status);
</del><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+    auto pkPaymentAuthorizationResult = adoptNS([allocPKPaymentAuthorizationResultInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:result ? toNSErrors(result-&gt;errors).get() : @[ ]]);
+    m_paymentAuthorizationViewControllerDelegate-&gt;_paymentAuthorizedCompletion(pkPaymentAuthorizationResult.get());
+#else
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_paymentAuthorizedCompletion(toPKPaymentAuthorizationStatus(status));
</span><ins>+#endif
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_paymentAuthorizedCompletion = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -496,7 +601,12 @@
</span><span class="cx">     if (update)
</span><span class="cx">         m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems = toPKPaymentSummaryItems(update-&gt;newTotalAndLineItems);
</span><span class="cx"> 
</span><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+    auto pkShippingMethodUpdate = adoptNS([allocPKPaymentRequestShippingMethodUpdateInstance() initWithStatus:toPKPaymentAuthorizationStatus(status) paymentSummaryItems:m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems.get()]);
+    m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectShippingMethodCompletion(pkShippingMethodUpdate.get());
+#else
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectShippingMethodCompletion(toPKPaymentAuthorizationStatus(status), m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems.get());
</span><ins>+#endif
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectShippingMethodCompletion = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -517,7 +627,12 @@
</span><span class="cx">         m_paymentAuthorizationViewControllerDelegate-&gt;_shippingMethods = WTFMove(shippingMethods);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+    auto pkShippingContactUpdate = adoptNS([allocPKPaymentRequestShippingContactUpdateInstance() initWithStatus:toPKPaymentAuthorizationStatus(status) errors:update ? toNSErrors(update-&gt;errors).get() : @[ ] paymentSummaryItems:m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems.get() shippingMethods:m_paymentAuthorizationViewControllerDelegate-&gt;_shippingMethods.get()]);
+    m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectShippingContactCompletion(pkShippingContactUpdate.get());
+#else
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectShippingContactCompletion(toPKPaymentAuthorizationStatus(status), m_paymentAuthorizationViewControllerDelegate-&gt;_shippingMethods.get(), m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems.get());
</span><ins>+#endif
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectShippingContactCompletion = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -526,20 +641,16 @@
</span><span class="cx">     ASSERT(m_paymentAuthorizationViewController);
</span><span class="cx">     ASSERT(m_paymentAuthorizationViewControllerDelegate);
</span><span class="cx"> 
</span><del>-    if (update) {
-        auto paymentSummaryItems = adoptNS([[NSMutableArray alloc] init]);
-        for (auto&amp; lineItem : update-&gt;newTotalAndLineItems.lineItems) {
-            if (auto summaryItem = toPKPaymentSummaryItem(lineItem))
-                [paymentSummaryItems addObject:summaryItem.get()];
-        }
</del><ins>+    if (update)
+        m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems = toPKPaymentSummaryItems(update-&gt;newTotalAndLineItems);
</ins><span class="cx"> 
</span><del>-        if (auto totalItem = toPKPaymentSummaryItem(update-&gt;newTotalAndLineItems.total))
-            [paymentSummaryItems addObject:totalItem.get()];
-
-        m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems = WTFMove(paymentSummaryItems);
-    }
-
</del><ins>+#if (PLATFORM(MAC) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101300) || (PLATFORM(IOS) &amp;&amp; __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= 110000)
+    auto status = update ? update-&gt;status : WebCore::PaymentAuthorizationStatus::Success;
+    auto pkPaymentMethodUpdate = adoptNS([allocPKPaymentRequestPaymentMethodUpdateInstance() initWithStatus:toPKPaymentAuthorizationStatus(status) paymentSummaryItems:m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems.get()]);
+    m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectPaymentMethodCompletion(pkPaymentMethodUpdate.get());
+#else
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectPaymentMethodCompletion(m_paymentAuthorizationViewControllerDelegate-&gt;_paymentSummaryItems.get());
</span><ins>+#endif
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_didSelectPaymentMethodCompletion = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>