Title: [213647] trunk/Source/WebKit2
Revision
213647
Author
ander...@apple.com
Date
2017-03-09 10:33:17 -0800 (Thu, 09 Mar 2017)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (213646 => 213647)


--- 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)
@@ -1,3 +1,31 @@
+2017-03-08  Anders Carlsson  <ander...@apple.com>
+
+        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):
+
 2017-03-09  Tim Horton  <timothy_hor...@apple.com>
 
         WKWebView should automatically respect insets from the view controller hierarchy

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h (213646 => 213647)


--- 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)
@@ -52,10 +52,17 @@
     BlockPtr<void (PKPaymentMerchantSession *, NSError *)> _sessionBlock;
 
     BOOL _didReachFinalState;
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+    BlockPtr<void (PKPaymentAuthorizationResult *)> _paymentAuthorizedCompletion;
+    BlockPtr<void (PKPaymentRequestPaymentMethodUpdate *)> _didSelectPaymentMethodCompletion;
+    BlockPtr<void (PKPaymentRequestShippingMethodUpdate *)> _didSelectShippingMethodCompletion;
+    BlockPtr<void (PKPaymentRequestShippingContactUpdate *)> _didSelectShippingContactCompletion;
+#else
     BlockPtr<void (PKPaymentAuthorizationStatus)> _paymentAuthorizedCompletion;
     BlockPtr<void (NSArray *)> _didSelectPaymentMethodCompletion;
     BlockPtr<void (PKPaymentAuthorizationStatus, NSArray *)> _didSelectShippingMethodCompletion;
     BlockPtr<void (PKPaymentAuthorizationStatus, NSArray *, NSArray *)> _didSelectShippingContactCompletion;
+#endif
 }
 
 - (instancetype)initWithPaymentCoordinatorProxy:(WebKit::WebPaymentCoordinatorProxy&)webPaymentCoordinatorProxy;

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (213646 => 213647)


--- 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)
@@ -57,6 +57,14 @@
 SOFT_LINK_CONSTANT(PassKit, PKPaymentNetworkPrivateLabel, NSString *);
 SOFT_LINK_CONSTANT(PassKit, PKPaymentNetworkVisa, NSString *);
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 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
+
 typedef void (^PKCanMakePaymentsCompletion)(BOOL isValid, NSError *error);
 extern "C" void PKCanMakePaymentsWithMerchantIdentifierAndDomain(NSString *identifier, NSString *domain, PKCanMakePaymentsCompletion completion);
 
@@ -78,7 +86,11 @@
 {
     _webPaymentCoordinatorProxy = nullptr;
     if (_paymentAuthorizedCompletion) {
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+        _paymentAuthorizedCompletion(adoptNS([allocPKPaymentAuthorizationResultInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:@[ ]]).get());
+#else
         _paymentAuthorizedCompletion(PKPaymentAuthorizationStatusFailure);
+#endif
         _paymentAuthorizedCompletion = nullptr;
     }
 }
@@ -109,10 +121,24 @@
     }];
 }
 
-- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus))completion
+static WebCore::PaymentRequest::ShippingMethod toShippingMethod(PKShippingMethod *shippingMethod)
 {
+    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) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment handler:(void (^)(PKPaymentAuthorizationResult *result))completion
+{
     if (!_webPaymentCoordinatorProxy) {
-        completion(PKPaymentAuthorizationStatusFailure);
+        completion(adoptNS([allocPKPaymentAuthorizationResultInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:@[ ]]).get());
         return;
     }
 
@@ -122,23 +148,21 @@
     _webPaymentCoordinatorProxy->didAuthorizePayment(WebCore::Payment(payment));
 }
 
-static WebCore::PaymentRequest::ShippingMethod toShippingMethod(PKShippingMethod *shippingMethod)
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod handler:(void (^)(PKPaymentRequestPaymentMethodUpdate *update))completion
 {
-    ASSERT(shippingMethod);
+    if (!_webPaymentCoordinatorProxy) {
+        completion(adoptNS([allocPKPaymentRequestPaymentMethodUpdateInstance() initWithStatus:PKPaymentAuthorizationStatusFailure paymentSummaryItems:@[ ]]).get());
+        return;
+    }
 
-    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;
+    ASSERT(!_didSelectPaymentMethodCompletion);
+    _didSelectPaymentMethodCompletion = completion;
+    _webPaymentCoordinatorProxy->didSelectPaymentMethod(WebCore::PaymentMethod(paymentMethod));
 }
 
-- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKPaymentSummaryItem *> *summaryItems))completion
-{
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod handler:(void (^)(PKPaymentRequestShippingMethodUpdate *update))completion {
     if (!_webPaymentCoordinatorProxy) {
-        completion(PKPaymentAuthorizationStatusFailure, @[]);
+        completion(adoptNS([allocPKPaymentRequestShippingMethodUpdateInstance() initWithStatus:PKPaymentAuthorizationStatusFailure paymentSummaryItems:@[ ]]).get());
         return;
     }
 
@@ -147,10 +171,10 @@
     _webPaymentCoordinatorProxy->didSelectShippingMethod(toShippingMethod(shippingMethod));
 }
 
-- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKShippingMethod *> *shippingMethods, NSArray<PKPaymentSummaryItem *> *summaryItems))completion
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact handler:(void (^)(PKPaymentRequestShippingContactUpdate *update))completion
 {
     if (!_webPaymentCoordinatorProxy) {
-        completion(PKPaymentAuthorizationStatusFailure, @[], @[]);
+        completion(adoptNS([allocPKPaymentRequestShippingContactUpdateInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:@[ ] paymentSummaryItems:@[ ] shippingMethods:@[ ]]).get());
         return;
     }
 
@@ -158,11 +182,36 @@
     _didSelectShippingContactCompletion = completion;
     _webPaymentCoordinatorProxy->didSelectShippingContact(WebCore::PaymentContact(contact));
 }
+#else
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus))completion
+{
+    if (!_webPaymentCoordinatorProxy) {
+        completion(PKPaymentAuthorizationStatusFailure);
+        return;
+    }
 
+    ASSERT(!_paymentAuthorizedCompletion);
+    _paymentAuthorizedCompletion = completion;
+
+    _webPaymentCoordinatorProxy->didAuthorizePayment(WebCore::Payment(payment));
+}
+
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKPaymentSummaryItem *> *summaryItems))completion
+{
+    if (!_webPaymentCoordinatorProxy) {
+        completion(PKPaymentAuthorizationStatusFailure, @[ ]);
+        return;
+    }
+
+    ASSERT(!_didSelectShippingMethodCompletion);
+    _didSelectShippingMethodCompletion = completion;
+    _webPaymentCoordinatorProxy->didSelectShippingMethod(toShippingMethod(shippingMethod));
+}
+
 - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod completion:(void (^)(NSArray<PKPaymentSummaryItem *> *summaryItems))completion
 {
     if (!_webPaymentCoordinatorProxy) {
-        completion(@[]);
+        completion(@[ ]);
         return;
     }
 
@@ -172,6 +221,19 @@
     _webPaymentCoordinatorProxy->didSelectPaymentMethod(WebCore::PaymentMethod(paymentMethod));
 }
 
+- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray<PKShippingMethod *> *shippingMethods, NSArray<PKPaymentSummaryItem *> *summaryItems))completion
+{
+    if (!_webPaymentCoordinatorProxy) {
+        completion(PKPaymentAuthorizationStatusFailure, @[ ], @[ ]);
+        return;
+    }
+
+    ASSERT(!_didSelectShippingContactCompletion);
+    _didSelectShippingContactCompletion = completion;
+    _webPaymentCoordinatorProxy->didSelectShippingContact(WebCore::PaymentContact(contact));
+}
+#endif
+
 - (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
 {
     if (!_webPaymentCoordinatorProxy)
@@ -303,6 +365,31 @@
     return result;
 }
 
+static PKPaymentAuthorizationStatus toPKPaymentAuthorizationStatus(WebCore::PaymentAuthorizationStatus status)
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+    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
+}
+
 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm>)
 #import <WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm>
 #else
@@ -440,31 +527,44 @@
     return result;
 }
 
-static PKPaymentAuthorizationStatus toPKPaymentAuthorizationStatus(WebCore::PaymentAuthorizationStatus status)
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+static PKPaymentErrorCode toPKPaymentErrorCode(WebCore::PaymentError::Code code)
 {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-    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;
+    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;
     }
-#pragma clang diagnostic pop
 }
 
+static RetainPtr<NSError> toNSError(const WebCore::PaymentError& 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<NSArray> toNSErrors(const Vector<WebCore::PaymentError>& errors)
+{
+    auto result = adoptNS([[NSMutableArray alloc] init]);
+
+    for (auto error : errors) {
+        if (auto nsError = toNSError(error))
+            [result addObject:nsError.get()];
+    }
+
+    return result;
+}
+#endif
+
 void WebPaymentCoordinatorProxy::platformCompletePaymentSession(const std::optional<WebCore::PaymentAuthorizationResult>& result)
 {
     ASSERT(m_paymentAuthorizationViewController);
@@ -471,9 +571,14 @@
     ASSERT(m_paymentAuthorizationViewControllerDelegate);
 
     auto status = result ? result->status : WebCore::PaymentAuthorizationStatus::Success;
+    m_paymentAuthorizationViewControllerDelegate->_didReachFinalState = WebCore::isFinalStateStatus(status);
 
-    m_paymentAuthorizationViewControllerDelegate->_didReachFinalState = WebCore::isFinalStateStatus(status);
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+    auto pkPaymentAuthorizationResult = adoptNS([allocPKPaymentAuthorizationResultInstance() initWithStatus:PKPaymentAuthorizationStatusFailure errors:result ? toNSErrors(result->errors).get() : @[ ]]);
+    m_paymentAuthorizationViewControllerDelegate->_paymentAuthorizedCompletion(pkPaymentAuthorizationResult.get());
+#else
     m_paymentAuthorizationViewControllerDelegate->_paymentAuthorizedCompletion(toPKPaymentAuthorizationStatus(status));
+#endif
     m_paymentAuthorizationViewControllerDelegate->_paymentAuthorizedCompletion = nullptr;
 }
 
@@ -496,7 +601,12 @@
     if (update)
         m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = toPKPaymentSummaryItems(update->newTotalAndLineItems);
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+    auto pkShippingMethodUpdate = adoptNS([allocPKPaymentRequestShippingMethodUpdateInstance() initWithStatus:toPKPaymentAuthorizationStatus(status) paymentSummaryItems:m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get()]);
+    m_paymentAuthorizationViewControllerDelegate->_didSelectShippingMethodCompletion(pkShippingMethodUpdate.get());
+#else
     m_paymentAuthorizationViewControllerDelegate->_didSelectShippingMethodCompletion(toPKPaymentAuthorizationStatus(status), m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get());
+#endif
     m_paymentAuthorizationViewControllerDelegate->_didSelectShippingMethodCompletion = nullptr;
 }
 
@@ -517,7 +627,12 @@
         m_paymentAuthorizationViewControllerDelegate->_shippingMethods = WTFMove(shippingMethods);
     }
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+    auto pkShippingContactUpdate = adoptNS([allocPKPaymentRequestShippingContactUpdateInstance() initWithStatus:toPKPaymentAuthorizationStatus(status) errors:update ? toNSErrors(update->errors).get() : @[ ] paymentSummaryItems:m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get() shippingMethods:m_paymentAuthorizationViewControllerDelegate->_shippingMethods.get()]);
+    m_paymentAuthorizationViewControllerDelegate->_didSelectShippingContactCompletion(pkShippingContactUpdate.get());
+#else
     m_paymentAuthorizationViewControllerDelegate->_didSelectShippingContactCompletion(toPKPaymentAuthorizationStatus(status), m_paymentAuthorizationViewControllerDelegate->_shippingMethods.get(), m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get());
+#endif
     m_paymentAuthorizationViewControllerDelegate->_didSelectShippingContactCompletion = nullptr;
 }
 
@@ -526,20 +641,16 @@
     ASSERT(m_paymentAuthorizationViewController);
     ASSERT(m_paymentAuthorizationViewControllerDelegate);
 
-    if (update) {
-        auto paymentSummaryItems = adoptNS([[NSMutableArray alloc] init]);
-        for (auto& lineItem : update->newTotalAndLineItems.lineItems) {
-            if (auto summaryItem = toPKPaymentSummaryItem(lineItem))
-                [paymentSummaryItems addObject:summaryItem.get()];
-        }
+    if (update)
+        m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = toPKPaymentSummaryItems(update->newTotalAndLineItems);
 
-        if (auto totalItem = toPKPaymentSummaryItem(update->newTotalAndLineItems.total))
-            [paymentSummaryItems addObject:totalItem.get()];
-
-        m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = WTFMove(paymentSummaryItems);
-    }
-
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+    auto status = update ? update->status : WebCore::PaymentAuthorizationStatus::Success;
+    auto pkPaymentMethodUpdate = adoptNS([allocPKPaymentRequestPaymentMethodUpdateInstance() initWithStatus:toPKPaymentAuthorizationStatus(status) paymentSummaryItems:m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get()]);
+    m_paymentAuthorizationViewControllerDelegate->_didSelectPaymentMethodCompletion(pkPaymentMethodUpdate.get());
+#else
     m_paymentAuthorizationViewControllerDelegate->_didSelectPaymentMethodCompletion(m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get());
+#endif
     m_paymentAuthorizationViewControllerDelegate->_didSelectPaymentMethodCompletion = nullptr;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to