-
Notifications
You must be signed in to change notification settings - Fork 112
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] Handle Network errors for payments using site credentials #14980
[Mobile Payments] Handle Network errors for payments using site credentials #14980
Conversation
When using site credentials, we get `NetworkError` not `DotcomError`. Previously, we handled the `orderCaptureError` as a special case when we got it while logged in via Jetpack, but as a generic error when using site credentials By using the new `PaymentError`, we can decode the `NetworkError` responses for `orderCaptureError` and use the special case handling however you log in.
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
908e02d
to
14b7bb8
Compare
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.
LGTM 🚢
✅ Triggers a call to delete the charge from storage when needed
✅ When failing capturing a payment, the proper localized error appears
TIL that the chargeID
is case-sensitive
Closes: #14409
Description
This PR ensures that we decode specific payment-related NetworkErrors, which we receive when using site credentials rather than Jetpack.
Additionally, it resolves an issue that was preventing localized error messages from being shown when payment capture failed. Without fixing this, it would be very difficult to test.
Two payment errors are covered: errors fetching a charge, and errors capturing a payment.
Steps to reproduce
To cause an error when fetching a charge, replace the path in
WCPayRemote.fetchCharge(for:chargeID:completion:)
with:Issue Refund
CardPresentPaymentStore.fetchCharge(siteID:chargeID:completion:)
To cause an error when capturing a payment, replace the
minimumAllowedChargeAmount
inCardPresentPaymentsConfiguration
with a lower number, e.g. 0.1, then try to take payment for an amount between the real minimum and your reduced minimum.Note that this PR does not fully adopt the new error available in WooPayments – pdfdoF-6h1-p2 for context. To do that, we can add to the decoding of the data returned with the error, which will be easier with
NetworkError
thanDotcomError
. When we do adopt that, we can provide the localization in the app, rather than relying on the server localization as we do in these cases now.Testing information
There's no visual difference when refunding a payment, the correct unwrapping of the error triggers a call to delete the charge from storage.
When capturing a payment, you can now see the message from WCPay or the app's localization in the UI, rather than
Yosemite.ServerSideCaptureError 0
Screenshots
Capture
Jetpack login
Site creds login
Refund
Jetpack login
Site creds login
RELEASE-NOTES.txt
if necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: