Skip to content

Conversation

@joshheald
Copy link
Contributor

@joshheald joshheald commented Oct 31, 2025

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.

finish setup

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:

  • If one or both of the account requests succeed, we return success
  • If both account requests fail, we return the error
  • If they don't do either... we return a new error! Generally this shouldn't happen, but we've removed a no-completion call from the flow here.

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_status
  • wc/v3/payments/accounts
  • wc/v3/wc_stripe/account/summary

Set 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.

  1. Leaving your breakpoints turned off, log out, and back in again.
  2. Go to an order and turn your breakpoints on
  3. Start taking payment, select card reader
  4. Onboarding should start with the loading screen
  5. Abort the system status request
  6. Observe that the no connection error is shown
  7. Tap Retry
  8. Allow the system status request, then abort the accounts request
  9. Observe that the no connection error is shown again
  10. Tap Retry and allow all the requests
  11. Observe that onboarding completes.

Screenshots

Onboarding.error.handling.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@joshheald joshheald added this to the 23.7 milestone Oct 31, 2025
@joshheald joshheald added type: bug A confirmed bug. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. labels Oct 31, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 31, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16304-eb5c1b9
Version23.6
Bundle IDcom.automattic.alpha.woocommerce
Commiteb5c1b9
Installation URL6pml4vd59m5g8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@joshheald joshheald marked this pull request as ready for review October 31, 2025 16:50
@joshheald joshheald requested a review from jaclync November 3, 2025 03:02
Copy link
Contributor

@jaclync jaclync left a 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! :shipit:

Comment on lines +686 to +687
//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 {
Copy link
Contributor

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?

Suggested change
//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 {

Copy link
Contributor Author

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.

Comment on lines 303 to 315
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)
Copy link
Contributor

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.

Suggested change
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)

@joshheald joshheald merged commit d9ffd67 into trunk Nov 3, 2025
14 checks passed
@joshheald joshheald deleted the woomob-1033-pay-with-card-reader-option-in-take-payment-orders-shows branch November 3, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: mobile payments Related to mobile payments / card present payments / Woo Payments. type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants