-
Notifications
You must be signed in to change notification settings - Fork 134
SDKData for payment data object #2266
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
Draft
erenbesel
wants to merge
11
commits into
develop
Choose a base branch
from
feature/COSDK-515_sdkData
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
92c9445
new field sdkData for paymentComponentData
erenbesel dbae270
Merge branch 'develop' into feature/COSDK-515_sdkData
erenbesel f79455b
fix typo
erenbesel 3013488
add schema version as a constant to track versions
erenbesel 4f53ba5
disable property rule for version constant
erenbesel 138b2f7
made tests more to the point
erenbesel f4f8f78
clarify more test code
erenbesel 28cea55
fix typo
erenbesel 782b34c
change schemaVersion to Int
erenbesel 0632e32
Merge branch 'develop' into feature/COSDK-515_sdkData
nauaros 3e187a4
Merge branch 'develop' into feature/COSDK-515_sdkData
erenbesel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ import Foundation | |
|
|
||
| /** | ||
| The data supplied by a payment component upon completion. | ||
|
|
||
| - SeeAlso: | ||
| [API Reference](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__example_payments-klarna) | ||
| */ | ||
|
|
@@ -36,6 +36,7 @@ public struct PaymentComponentData { | |
| public let installments: Installments? | ||
|
|
||
| /// Indicates whether the current SDK version suports native redirect without glue pages. | ||
| @available(*, deprecated, message: "This property is deprecated. Use the new sdkData property instead.") | ||
| public let supportNativeRedirect: Bool = true | ||
|
|
||
| /// Shopper name. | ||
|
|
@@ -60,6 +61,7 @@ public struct PaymentComponentData { | |
| public let browserInfo: BrowserInfo? | ||
|
|
||
| /// A unique identifier for a checkout attempt. | ||
| @available(*, deprecated, message: "This property is deprecated. Use the new sdkData property instead.") | ||
| public var checkoutAttemptId: String? { | ||
| paymentMethod.checkoutAttemptId | ||
| } | ||
|
|
@@ -87,6 +89,10 @@ public struct PaymentComponentData { | |
| return paymentMethod.delegatedAuthenticationData | ||
| } | ||
|
|
||
| /// An encoded string containing important SDK-specific data. | ||
| /// It is recommended to pass this field to your server to ensure maximum performance and reliability. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please disregard if it makes no sense, but I decided to bring this to your attention. Can we make this statement less vague and explain a bit more? |
||
| public var sdkData: String? | ||
|
|
||
| /// Initializes the payment component data. | ||
| /// | ||
| /// | ||
|
|
@@ -98,21 +104,36 @@ public struct PaymentComponentData { | |
| /// - browserInfo: The device default browser info. | ||
| /// - checkoutAttemptId: The checkoutAttempt identifier. | ||
| /// - installments: Installments selection if specified. | ||
| /// - sdkData: The encoded SDK data if specified. | ||
| @_spi(AdyenInternal) | ||
| public init( | ||
| paymentMethodDetails: some PaymentMethodDetails, | ||
| amount: Amount?, | ||
| order: PartialPaymentOrder?, | ||
| storePaymentMethod: Bool? = nil, | ||
| browserInfo: BrowserInfo? = nil, | ||
| installments: Installments? = nil | ||
| installments: Installments? = nil, | ||
| sdkData: String? = nil | ||
| ) { | ||
| self.amount = amount | ||
| self.paymentMethod = paymentMethodDetails | ||
| self.order = order | ||
| self.storePaymentMethod = storePaymentMethod | ||
| self.browserInfo = browserInfo | ||
| self.installments = installments | ||
| self.sdkData = sdkData | ||
| } | ||
|
|
||
| internal func replacing(sdkData: SDKData) -> PaymentComponentData { | ||
| PaymentComponentData( | ||
| paymentMethodDetails: paymentMethod, | ||
| amount: amount, | ||
| order: order, | ||
| storePaymentMethod: storePaymentMethod, | ||
| browserInfo: browserInfo, | ||
| installments: installments, | ||
| sdkData: sdkData.encodedValue | ||
| ) | ||
| } | ||
|
|
||
| @_spi(AdyenInternal) | ||
|
|
@@ -123,7 +144,8 @@ public struct PaymentComponentData { | |
| order: order, | ||
| storePaymentMethod: storePaymentMethod, | ||
| browserInfo: browserInfo, | ||
| installments: installments | ||
| installments: installments, | ||
| sdkData: sdkData | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -135,7 +157,8 @@ public struct PaymentComponentData { | |
| order: order, | ||
| storePaymentMethod: storePaymentMethod, | ||
| browserInfo: browserInfo, | ||
| installments: installments | ||
| installments: installments, | ||
| sdkData: sdkData | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -150,7 +173,8 @@ public struct PaymentComponentData { | |
| order: order, | ||
| storePaymentMethod: storePaymentMethod, | ||
| browserInfo: browserInfo, | ||
| installments: installments | ||
| installments: installments, | ||
| sdkData: sdkData | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -168,7 +192,8 @@ public struct PaymentComponentData { | |
| order: order, | ||
| storePaymentMethod: storePaymentMethod, | ||
| browserInfo: $0, | ||
| installments: installments | ||
| installments: installments, | ||
| sdkData: sdkData | ||
| )) | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // | ||
| // Copyright (c) 2025 Adyen N.V. | ||
| // | ||
| // This file is open source and available under the MIT license. See the LICENSE file for more info. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| @_spi(AdyenInternal) | ||
| public struct SDKData: Codable { | ||
|
|
||
| internal struct Analytics: Codable { | ||
| internal let checkoutAttemptId: String | ||
| } | ||
|
|
||
| public struct Authentication: Codable { | ||
| internal let threeDS2SdkVersion: String | ||
|
|
||
| public init(threeDS2SdkVersion: String) { | ||
| self.threeDS2SdkVersion = threeDS2SdkVersion | ||
| } | ||
| } | ||
|
|
||
| internal let analytics: Analytics | ||
| internal private(set) var authentication: Authentication? | ||
| internal let schemaVersion: Int = SchemaVersions.v1 | ||
| private let supportNativeRedirect: Bool = true | ||
| private let timestamp = Int(Date().timeIntervalSince1970 * 1000) | ||
|
|
||
| internal var encodedValue: String? { | ||
| try? AdyenCoder.encodeBase64(self) | ||
| } | ||
|
|
||
| internal init( | ||
| checkoutAttemptId: String, | ||
| authenticationProvider: SDKDataAuthenticationProvider? = nil | ||
| ) { | ||
| self.analytics = .init(checkoutAttemptId: checkoutAttemptId) | ||
| self.authentication = authenticationProvider?.authentication | ||
| } | ||
|
|
||
| private enum CodingKeys: String, CodingKey { | ||
| case analytics | ||
| case authentication | ||
| case supportNativeRedirect | ||
| case schemaVersion | ||
| case timestamp = "createdAt" | ||
| } | ||
|
|
||
| private enum SchemaVersions { | ||
| internal static let v1 = 1 | ||
| } | ||
| } | ||
|
|
||
| @_spi(AdyenInternal) | ||
| public protocol SDKDataAuthenticationProvider { | ||
| var authentication: SDKData.Authentication { get } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.