-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
COIOS-802: Identify native redirect flow (v5) #1879
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request does not contain a valid label. Please add one of the following labels: ['new', 'changed', 'fixed', 'removed', 'deprecated', 'chore', 'improvement']
…native_redirect_flow' into COIOS-802_identify_native_redirect_flow
Quality Gate passedIssues Measures |
7f206e2
|
❇️ | 1 Addition |
🔀 | 1 Modification |
AdyenActions
RedirectAction
❇️ Added
public enum RedirectType: Swift.Decodable, Swift.Equatable, Swift.Hashable, Swift.RawRepresentable, Swift.String {
case nativeRedirect
case redirect
public init(from decoder: any Swift.Decoder) throws
public init?(rawValue: Swift.String)
public typealias RawValue = Swift.String
public var rawValue: Swift.String { get }
}
🔀 Modified
// From
public init(
url: Foundation.URL,
paymentData: Swift.String?,
nativeRedirectData: Swift.String? = nil,
paymentMethodType: Swift.String? = nil
)
// To
public init(
url: Foundation.URL,
paymentData: Swift.String?,
type: AdyenActions.RedirectAction.RedirectType = .redirect,
nativeRedirectData: Swift.String? = nil,
paymentMethodType: Swift.String? = nil
)
/**
Changes:
- Added parameter `type: AdyenActions.RedirectAction.RedirectType = .redirect`
*/
Analyzed targets: Adyen, AdyenActions, AdyenCard, AdyenCashAppPay, AdyenComponents, AdyenDelegatedAuthentication, AdyenEncryption, AdyenSession, AdyenSwiftUI, AdyenTwint, AdyenWeChatPay
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.url = try container.decode(URL.self, forKey: .url) | ||
self.paymentData = try container.decodeIfPresent(String.self, forKey: .paymentData) | ||
self.type = try container.decode(RedirectType.self, forKey: .type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure the RedirectType will always be returned?
otherwise we could do:
self.type = try container.decode(RedirectType.self, forKey: .type) | |
self.type = (try? container.decode(RedirectType.self, forKey: .type)) ?? FALLBACK_VALUE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any other way to check its optionality? https://docs.adyen.com/api-explorer/Checkout/71/post/payments#responses-200-action-CheckoutRedirectAction-type
Quality Gate passedIssues Measures |
@@ -9,12 +9,27 @@ import Foundation | |||
/// Describes an action in which the user is redirected to a URL. | |||
public struct RedirectAction: Decodable { | |||
|
|||
/// Defines the type of redirect flow utilized by the `RedirectAction` object. | |||
public enum RedirectType: String, Decodable { | |||
// swiftlint:disable redundant_string_enum_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to add the string values when they are matching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a guess - to not break anything if someone decides to rename enum case in the future?
url: URL(string: "https://google.com")!, | ||
paymentData: nil, | ||
type: .nativeRedirect, | ||
nativeRedirectData: "test_nativeRedirectData" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation says it's just a string with no further explanation. Is this an URL or anything else? Should we have tests for this string?
Summary
This development enables us to differentiate between regular and native redirects. To handle cases where native redirects fail (indicated by
nativeRedirectData
beingnil
), it's essential to track the originating flow type of each redirect.Motivation
Native redirect flows can occasionally fail if
nativeRedirectData
isnil
within the action object. Currently, we handle this by discarding the native redirect (checking ifnativeRedirectData
is nil), and defaulting to a "direct issuer flow" using a/details
call.To avoid the additional steps of the "direct issuer flow," we can address this issue on the backend. By identifying the native redirect flow, we can still retrieve the native redirect result directly.
Release notes
Ticket
COIOS-802