Skip to content

Commit 5c19233

Browse files
committed
Return failure to load account to completion
1 parent 1ea3fbf commit 5c19233

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Yosemite/Yosemite/Stores/CardPresentPaymentStore.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -443,15 +443,12 @@ private extension CardPresentPaymentStore {
443443
switch result {
444444
case .success(let wcpayAccount):
445445
let account = wcpayAccount.toPaymentGatewayAccount(siteID: siteID)
446-
print("==== CPPS successfully fetched WCPay account")
447446
self.upsertStoredAccountInBackground(readonlyAccount: account)
448-
case .failure:
449-
print("==== CPPS was unable to fetch WCPay account")
450-
DDLogDebug("Error fetching WCPay account - it is possible the extension is not installed or inactive")
447+
onCompletion(.success(()))
448+
case .failure(let error):
451449
self.deleteStaleAccount(siteID: siteID, gatewayID: WCPayAccount.gatewayID)
450+
onCompletion(.failure(error))
452451
}
453-
454-
onCompletion(.success(())) // TODO - consider bringing back Error, although callers don't currently use it
455452
}
456453
}
457454

@@ -467,14 +464,12 @@ private extension CardPresentPaymentStore {
467464
switch result {
468465
case .success(let stripeAccount):
469466
let account = stripeAccount.toPaymentGatewayAccount(siteID: siteID)
470-
print("==== CPPS successfully fetched Stripe account")
471467
self.upsertStoredAccountInBackground(readonlyAccount: account)
472-
case .failure:
473-
print("==== CPPS was unable to fetch Stripe account")
468+
onCompletion(.success(()))
469+
case .failure(let error):
474470
self.deleteStaleAccount(siteID: siteID, gatewayID: StripeAccount.gatewayID)
471+
onCompletion(.failure(error))
475472
}
476-
477-
onCompletion(.success(())) // TODO - consider bringing back Error, although callers don't currently use it
478473
}
479474
}
480475

Yosemite/YosemiteTests/Stores/CardPresentPaymentStoreTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ final class CardPresentPaymentStoreTests: XCTestCase {
255255
network.simulateResponse(requestUrlSuffix: "payments/accounts", filename: "generic_error")
256256

257257
let action = CardPresentPaymentAction.loadAccounts(siteID: sampleSiteID, onCompletion: { result in
258+
XCTAssertTrue(result.isFailure)
258259
expectation.fulfill()
259260
})
260261

0 commit comments

Comments
 (0)