haikuwebkit/Source/WebCore/Modules/applepay/ApplePayInstallmentItem.h

47 lines
1.8 KiB
C
Raw Permalink Normal View History

[Apple Pay] Add new ApplePayInstallmentConfiguration members https://bugs.webkit.org/show_bug.cgi?id=212160 <rdar://problem/60703650> Reviewed by Alex Christensen. Source/WebCore: Test: http/tests/ssl/applepay/ApplePayInstallmentItems.https.html * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: Added IDLs, headers, and derived sources for ApplePayInstallment{Item,ItemType,RetailChannel}. * Modules/applepay/ApplePayInstallmentConfiguration.idl: * Modules/applepay/ApplePayInstallmentConfigurationWebCore.h: Added items, applicationMetadata, and retailChannel members. Added missing conditionals to merchantIdentifier and referrerIdentifier. * Modules/applepay/ApplePayInstallmentItem.h: * Modules/applepay/ApplePayInstallmentItem.idl: * Modules/applepay/ApplePayInstallmentItemType.h: * Modules/applepay/ApplePayInstallmentItemType.idl: * Modules/applepay/ApplePayInstallmentRetailChannel.h: * Modules/applepay/ApplePayInstallmentRetailChannel.idl: Added. * Modules/applepay/ApplePayRequestBase.cpp: (WebCore::convertAndValidate): Changed to call PaymentInstallmentConfiguration::create, returning an exception if present. * Modules/applepay/PaymentInstallmentConfiguration.mm: (WebCore::fromDecimalNumber): Allowed for a large maximum number of fractional digits to support formatting high-precision currency and APRs (note that this formatter is only used for test support). (WebCore::applePayItemType): (WebCore::platformItemType): Added to convert between PKInstallmentItemType and ApplePayInstallmentItemType. (WebCore::applePayRetailChannel): (WebCore::platformRetailChannel): Added to convert between PKInstallmentRetailChannel and ApplePayInstallmentRetailChannel. (WebCore::makeNSArrayElement): (WebCore::makeVectorElement): Added to convert between NSArray<PKPaymentInstallmentItem *> and Vector<ApplePayInstallmentItem>. (WebCore::createPlatformConfiguration): Added a parameter for passing in applicationMetadata as an NSDictionary. Set properties on PKPaymentInstallmentConfiguration for new ApplePayInstallmentConfiguration members. (WebCore::PaymentInstallmentConfiguration::create): Added; converts the applicationMetadata JSON string (if present) to an NSDictionary, returning a TypeError if the JSON string does not deserialize to an NSDictionary (as PassKit requires). (WebCore::PaymentInstallmentConfiguration::PaymentInstallmentConfiguration): Added a parameter for passing in applicationMetadata as an NSDictionary. Made private. (WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const): Set members on ApplePayInstallmentConfiguration for new PKPaymentInstallmentConfiguration properties. * Modules/applepay/PaymentInstallmentConfigurationWebCore.h: Source/WebCore/PAL: * pal/cocoa/PassKitSoftLink.h: * pal/cocoa/PassKitSoftLink.mm: Added soft-linking macros for PKPaymentInstallmentItem. Source/WTF: * wtf/PlatformEnableCocoa.h: Defined ENABLE_APPLE_PAY_INSTALLMENT_IDENTIFIERS. LayoutTests: * http/tests/ssl/applepay/ApplePayInstallmentItems.https-expected.txt: * http/tests/ssl/applepay/ApplePayInstallmentItems.https.html: Added. * platform/mac-wk2/TestExpectations: Skipped test on Mojave and Catalina. Canonical link: https://commits.webkit.org/225136@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-22 20:10:01 +00:00
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
[Apple Pay] Enable layout tests on more platforms https://bugs.webkit.org/show_bug.cgi?id=212955 <rdar://problem/64174156> Reviewed by Alex Christensen. Source/WebCore: Added runtime checks to determine the Apple Pay API version when installments are enabled. Enabled tests in http/tests/ssl/applepay on iOS. * Modules/applepay/ApplePayInstallmentConfiguration.idl: * Modules/applepay/ApplePayInstallmentConfigurationWebCore.h: * Modules/applepay/ApplePayInstallmentItem.h: * Modules/applepay/ApplePayInstallmentItem.idl: * Modules/applepay/ApplePayInstallmentItemType.h: * Modules/applepay/ApplePayInstallmentItemType.idl: * Modules/applepay/ApplePayInstallmentRetailChannel.h: * Modules/applepay/ApplePayInstallmentRetailChannel.idl: Removed uses of APPLE_PAY_INSTALLMENT_IDENTIFIERS and APPLE_PAY_INSTALLMENT_ITEMS (or replaced with APPLE_PAY_INSTALLMENTS). * Modules/applepay/PaymentAPIVersion.h: * Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm: (WebCore::PaymentAPIVersion::current): Moved the computation of current API version from PaymentCoordinatorClient::supportsVersion to here. Added runtime checks to determine the level of PassKit installments support since we don't have enough information to tell at compile time. * Modules/applepay/PaymentCoordinatorClient.cpp: (WebCore::PaymentCoordinatorClient::supportsVersion): Changed to call PaymentAPIVersion::current. * Modules/applepay/PaymentInstallmentConfiguration.mm: (WebCore::makeNSArrayElement): (WebCore::createPlatformConfiguration): (WebCore::PaymentInstallmentConfiguration::create): (WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const): Removed uses of HAVE_PASSKIT_INSTALLMENT_ITEMS and HAVE_PASSKIT_INSTALLMENT_IDENTIFIERS. Used runtime checks to determine support for PKPaymentInstallmentConfiguration and PKPaymentInstallmentItem. * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: Added source files for PaymentAPIVersion. Source/WebCore/PAL: PassKit added SPIs for Apple Pay installments over a series of iOS 13 and macOS Catalina minor updates. WebKit trunk is still built across a range of iOS 13 and macOS Catalina minor update SDKs that contain none, some, or all of the installment SPIs. It's not possible to reliably detect the SDK minor version at compile-time, so instead we now use our own SPI declarations unless we know all minor versions of the major SDK version contain all of the installments definitions. * PAL.xcodeproj/project.pbxproj: Added PassKitInstallmentsSPI.h. * pal/cocoa/PassKitSoftLink.h: * pal/cocoa/PassKitSoftLink.mm: Used SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT on both Mac and iOS to soft-link PKPaymentInstallmentConfiguration and PKPaymentInstallmentItem. * pal/spi/cocoa/PassKitInstallmentSPI.h: Added. When building against an SDK that is known to declare the PassKit installments SPIs, this file includes the SPI headers. Otherwise, it declares the SPIs. * pal/spi/cocoa/PassKitSPI.h: Moved PassKit installments SPI declarations to PassKitInstallmentSPI.h. Source/WTF: * wtf/PlatformEnableCocoa.h: Removed ENABLE_APPLE_PAY_INSTALLMENT_IDENTIFIERS, ENABLE_APPLE_PAY_INSTALLMENT_ITEMS, ENABLE_APPLE_PAY_SESSION_V8, ENABLE_APPLE_PAY_SESSION_V9, and ENABLE_APPLE_PAY_SESSION_V10. * wtf/PlatformHave.h: Removed HAVE_PASSKIT_INSTALLMENT_IDENTIFIERS and corrected iOS version checks for HAVE_PASSKIT_INSTALLMENTS. LayoutTests: * http/tests/ssl/applepay/ApplePayInstallmentItems.https.html: Changed to fail instead of time out when API version 9 isn't supported. * http/tests/ssl/applepay/ApplePayError.html: * http/tests/ssl/applepay/ApplePaySession.html: * http/tests/ssl/applepay/ApplePaySessionV3.html: * http/tests/ssl/applepay/ApplePaySessionV4.html: * http/tests/ssl/applepay/ApplePaySessionV5.html: Removed a custom element-clicking function and used UIHelper.activateElement instead. * platform/ios-wk2/TestExpectations: Un-skipped http/tests/ssl/applepay. Marked PaymentRequest.https.html as Slow. Marked ApplePayInstallmentItems.https.html as Failure. * platform/mac-wk2/TestExpectations: Removed a trailing '/'. Skipped ApplePayInstallmentItems.https.html on Mojave and marked it as Failure on Catalina. Canonical link: https://commits.webkit.org/226081@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-17 15:55:49 +00:00
#if ENABLE(APPLE_PAY_INSTALLMENTS)
[Apple Pay] Add new ApplePayInstallmentConfiguration members https://bugs.webkit.org/show_bug.cgi?id=212160 <rdar://problem/60703650> Reviewed by Alex Christensen. Source/WebCore: Test: http/tests/ssl/applepay/ApplePayInstallmentItems.https.html * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: Added IDLs, headers, and derived sources for ApplePayInstallment{Item,ItemType,RetailChannel}. * Modules/applepay/ApplePayInstallmentConfiguration.idl: * Modules/applepay/ApplePayInstallmentConfigurationWebCore.h: Added items, applicationMetadata, and retailChannel members. Added missing conditionals to merchantIdentifier and referrerIdentifier. * Modules/applepay/ApplePayInstallmentItem.h: * Modules/applepay/ApplePayInstallmentItem.idl: * Modules/applepay/ApplePayInstallmentItemType.h: * Modules/applepay/ApplePayInstallmentItemType.idl: * Modules/applepay/ApplePayInstallmentRetailChannel.h: * Modules/applepay/ApplePayInstallmentRetailChannel.idl: Added. * Modules/applepay/ApplePayRequestBase.cpp: (WebCore::convertAndValidate): Changed to call PaymentInstallmentConfiguration::create, returning an exception if present. * Modules/applepay/PaymentInstallmentConfiguration.mm: (WebCore::fromDecimalNumber): Allowed for a large maximum number of fractional digits to support formatting high-precision currency and APRs (note that this formatter is only used for test support). (WebCore::applePayItemType): (WebCore::platformItemType): Added to convert between PKInstallmentItemType and ApplePayInstallmentItemType. (WebCore::applePayRetailChannel): (WebCore::platformRetailChannel): Added to convert between PKInstallmentRetailChannel and ApplePayInstallmentRetailChannel. (WebCore::makeNSArrayElement): (WebCore::makeVectorElement): Added to convert between NSArray<PKPaymentInstallmentItem *> and Vector<ApplePayInstallmentItem>. (WebCore::createPlatformConfiguration): Added a parameter for passing in applicationMetadata as an NSDictionary. Set properties on PKPaymentInstallmentConfiguration for new ApplePayInstallmentConfiguration members. (WebCore::PaymentInstallmentConfiguration::create): Added; converts the applicationMetadata JSON string (if present) to an NSDictionary, returning a TypeError if the JSON string does not deserialize to an NSDictionary (as PassKit requires). (WebCore::PaymentInstallmentConfiguration::PaymentInstallmentConfiguration): Added a parameter for passing in applicationMetadata as an NSDictionary. Made private. (WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const): Set members on ApplePayInstallmentConfiguration for new PKPaymentInstallmentConfiguration properties. * Modules/applepay/PaymentInstallmentConfigurationWebCore.h: Source/WebCore/PAL: * pal/cocoa/PassKitSoftLink.h: * pal/cocoa/PassKitSoftLink.mm: Added soft-linking macros for PKPaymentInstallmentItem. Source/WTF: * wtf/PlatformEnableCocoa.h: Defined ENABLE_APPLE_PAY_INSTALLMENT_IDENTIFIERS. LayoutTests: * http/tests/ssl/applepay/ApplePayInstallmentItems.https-expected.txt: * http/tests/ssl/applepay/ApplePayInstallmentItems.https.html: Added. * platform/mac-wk2/TestExpectations: Skipped test on Mojave and Catalina. Canonical link: https://commits.webkit.org/225136@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-22 20:10:01 +00:00
#include "ApplePayInstallmentItemType.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
struct ApplePayInstallmentItem {
ApplePayInstallmentItemType type { ApplePayInstallmentItemType::Generic };
String amount;
String currencyCode;
String programIdentifier;
String apr;
String programTerms;
};
} // namespace WebCore
[Apple Pay] Enable layout tests on more platforms https://bugs.webkit.org/show_bug.cgi?id=212955 <rdar://problem/64174156> Reviewed by Alex Christensen. Source/WebCore: Added runtime checks to determine the Apple Pay API version when installments are enabled. Enabled tests in http/tests/ssl/applepay on iOS. * Modules/applepay/ApplePayInstallmentConfiguration.idl: * Modules/applepay/ApplePayInstallmentConfigurationWebCore.h: * Modules/applepay/ApplePayInstallmentItem.h: * Modules/applepay/ApplePayInstallmentItem.idl: * Modules/applepay/ApplePayInstallmentItemType.h: * Modules/applepay/ApplePayInstallmentItemType.idl: * Modules/applepay/ApplePayInstallmentRetailChannel.h: * Modules/applepay/ApplePayInstallmentRetailChannel.idl: Removed uses of APPLE_PAY_INSTALLMENT_IDENTIFIERS and APPLE_PAY_INSTALLMENT_ITEMS (or replaced with APPLE_PAY_INSTALLMENTS). * Modules/applepay/PaymentAPIVersion.h: * Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm: (WebCore::PaymentAPIVersion::current): Moved the computation of current API version from PaymentCoordinatorClient::supportsVersion to here. Added runtime checks to determine the level of PassKit installments support since we don't have enough information to tell at compile time. * Modules/applepay/PaymentCoordinatorClient.cpp: (WebCore::PaymentCoordinatorClient::supportsVersion): Changed to call PaymentAPIVersion::current. * Modules/applepay/PaymentInstallmentConfiguration.mm: (WebCore::makeNSArrayElement): (WebCore::createPlatformConfiguration): (WebCore::PaymentInstallmentConfiguration::create): (WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const): Removed uses of HAVE_PASSKIT_INSTALLMENT_ITEMS and HAVE_PASSKIT_INSTALLMENT_IDENTIFIERS. Used runtime checks to determine support for PKPaymentInstallmentConfiguration and PKPaymentInstallmentItem. * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: Added source files for PaymentAPIVersion. Source/WebCore/PAL: PassKit added SPIs for Apple Pay installments over a series of iOS 13 and macOS Catalina minor updates. WebKit trunk is still built across a range of iOS 13 and macOS Catalina minor update SDKs that contain none, some, or all of the installment SPIs. It's not possible to reliably detect the SDK minor version at compile-time, so instead we now use our own SPI declarations unless we know all minor versions of the major SDK version contain all of the installments definitions. * PAL.xcodeproj/project.pbxproj: Added PassKitInstallmentsSPI.h. * pal/cocoa/PassKitSoftLink.h: * pal/cocoa/PassKitSoftLink.mm: Used SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT on both Mac and iOS to soft-link PKPaymentInstallmentConfiguration and PKPaymentInstallmentItem. * pal/spi/cocoa/PassKitInstallmentSPI.h: Added. When building against an SDK that is known to declare the PassKit installments SPIs, this file includes the SPI headers. Otherwise, it declares the SPIs. * pal/spi/cocoa/PassKitSPI.h: Moved PassKit installments SPI declarations to PassKitInstallmentSPI.h. Source/WTF: * wtf/PlatformEnableCocoa.h: Removed ENABLE_APPLE_PAY_INSTALLMENT_IDENTIFIERS, ENABLE_APPLE_PAY_INSTALLMENT_ITEMS, ENABLE_APPLE_PAY_SESSION_V8, ENABLE_APPLE_PAY_SESSION_V9, and ENABLE_APPLE_PAY_SESSION_V10. * wtf/PlatformHave.h: Removed HAVE_PASSKIT_INSTALLMENT_IDENTIFIERS and corrected iOS version checks for HAVE_PASSKIT_INSTALLMENTS. LayoutTests: * http/tests/ssl/applepay/ApplePayInstallmentItems.https.html: Changed to fail instead of time out when API version 9 isn't supported. * http/tests/ssl/applepay/ApplePayError.html: * http/tests/ssl/applepay/ApplePaySession.html: * http/tests/ssl/applepay/ApplePaySessionV3.html: * http/tests/ssl/applepay/ApplePaySessionV4.html: * http/tests/ssl/applepay/ApplePaySessionV5.html: Removed a custom element-clicking function and used UIHelper.activateElement instead. * platform/ios-wk2/TestExpectations: Un-skipped http/tests/ssl/applepay. Marked PaymentRequest.https.html as Slow. Marked ApplePayInstallmentItems.https.html as Failure. * platform/mac-wk2/TestExpectations: Removed a trailing '/'. Skipped ApplePayInstallmentItems.https.html on Mojave and marked it as Failure on Catalina. Canonical link: https://commits.webkit.org/226081@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-17 15:55:49 +00:00
#endif // ENABLE(APPLE_PAY_INSTALLMENTS)