Skip to content

Commit 0ce2093

Browse files
committed
COSDK-931: ApplePay factory
1 parent bd0e813 commit 0ce2093

18 files changed

Lines changed: 411 additions & 192 deletions

Adyen.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@
470470
A013F98126AFF72D00602633 /* BrazilSocialSecurityNumberFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07B2CE526A5B5440008185C /* BrazilSocialSecurityNumberFormatter.swift */; };
471471
A018094826FDD345003A8DE3 /* FormCardNumberContainerItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A018094726FDD345003A8DE3 /* FormCardNumberContainerItem.swift */; };
472472
A01948342D8827FD00AA27AC /* PayToFormPickerItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01948332D8827A300AA27AC /* PayToFormPickerItemView.swift */; };
473+
A01B112C2F991E830081DA79 /* ApplePayComponentFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01B112B2F991E830081DA79 /* ApplePayComponentFactory.swift */; };
473474
A01DCF0B26BD67BB00BC35B3 /* FormCardExpiryDateItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DCF0A26BD67BB00BC35B3 /* FormCardExpiryDateItem.swift */; };
474475
A01DFBBF2BA887BF00205881 /* ThreadSafeAnalyticsEventDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DFBBE2BA887BF00205881 /* ThreadSafeAnalyticsEventDataSource.swift */; };
475476
A01DFBC52BB6F9FA00205881 /* ValidationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DFBC42BB6F9FA00205881 /* ValidationError.swift */; };
@@ -608,6 +609,7 @@
608609
A0E1B63D2EA90B6D0070B915 /* BLIKComponentFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B63C2EA90B620070B915 /* BLIKComponentFactory.swift */; };
609610
A0E1B63F2EA90BDF0070B915 /* CardComponentFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B63E2EA90BDB0070B915 /* CardComponentFactory.swift */; };
610611
A0E1B6422EAB9D0E0070B915 /* BLIKComponentFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B6412EAB9D0C0070B915 /* BLIKComponentFactoryTests.swift */; };
612+
A0E1B6512EE1E1A20070B915 /* ApplePayComponentFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B6502EE1E1A10070B915 /* ApplePayComponentFactoryTests.swift */; };
611613
A0E1B6452EAB9F580070B915 /* CheckoutConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B6442EAB9F520070B915 /* CheckoutConfigurationTests.swift */; };
612614
A0E1B6492EABA05F0070B915 /* PaymentComponentFactoryProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B6482EABA05D0070B915 /* PaymentComponentFactoryProtocolTests.swift */; };
613615
A0E1B64B2EABA0C00070B915 /* CheckoutComponentBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E1B64A2EABA0BF0070B915 /* CheckoutComponentBuilderTests.swift */; };
@@ -2163,6 +2165,7 @@
21632165
A01948332D8827A300AA27AC /* PayToFormPickerItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayToFormPickerItemView.swift; sourceTree = "<group>"; };
21642166
A01948542D91AD8700AA27AC /* CheckoutConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckoutConfiguration.swift; sourceTree = "<group>"; };
21652167
A01948562D92BFAB00AA27AC /* ConfigurationBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationBuilder.swift; sourceTree = "<group>"; };
2168+
A01B112B2F991E830081DA79 /* ApplePayComponentFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplePayComponentFactory.swift; sourceTree = "<group>"; };
21662169
A01D775529B250C10075BD70 /* CashAppPayDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CashAppPayDetails.swift; sourceTree = "<group>"; };
21672170
A01DCF0A26BD67BB00BC35B3 /* FormCardExpiryDateItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCardExpiryDateItem.swift; sourceTree = "<group>"; };
21682171
A01DFBBE2BA887BF00205881 /* ThreadSafeAnalyticsEventDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadSafeAnalyticsEventDataSource.swift; sourceTree = "<group>"; };
@@ -2271,6 +2274,7 @@
22712274
A0E1B63C2EA90B620070B915 /* BLIKComponentFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLIKComponentFactory.swift; sourceTree = "<group>"; };
22722275
A0E1B63E2EA90BDB0070B915 /* CardComponentFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardComponentFactory.swift; sourceTree = "<group>"; };
22732276
A0E1B6412EAB9D0C0070B915 /* BLIKComponentFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLIKComponentFactoryTests.swift; sourceTree = "<group>"; };
2277+
A0E1B6502EE1E1A10070B915 /* ApplePayComponentFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplePayComponentFactoryTests.swift; sourceTree = "<group>"; };
22742278
A0E1B6442EAB9F520070B915 /* CheckoutConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckoutConfigurationTests.swift; sourceTree = "<group>"; };
22752279
A0E1B6482EABA05D0070B915 /* PaymentComponentFactoryProtocolTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentComponentFactoryProtocolTests.swift; sourceTree = "<group>"; };
22762280
A0E1B64A2EABA0BF0070B915 /* CheckoutComponentBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckoutComponentBuilderTests.swift; sourceTree = "<group>"; };
@@ -4124,6 +4128,7 @@
41244128
isa = PBXGroup;
41254129
children = (
41264130
A0E1B6412EAB9D0C0070B915 /* BLIKComponentFactoryTests.swift */,
4131+
A0E1B6502EE1E1A10070B915 /* ApplePayComponentFactoryTests.swift */,
41274132
);
41284133
path = "Component Factory Tests";
41294134
sourceTree = "<group>";
@@ -5902,6 +5907,7 @@
59025907
E97B971C229E83F800505476 /* ApplePayComponent.swift */,
59035908
F99262C324EECB9F00C9A60D /* ApplePayComponentExtensions.swift */,
59045909
E97B971E22A14C6C00505476 /* ApplePayDetails.swift */,
5910+
A01B112B2F991E830081DA79 /* ApplePayComponentFactory.swift */,
59055911
E7D874F227DF5CDC00D3C00A /* ApplePayComponentError.swift */,
59065912
E7D874F427E0E26100D3C00A /* ApplePayConfiguration.swift */,
59075913
C92245B02EE9863F00815A51 /* ApplePayNetworksProvider.swift */,
@@ -8425,6 +8431,7 @@
84258431
B6D808212BCD151F00F3F5EB /* URLProtocolMock.swift in Sources */,
84268432
B6D8081B2BCD151F00F3F5EB /* StoredPaymentMethodMock.swift in Sources */,
84278433
A0E1B6422EAB9D0E0070B915 /* BLIKComponentFactoryTests.swift in Sources */,
8434+
A0E1B6512EE1E1A20070B915 /* ApplePayComponentFactoryTests.swift in Sources */,
84288435
A06C76452E1EAF9700213E53 /* AdyenSessionMock.swift in Sources */,
84298436
B62D48C02BBE8DF5001EF01A /* APIClientMock.swift in Sources */,
84308437
A03056E82E016D9A00ED7014 /* CheckoutTests.swift in Sources */,
@@ -9160,6 +9167,7 @@
91609167
C930FB6E269D79E0006A26D2 /* AffirmDetails.swift in Sources */,
91619168
5A54603F264A5CEC00724A87 /* BoletoComponent.swift in Sources */,
91629169
C93B01B72760B03400D311A1 /* BACSConfirmationViewController.swift in Sources */,
9170+
A01B112C2F991E830081DA79 /* ApplePayComponentFactory.swift in Sources */,
91639171
C9D8EB9927452355006D8CA1 /* BACSInputFormViewController.swift in Sources */,
91649172
A0E1B63D2EA90B6D0070B915 /* BLIKComponentFactory.swift in Sources */,
91659173
A0BFBB542D6F267A003F543E /* PayToItemsProvider.swift in Sources */,

AdyenCheckout/Checkout+DelegateCallbacks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension Checkout: PaymentComponentDelegate {
1616
public func didSubmit(_ data: PaymentComponentData, from component: any PaymentComponent) {
1717
AdyenAssertion.assert(
1818
message: "A new payment component submitted while another flow is still pending.",
19-
condition: pendingPaymentComponent == nil
19+
condition: pendingPaymentComponent != nil
2020
)
2121
pendingPaymentComponent = component
2222

AdyenCheckout/CheckoutComponentBuilder.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ internal enum CheckoutComponentBuilder {
4343
configuration: configuration,
4444
context: context
4545
)
46+
case let applePayPaymentMethod as ApplePayPaymentMethod:
47+
return try createComponent(
48+
using: ApplePayComponentFactory(),
49+
paymentMethod: applePayPaymentMethod,
50+
configuration: configuration,
51+
context: context
52+
)
4653
#endif
4754

4855
// card module

AdyenComponents/Apple Pay/ApplePayComponent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ApplePayComponent: NSObject, PresentableComponent, PaymentComponent
3636
applePayPaymentMethod
3737
}
3838

39-
internal let configuration: Configuration
39+
internal let configuration: ApplePayConfiguration
4040

4141
internal var paymentAuthorizationViewController: PKPaymentAuthorizationViewController?
4242

@@ -61,7 +61,7 @@ public class ApplePayComponent: NSObject, PresentableComponent, PaymentComponent
6161
public init(
6262
paymentMethod: ApplePayPaymentMethod,
6363
context: AdyenContext,
64-
configuration: Configuration
64+
configuration: ApplePayConfiguration
6565
) throws {
6666
guard PKPaymentAuthorizationViewController.canMakePayments() else {
6767
throw Error.deviceDoesNotSupportApplePay

AdyenComponents/Apple Pay/ApplePayComponentExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ extension ApplePayComponent {
154154
return paymentRequest.paymentSummaryItems
155155
}
156156
do {
157-
try Configuration.validate(summaryItems: result.paymentSummaryItems)
157+
try ApplePayConfiguration.validate(summaryItems: result.paymentSummaryItems)
158158
paymentRequest.paymentSummaryItems = result.paymentSummaryItems
159159
return result.paymentSummaryItems
160160
} catch {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Copyright (c) 2026 Adyen N.V.
3+
//
4+
// This file is open source and available under the MIT license. See the LICENSE file for more info.
5+
//
6+
7+
@_spi(AdyenInternal) import Adyen
8+
9+
/// Factory for creating Apple Pay payment components.
10+
///
11+
/// Apple Pay has no usable default configuration because it requires merchant-specific
12+
/// fields (merchant identifier, payment request). Integrators must supply a configuration
13+
/// via the `CheckoutConfiguration` DSL.
14+
@MainActor
15+
package struct ApplePayComponentFactory: PaymentComponentFactory {
16+
package typealias Configuration = ApplePayConfiguration
17+
package typealias Method = ApplePayPaymentMethod
18+
package typealias Component = ApplePayComponent
19+
20+
package init() {}
21+
22+
package func create(
23+
with paymentMethod: ApplePayPaymentMethod,
24+
context: AdyenContext,
25+
configuration: ApplePayConfiguration
26+
) throws -> ApplePayComponent {
27+
try ApplePayComponent(
28+
paymentMethod: paymentMethod,
29+
context: context,
30+
configuration: configuration
31+
)
32+
}
33+
34+
package func defaultConfiguration() -> ApplePayConfiguration? {
35+
nil
36+
}
37+
}

0 commit comments

Comments
 (0)