diff --git a/CHANGELOG.md b/CHANGELOG.md index 985c953855..6cb3195a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## unreleased * BraintreeThreeDSecure * Add `cardAddChallengeRequested` to `BTThreeDSecureRequest` +* BraintreeCard + * Deprecate unused `BTCardRequest` class ## 5.24.0 (2023-10-30) * BraintreePayPalDataCollector diff --git a/Sources/BraintreeCard/BTCardClient.swift b/Sources/BraintreeCard/BTCardClient.swift index a80e30eb48..0eb4c3771a 100644 --- a/Sources/BraintreeCard/BTCardClient.swift +++ b/Sources/BraintreeCard/BTCardClient.swift @@ -33,7 +33,6 @@ import BraintreeCore @objc(tokenizeCard:completion:) public func tokenize(_ card: BTCard, completion: @escaping (BTCardNonce?, Error?) -> Void) { apiClient.sendAnalyticsEvent(BTCardAnalytics.cardTokenizeStarted) - let request = BTCardRequest(card: card) apiClient.fetchOrReturnRemoteConfiguration() { configuration, error in if let error { @@ -47,12 +46,12 @@ import BraintreeCore } if self.isGraphQLEnabled(for: configuration) { - if request.card.authenticationInsightRequested && request.card.merchantAccountID == nil { + if card.authenticationInsightRequested && card.merchantAccountID == nil { self.notifyFailure(with: BTCardError.integration, completion: completion) return } - let parameters = request.card.graphQLParameters() + let parameters = card.graphQLParameters() self.apiClient.post("", parameters: parameters, httpType: .graphQLAPI) { body, _, error in if let error = error as NSError? { @@ -80,7 +79,7 @@ import BraintreeCore return } } else { - let parameters = self.clientAPIParameters(for: request) + let parameters = self.clientAPIParameters(for: card) self.apiClient.post("v1/payment_methods/credit_cards", parameters: parameters) {body, _, error in if let error = error as NSError? { @@ -137,9 +136,9 @@ import BraintreeCore return false } - private func clientAPIParameters(for request: BTCardRequest) -> [String: Any] { + private func clientAPIParameters(for card: BTCard) -> [String: Any] { var parameters: [String: Any] = [:] - parameters["credit_card"] = request.card.parameters() + parameters["credit_card"] = card.parameters() let metadata: [String: String] = [ "source": apiClient.metadata.source.stringValue, @@ -149,9 +148,9 @@ import BraintreeCore parameters["_meta"] = metadata - if request.card.authenticationInsightRequested { + if card.authenticationInsightRequested { parameters["authenticationInsight"] = true - parameters["merchantAccountId"] = request.card.merchantAccountID + parameters["merchantAccountId"] = card.merchantAccountID } return parameters diff --git a/Sources/BraintreeCard/BTCardRequest.swift b/Sources/BraintreeCard/BTCardRequest.swift index db28a23276..8a8595cc46 100644 --- a/Sources/BraintreeCard/BTCardRequest.swift +++ b/Sources/BraintreeCard/BTCardRequest.swift @@ -1,6 +1,8 @@ import Foundation /// Contains information about a card to tokenize +// TODO: - NEXT_MAJOR_VERSION remove this class +@available(*, deprecated, message: "Use BTCard directly instead") @objcMembers public class BTCardRequest: NSObject { /// The `BTCard` associated with this instance.