Skip to content

Commit

Permalink
Improve Apple Pay flow state naming
Browse files Browse the repository at this point in the history
This change makes state naming more precise as we might receive an error after submitting payment details to Apple so `submitted` fits and reads better and doesn't provoke any false assumptions.
  • Loading branch information
atmamont committed Feb 14, 2024
1 parent a7902c4 commit 663f10b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions AdyenComponents/Apple Pay/ApplePayComponent.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2023 Adyen N.V.
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//
Expand Down Expand Up @@ -83,7 +83,7 @@ public class ApplePayComponent: NSObject, PresentableComponent, PaymentComponent
}

public func didFinalize(with success: Bool, completion: (() -> Void)?) {
if case let .paid(paymentAuthorizationCompletion) = state {
if case let .submitted(paymentAuthorizationCompletion) = state {
state = .finalized(completion)
paymentAuthorizationCompletion(success ? .success : .failure)
} else {
Expand Down Expand Up @@ -120,7 +120,7 @@ extension ApplePayComponent {

internal enum State {
case initial
case paid((PKPaymentAuthorizationStatus) -> Void)
case submitted((PKPaymentAuthorizationStatus) -> Void)
case finalized((() -> Void)?)
}

Expand Down
4 changes: 2 additions & 2 deletions AdyenComponents/Apple Pay/ApplePayComponentExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2022 Adyen N.V.
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//
Expand Down Expand Up @@ -29,7 +29,7 @@ extension ApplePayComponent: PKPaymentAuthorizationViewControllerDelegate {
return
}

state = .paid(completion)
state = .submitted(completion)
let token = payment.token.paymentData.base64EncodedString()
let network = payment.token.paymentMethod.network?.rawValue ?? ""
let details = ApplePayDetails(paymentMethod: applePayPaymentMethod,
Expand Down

0 comments on commit 663f10b

Please sign in to comment.