Skip to content

Commit 890423f

Browse files
committed
Fix onboarding looking only at accounts for the gateway we are checking
1 parent 721ec11 commit 890423f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
218218
}
219219

220220
func accountChecks(plugin: CardPresentPaymentsPlugin) -> CardPresentPaymentOnboardingState {
221-
guard let account = getPaymentGatewayAccount() else {
221+
guard let account = getPaymentGatewayAccount(plugin: plugin) else {
222222
/// Active plugin but unable to fetch an account? Prompt the merchant to finish setting it up.
223223
return .pluginSetupNotCompleted(plugin: plugin)
224224
}
@@ -272,13 +272,13 @@ private extension CardPresentPaymentsOnboardingUseCase {
272272

273273
// Note: This counts on synchronizeStoreCountryAndPlugins having been called to get
274274
// the appropriate account for the site, be that Stripe or WCPay
275-
func getPaymentGatewayAccount() -> PaymentGatewayAccount? {
275+
func getPaymentGatewayAccount(plugin: CardPresentPaymentsPlugin) -> PaymentGatewayAccount? {
276276
guard let siteID = siteID else {
277277
return nil
278278
}
279279
return storageManager.viewStorage
280280
.loadPaymentGatewayAccounts(siteID: siteID)
281-
.first(where: \.isCardPresentEligible)?
281+
.first(where: { $0.isCardPresentEligible && $0.gatewayID == plugin.gatewayID })?
282282
.toReadOnly()
283283
}
284284

WooCommerce/WooCommerceTests/ViewRelated/CardPresentPayments/CardPresentPaymentsOnboardingUseCaseTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class CardPresentPaymentsOnboardingUseCaseTests: XCTestCase {
235235
// Given
236236
setupCountry(country: .us)
237237
setupWCPayPlugin(status: .active, version: WCPayPluginVersion.minimumSupportedVersion)
238-
setupPaymentGatewayAccount(accountType: StripeAccount.self, status: .complete, isLive: true, isInTestMode: true)
238+
setupPaymentGatewayAccount(accountType: WCPayAccount.self, status: .complete, isLive: true, isInTestMode: true)
239239

240240
// When
241241
let useCase = CardPresentPaymentsOnboardingUseCase(storageManager: storageManager, stores: stores)
@@ -334,7 +334,7 @@ class CardPresentPaymentsOnboardingUseCaseTests: XCTestCase {
334334
setupCountry(country: .us)
335335
setupWCPayPlugin(status: .inactive, version: WCPayPluginVersion.minimumSupportedVersion)
336336
setupStripePlugin(status: .active, version: StripePluginVersion.minimumSupportedVersion)
337-
setupPaymentGatewayAccount(accountType: WCPayAccount.self, status: .complete)
337+
setupPaymentGatewayAccount(accountType: StripeAccount.self, status: .complete)
338338

339339
// When
340340
let useCase = CardPresentPaymentsOnboardingUseCase(storageManager: storageManager, stores: stores)

0 commit comments

Comments
 (0)