-
Notifications
You must be signed in to change notification settings - Fork 120
[Mobile Payments] Show network error when onboarding requests fail #16304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mobile Payments] Show network error when onboarding requests fail #16304
Conversation
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the POS onboarding flow followed by successful payment with both WPCOM & application passwords login, worked as expected! ![]()
| //periphery:ignore - logging this error detail in WooCommerce is useful, if it ever happens. It's part of the public API here. | ||
| public enum CardPresentPaymentStoreError: Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this error enum doesn't seem used outside of Yosemite. Could it be internal to avoid the Periphery warning?
| //periphery:ignore - logging this error detail in WooCommerce is useful, if it ever happens. It's part of the public API here. | |
| public enum CardPresentPaymentStoreError: Error { | |
| enum CardPresentPaymentStoreError: Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not used, but I see it as part of the public API, as the store is used from outside Yosemite and the clients could definitely care about the errors that come back.
...ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift
Outdated
Show resolved
Hide resolved
| let expectation = self.expectation(description: "Load Account succeeds with WCPay only") | ||
| network.simulateResponse(requestUrlSuffix: "payments/accounts", | ||
| filename: "wcpay-account-complete") | ||
| network.simulateResponse(requestUrlSuffix: "wc_stripe/account/summary", | ||
| filename: "generic_error") | ||
|
|
||
| let action = CardPresentPaymentAction.loadAccounts(siteID: sampleSiteID, onCompletion: { result in | ||
| XCTAssertTrue(result.isSuccess) | ||
| expectation.fulfill() | ||
| }) | ||
|
|
||
| cardPresentStore.onAction(action) | ||
| wait(for: [expectation], timeout: Constants.expectationTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: with TestKit import, could simplify the async testing. Similarly for the other 2 test cases.
| let expectation = self.expectation(description: "Load Account succeeds with WCPay only") | |
| network.simulateResponse(requestUrlSuffix: "payments/accounts", | |
| filename: "wcpay-account-complete") | |
| network.simulateResponse(requestUrlSuffix: "wc_stripe/account/summary", | |
| filename: "generic_error") | |
| let action = CardPresentPaymentAction.loadAccounts(siteID: sampleSiteID, onCompletion: { result in | |
| XCTAssertTrue(result.isSuccess) | |
| expectation.fulfill() | |
| }) | |
| cardPresentStore.onAction(action) | |
| wait(for: [expectation], timeout: Constants.expectationTimeout) | |
| // Given | |
| network.simulateResponse(requestUrlSuffix: "payments/accounts", | |
| filename: "wcpay-account-complete") | |
| network.simulateResponse(requestUrlSuffix: "wc_stripe/account/summary", | |
| filename: "generic_error") | |
| // When | |
| let result = waitFor { promise in | |
| self.cardPresentStore.onAction(CardPresentPaymentAction.loadAccounts(siteID: self.sampleSiteID, onCompletion: { result in | |
| XCTAssertTrue(result.isSuccess) | |
| promise(result) | |
| })) | |
| } | |
| // Then | |
| XCTAssertTrue(result.isSuccess) |
Co-authored-by: Jaclyn Chen <[email protected]>

Description
This PR updates our error handling during Card Present Payments Onboarding to show network errors when the gateway account or system status requests fail.
Previously, errors in these requests would result in us showing a "Finish Setup" message, suggesting there was more for the user to do on the web before they could take payments. This was confusing, because they may well have been fully setup and onboarded – the app just couldn't tell because it couldn't fetch their payments account.
Generally speaking, people won't hit these issues because of having no internet connection, but there could be other issues with them making a particular call.
Changes
There was already some code to handle
noConnectionError, but it didn't work because it was too picky about the types of errors which would be considered. Network errors tend to be AlamofireErrors, so we now consider these as "connection" errors when we encounter them during onboarding.The payment gateway account request was a little different, as errors were never sent to the view. Ironically, it would almost always error, because we check both Stripe and WooPayments to see whether there's an account or not. I've changed that behaviour:
Back in CardPresentPaymentsOnboardingUseCase, when we get an error from these (i.e. there's no account) we show the connection error.
Test Steps
Network breakpoints are your friend. Aborting a bunch of requests is the way to reproduce this.
wc/v3/system_statuswc/v3/payments/accountswc/v3/wc_stripe/account/summarySet your breakpoints on the request, and abort them before they go out to the server.
It's worth testing with both WordPress.com credentials and site credentials, as errors can be affected by that.
RetryRetryand allow all the requestsScreenshots
Onboarding.error.handling.mp4
RELEASE-NOTES.txtif necessary.