From 23c767fb8490972fcfddb525941569d3c5fbc08b Mon Sep 17 00:00:00 2001 From: Amy Date: Thu, 25 Apr 2024 09:29:49 -0400 Subject: [PATCH] MBL-1368: Enable Stripe Link by adding e-mail to PaymentSheet.Configuration --- Library/TestHelpers/Stripe+PaymentMethod.swift | 6 +++--- Library/ViewModels/PaymentMethodSettingsViewModel.swift | 5 +++++ Library/ViewModels/PledgePaymentMethodsViewModel.swift | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Library/TestHelpers/Stripe+PaymentMethod.swift b/Library/TestHelpers/Stripe+PaymentMethod.swift index dcc4984022..4b4673f476 100644 --- a/Library/TestHelpers/Stripe+PaymentMethod.swift +++ b/Library/TestHelpers/Stripe+PaymentMethod.swift @@ -22,15 +22,15 @@ extension STPPaymentMethod { ]) static let sampleStringPaymentOption: (STPPaymentMethod) -> PaymentSheet.PaymentOption = { paymentMethod in - PaymentSheet.PaymentOption.saved(paymentMethod: paymentMethod) + PaymentSheet.PaymentOption.saved(paymentMethod: paymentMethod, confirmParams: nil) } static let samplePaymentOptionsDisplayData: (PaymentSheet.PaymentOption) -> PaymentSheetPaymentOptionsDisplayData = { paymentOption in switch paymentOption { - case let .saved(paymentMethod): + case .saved: return PaymentSheetPaymentOptionsDisplayData(image: .add, label: "••••1234") - case .applePay, .new, .link: + case .applePay, .new, .link, .external: return PaymentSheetPaymentOptionsDisplayData(image: .add, label: "Unknown") } } diff --git a/Library/ViewModels/PaymentMethodSettingsViewModel.swift b/Library/ViewModels/PaymentMethodSettingsViewModel.swift index 61e567e318..da2cde545a 100644 --- a/Library/ViewModels/PaymentMethodSettingsViewModel.swift +++ b/Library/ViewModels/PaymentMethodSettingsViewModel.swift @@ -157,6 +157,11 @@ public final class PaymentMethodSettingsViewModel: PaymentMethodsViewModelType, var configuration = PaymentSheet.Configuration() configuration.merchantDisplayName = Strings.general_accessibility_kickstarter() configuration.allowsDelayedPaymentMethods = true + + if featureStripeLinkEnabled() { + configuration.defaultBillingDetails.email = AppEnvironment.current.currentUserEmail + } + let data = PaymentSheetSetupData( clientSecret: envelope.clientSecret, configuration: configuration, diff --git a/Library/ViewModels/PledgePaymentMethodsViewModel.swift b/Library/ViewModels/PledgePaymentMethodsViewModel.swift index eb2a13c47b..4a6eacc619 100644 --- a/Library/ViewModels/PledgePaymentMethodsViewModel.swift +++ b/Library/ViewModels/PledgePaymentMethodsViewModel.swift @@ -346,6 +346,10 @@ public final class PledgePaymentMethodsViewModel: PledgePaymentMethodsViewModelT configuration.merchantDisplayName = Strings.general_accessibility_kickstarter() configuration.allowsDelayedPaymentMethods = paymentSheetType == .setupIntent + if featureStripeLinkEnabled() { + configuration.defaultBillingDetails.email = AppEnvironment.current.currentUserEmail + } + let data = PaymentSheetSetupData( clientSecret: clientSecret, configuration: configuration,