Skip to content

Commit

Permalink
Revert Stripe Link integration
Browse files Browse the repository at this point in the history
Revert "Set billingDetailsCollectionConfiguration.email to correctly turn Stripe Link on or off"

This reverts commit 366742e.

Revert "Remove Stripe Link from PaymentMethodSettingsViewModel"

This reverts commit affad96.

Revert "Move formatLinkLabel utility into its own class, with a test"

This reverts commit ce7c8f8.

Revert "Add comment to regex"

This reverts commit 787cbd5.

Revert "MBL-1368: Fetch PaymentMethod to display Stripe Link in pledge flow"

This reverts commit c55a641.

Revert "MBL-1368: Enable Stripe Link by adding e-mail to PaymentSheet.Configuration"

This reverts commit 23c767f.

Revert "Update Stripe SDK to 23.27.1"

This reverts commit 8586287.

Revert "MBL-1390: Add config flag for Stripe Link"

This reverts commit e9ce5d6.
  • Loading branch information
amy-at-kickstarter committed May 15, 2024
1 parent 366742e commit 761a562
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ final class PledgePaymentMethodsViewController: UIViewController {
strongSelf.paymentSheetFlowController?.presentPaymentOptions(from: strongSelf) { [weak self] in
guard let strongSelf = self else { return }

strongSelf.confirmPaymentResult(with: data)
strongSelf.confirmPaymentResult(with: data.clientSecret)
}
strongSelf.viewModel.inputs.stripePaymentSheetDidAppear()
}
Expand All @@ -191,7 +191,7 @@ final class PledgePaymentMethodsViewController: UIViewController {
}
}

private func confirmPaymentResult(with data: PaymentSheetSetupData) {
private func confirmPaymentResult(with clientSecret: String) {
guard self.paymentSheetFlowController?.paymentOption != nil else {
self.viewModel.inputs.shouldCancelPaymentSheetAppearance(state: true)

Expand All @@ -208,11 +208,12 @@ final class PledgePaymentMethodsViewController: UIViewController {

switch paymentResult {
case .completed:
strongSelf.didConfirmAddedPaymentOption(
paymentOption: existingPaymentOption,
forClientSecret: data.clientSecret,
forPaymentSheetType: data.paymentSheetType
let paymentDisplayData = PaymentSheetPaymentOptionsDisplayData(
image: existingPaymentOption.image,
label: existingPaymentOption.label
)
strongSelf.viewModel.inputs
.paymentSheetDidAdd(newCard: paymentDisplayData, clientSecret: clientSecret)
case .canceled:
// User cancelled intentionally so do nothing.
break
Expand All @@ -223,73 +224,6 @@ final class PledgePaymentMethodsViewController: UIViewController {
}
}

private func didConfirmAddedPaymentOption(
paymentOption: PaymentSheet.FlowController.PaymentOptionDisplayData,
forClientSecret clientSecret: String,
forPaymentSheetType paymentSheetType: PledgePaymentSheetType
) {
// Stripe also defines this constant, but it's defined internally to the Stripe SDK :(
let linkIdentifier = "link"

// For regular payment types, continue with the display information they gave us
if paymentOption.paymentMethodType != linkIdentifier {
let paymentDisplayData = PaymentSheetPaymentOptionsDisplayData(
image: paymentOption.image,
label: paymentOption.label
)

self.viewModel.inputs.paymentSheetDidAdd(newCard: paymentDisplayData, clientSecret: clientSecret)
return
}

// For link payment types, fetch the underlying payment method so we can get at the card type and label

switch paymentSheetType {
case .setupIntent:
STPAPIClient.shared
.retrieveSetupIntent(
withClientSecret: clientSecret,
expand: ["payment_method"]
) { [weak self] intent, _ in
guard let strongSelf = self else { return }
guard let paymentDisplayData = strongSelf.paymentDisplayData(forLink: intent?.paymentMethod)
else { return }
strongSelf.viewModel.inputs.paymentSheetDidAdd(
newCard: paymentDisplayData,
clientSecret: clientSecret
)
}

case .paymentIntent:
STPAPIClient.shared
.retrievePaymentIntent(
withClientSecret: clientSecret,
expand: ["payment_method"]
) { [weak self] intent, _ in
guard let strongSelf = self else { return }
guard let paymentDisplayData = strongSelf.paymentDisplayData(forLink: intent?.paymentMethod)
else { return }
strongSelf.viewModel.inputs.paymentSheetDidAdd(
newCard: paymentDisplayData,
clientSecret: clientSecret
)
}
}
}

private func paymentDisplayData(forLink optionalPaymentMethod: STPPaymentMethod?)
-> PaymentSheetPaymentOptionsDisplayData? {
guard let paymentMethod = optionalPaymentMethod else {
return nil
}

let formattedLabel = KSRStripeLink.formatLinkLabel(paymentMethod.label)
return PaymentSheetPaymentOptionsDisplayData(
image: paymentMethod.image,
label: formattedLabel ?? paymentMethod.label
)
}

private func updateAddNewPaymentMethodButtonLoading(state: Bool) {
self.dataSource.updateAddNewPaymentCardLoad(state: state)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 1 addition & 9 deletions Kickstarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,6 @@
E182E5BA2B8CDFDE0008DD69 /* AppEnvironmentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7ED1F121E830FDC00BFFA01 /* AppEnvironmentTests.swift */; };
E182E5BC2B8D36FE0008DD69 /* AppEnvironmentTests+OAuthInKeychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = E182E5BB2B8D36FE0008DD69 /* AppEnvironmentTests+OAuthInKeychain.swift */; };
E1972EA22BB4722D002517E6 /* PostCampaignCheckoutViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1972EA12BB4722D002517E6 /* PostCampaignCheckoutViewModelTests.swift */; };
E1982FE52BEABF8B0057BD09 /* KSRStripeLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1982FE32BEABF8B0057BD09 /* KSRStripeLink.swift */; };
E1982FE62BEABF8F0057BD09 /* KSRStripeLinkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1982FE22BEABF8B0057BD09 /* KSRStripeLinkTests.swift */; };
E1A149202ACDD7BF00F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryData.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1A1491F2ACDD7BF00F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryData.swift */; };
E1A149222ACE013100F49709 /* FetchProjectsEnvelope.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1A149212ACE013100F49709 /* FetchProjectsEnvelope.swift */; };
E1A149242ACE02B300F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1A149232ACE02B300F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryDataTests.swift */; };
Expand Down Expand Up @@ -3162,8 +3160,6 @@
E182E5BB2B8D36FE0008DD69 /* AppEnvironmentTests+OAuthInKeychain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppEnvironmentTests+OAuthInKeychain.swift"; sourceTree = "<group>"; };
E1889D8D2B6065D6004FBE21 /* CombineTestObserverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombineTestObserverTests.swift; sourceTree = "<group>"; };
E1972EA12BB4722D002517E6 /* PostCampaignCheckoutViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCampaignCheckoutViewModelTests.swift; sourceTree = "<group>"; };
E1982FE22BEABF8B0057BD09 /* KSRStripeLinkTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = KSRStripeLinkTests.swift; path = Library/KSRStripeLinkTests.swift; sourceTree = SOURCE_ROOT; };
E1982FE32BEABF8B0057BD09 /* KSRStripeLink.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = KSRStripeLink.swift; path = Library/KSRStripeLink.swift; sourceTree = SOURCE_ROOT; };
E1A1491F2ACDD7BF00F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FetchProjectsEnvelope+FetchBackerProjectsQueryData.swift"; sourceTree = "<group>"; };
E1A149212ACE013100F49709 /* FetchProjectsEnvelope.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchProjectsEnvelope.swift; sourceTree = "<group>"; };
E1A149232ACE02B300F49709 /* FetchProjectsEnvelope+FetchBackerProjectsQueryDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FetchProjectsEnvelope+FetchBackerProjectsQueryDataTests.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6121,8 +6117,6 @@
A71404381CAF215900A2795B /* KeyValueStoreType.swift */,
A71F59E71D2424CA00909BE3 /* KSCache.swift */,
A7ED1F171E830FDC00BFFA01 /* KSCacheTests.swift */,
E1982FE32BEABF8B0057BD09 /* KSRStripeLink.swift */,
E1982FE22BEABF8B0057BD09 /* KSRStripeLinkTests.swift */,
A7C725821C85D36D005A016B /* Language.swift */,
A7ED1F181E830FDC00BFFA01 /* LanguageTests.swift */,
A7C725831C85D36D005A016B /* LaunchedCountries.swift */,
Expand Down Expand Up @@ -7949,7 +7943,6 @@
59B0E07E1D147F340081D2DC /* DashboardStyles.swift in Sources */,
470B771A26FCDC8900EBD5CA /* RiskMessagingViewModel.swift in Sources */,
0169F8C11D6CA27500C8D5C5 /* RootCategory.swift in Sources */,
E1982FE52BEABF8B0057BD09 /* KSRStripeLink.swift in Sources */,
D04AAC21218BB70D00CF713E /* ChangePasswordViewModel.swift in Sources */,
8A32FE0624D233F000F79C72 /* EmptyStateViewModel.swift in Sources */,
37FEFBC8222F1E4F00FCA608 /* ProcessInfoType.swift in Sources */,
Expand Down Expand Up @@ -8048,7 +8041,6 @@
A7ED1F281E830FDC00BFFA01 /* CircleAvatarImageViewTests.swift in Sources */,
606C45F829FACD9F001BA067 /* RemoteConfigFeature+HelpersTests.swift in Sources */,
A7ED1FB81E831C5C00BFFA01 /* BackingCellViewModelTests.swift in Sources */,
E1982FE62BEABF8F0057BD09 /* KSRStripeLinkTests.swift in Sources */,
A7ED1FFD1E831C5C00BFFA01 /* ProjectUpdatesViewModelTests.swift in Sources */,
191E60262A953E2B001413B2 /* ProjectTabCheckmarkListCellViewModelTests.swift in Sources */,
A7ED1F341E830FDC00BFFA01 /* SharedFunctionsTests.swift in Sources */,
Expand Down Expand Up @@ -10745,7 +10737,7 @@
repositoryURL = "https://github.com/stripe/stripe-ios";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 23.27.1;
minimumVersion = 23.10.0;
};
};
194C593E28F5E7FF00453249 /* XCRemoteSwiftPackageReference "Kickstarter-ReactiveExtensions" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/stripe/stripe-ios",
"state" : {
"revision" : "d0c607a3bce526f2fd27c87fa4822f285d378d3f",
"version" : "23.27.1"
"revision" : "e7bd9f65d40c20c1c84e6f335f60ff89f9f04a5d",
"version" : "23.10.0"
}
},
{
Expand Down
29 changes: 0 additions & 29 deletions Library/KSRStripeLink.swift

This file was deleted.

10 changes: 0 additions & 10 deletions Library/KSRStripeLinkTests.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Library/RemoteConfig/RemoteConfigFeature+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,3 @@ public func featureLoginWithOAuthEnabled() -> Bool {
public func featureUseKeychainForOAuthTokenEnabled() -> Bool {
featureEnabled(feature: .useKeychainForOAuthToken)
}

public func featureStripeLinkEnabled() -> Bool {
featureEnabled(feature: .stripeLinkEnabled)
}
2 changes: 0 additions & 2 deletions Library/RemoteConfig/RemoteConfigFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public enum RemoteConfigFeature: String, CaseIterable {
case reportThisProjectEnabled = "report_this_project"
case loginWithOAuthEnabled = "ios_oauth"
case useKeychainForOAuthToken = "use_keychain_for_oauth_token"
case stripeLinkEnabled = "stripe_link"
}

extension RemoteConfigFeature: CustomStringConvertible {
Expand All @@ -23,7 +22,6 @@ extension RemoteConfigFeature: CustomStringConvertible {
case .reportThisProjectEnabled: return "Report This Project"
case .loginWithOAuthEnabled: return "Login with OAuth"
case .useKeychainForOAuthToken: return "Use Keychain for OAuth token"
case .stripeLinkEnabled: return "Stripe Link"
}
}
}
6 changes: 3 additions & 3 deletions Library/TestHelpers/Stripe+PaymentMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ extension STPPaymentMethod {
])

static let sampleStringPaymentOption: (STPPaymentMethod) -> PaymentSheet.PaymentOption = { paymentMethod in
PaymentSheet.PaymentOption.saved(paymentMethod: paymentMethod, confirmParams: nil)
PaymentSheet.PaymentOption.saved(paymentMethod: paymentMethod)
}

static let samplePaymentOptionsDisplayData: (PaymentSheet.PaymentOption)
-> PaymentSheetPaymentOptionsDisplayData = { paymentOption in
switch paymentOption {
case .saved:
case let .saved(paymentMethod):
return PaymentSheetPaymentOptionsDisplayData(image: .add, label: "••••1234")
case .applePay, .new, .link, .external:
case .applePay, .new, .link:
return PaymentSheetPaymentOptionsDisplayData(image: .add, label: "Unknown")
}
}
Expand Down
1 change: 0 additions & 1 deletion Library/ViewModels/PaymentMethodSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public final class PaymentMethodSettingsViewModel: PaymentMethodsViewModelType,
var configuration = PaymentSheet.Configuration()
configuration.merchantDisplayName = Strings.general_accessibility_kickstarter()
configuration.allowsDelayedPaymentMethods = true

let data = PaymentSheetSetupData(
clientSecret: envelope.clientSecret,
configuration: configuration,
Expand Down
7 changes: 0 additions & 7 deletions Library/ViewModels/PledgePaymentMethodsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,6 @@ public final class PledgePaymentMethodsViewModel: PledgePaymentMethodsViewModelT
configuration.merchantDisplayName = Strings.general_accessibility_kickstarter()
configuration.allowsDelayedPaymentMethods = paymentSheetType == .setupIntent

if featureStripeLinkEnabled() {
configuration.defaultBillingDetails.email = AppEnvironment.current.currentUserEmail
configuration.billingDetailsCollectionConfiguration.email = .automatic
} else {
configuration.billingDetailsCollectionConfiguration.email = .always
}

let data = PaymentSheetSetupData(
clientSecret: clientSecret,
configuration: configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ private func isFeatureEnabled(_ feature: RemoteConfigFeature) -> Bool {
return featureLoginWithOAuthEnabled()
case .useKeychainForOAuthToken:
return featureUseKeychainForOAuthTokenEnabled()
case .stripeLinkEnabled:
return featureStripeLinkEnabled()
}
}

Expand Down

0 comments on commit 761a562

Please sign in to comment.