Skip to content
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

Pass additional data to the intent authentication exception #7873

Conversation

hsingyuc
Copy link
Contributor

@hsingyuc hsingyuc commented Dec 11, 2023

Slack discussion p1702070481324349/1702053239.912509-slack-C022WMN88KG

Currently, we only throw an exception message We're not able to process this payment. Please try again later. and don't have further information for debugging.

Changes proposed in this Pull Request

Throw additional data intent_meta_data and order_id to the intent authentication exception so we have more information for the failed order.

Testing instructions

  1. Test with Update to exception to throwable and pass additional data in store API woocommerce/woocommerce#42685
  2. Update the condition to true
  3. Add a log error_log(print_r($e,true)); behind the catch to see the additional data
  4. Place an order via WooPay
  5. Check the additional data in the debug log

If test with WooPay

See the test instruction https://github.com/Automattic/woopay/pull/2394


  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@hsingyuc hsingyuc requested review from lovo-h and bborman22 December 11, 2023 22:26
@botwoo
Copy link
Collaborator

botwoo commented Dec 11, 2023

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 7873 or branch name fix/pass-additional-data-to-intent-authentication-exception in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: ea9ee60
  • Build time: 2023-12-22 01:08:06 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Dec 11, 2023

Size Change: 0 B

Total Size: 1.27 MB

ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.06 kB
release/woocommerce-payments/assets/css/success.css 158 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 1.8 kB
release/woocommerce-payments/dist/blocks-checkout.css 1.8 kB
release/woocommerce-payments/dist/blocks-checkout.js 85.5 kB
release/woocommerce-payments/dist/checkout-rtl.css 318 B
release/woocommerce-payments/dist/checkout.css 319 B
release/woocommerce-payments/dist/checkout.js 37.1 kB
release/woocommerce-payments/dist/index-rtl.css 37.9 kB
release/woocommerce-payments/dist/index.css 37.9 kB
release/woocommerce-payments/dist/index.js 289 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.4 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.7 kB
release/woocommerce-payments/dist/multi-currency.css 3.4 kB
release/woocommerce-payments/dist/multi-currency.js 55.9 kB
release/woocommerce-payments/dist/order-rtl.css 676 B
release/woocommerce-payments/dist/order.css 679 B
release/woocommerce-payments/dist/order.js 42.3 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.31 kB
release/woocommerce-payments/dist/payment-gateways.css 1.31 kB
release/woocommerce-payments/dist/payment-gateways.js 39.5 kB
release/woocommerce-payments/dist/payment-request-rtl.css 153 B
release/woocommerce-payments/dist/payment-request.css 153 B
release/woocommerce-payments/dist/payment-request.js 13.6 kB
release/woocommerce-payments/dist/product-details.js 919 B
release/woocommerce-payments/dist/settings-rtl.css 10.4 kB
release/woocommerce-payments/dist/settings.css 10.4 kB
release/woocommerce-payments/dist/settings.js 233 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.4 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 710 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.5 kB
release/woocommerce-payments/dist/tos-rtl.css 230 B
release/woocommerce-payments/dist/tos.css 231 B
release/woocommerce-payments/dist/tos.js 22 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 153 B
release/woocommerce-payments/dist/woopay-express-button.css 153 B
release/woocommerce-payments/dist/woopay-express-button.js 52.6 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.18 kB
release/woocommerce-payments/dist/woopay.css 4.19 kB
release/woocommerce-payments/dist/woopay.js 71.8 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 622 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 812 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 522 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 581 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.32 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.8 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.32 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.03 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 291 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 781 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.05 kB

compressed-size-action

@hsingyuc hsingyuc marked this pull request as draft December 11, 2023 22:49
@hsingyuc hsingyuc force-pushed the fix/pass-additional-data-to-intent-authentication-exception branch from 79cf635 to fb61488 Compare December 11, 2023 22:50
@hsingyuc hsingyuc marked this pull request as ready for review December 13, 2023 15:09
@hsingyuc hsingyuc force-pushed the fix/pass-additional-data-to-intent-authentication-exception branch from 4f5510a to bd654f7 Compare December 13, 2023 15:13
@hsingyuc hsingyuc force-pushed the fix/pass-additional-data-to-intent-authentication-exception branch from 337f1f5 to 859d908 Compare December 15, 2023 01:54
@hsingyuc hsingyuc force-pushed the fix/pass-additional-data-to-intent-authentication-exception branch from c416d1d to e70d499 Compare December 18, 2023 03:20
Copy link
Member

@malithsen malithsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsingyuc I haven't yet tested the changes, but I have a couple of questions that I wanted to ask.

  1. I see a few other instances of the We're not able to process this payment. Please try again later. exception in the update_order_status function. Do we know if these can be reached in the WooPay flow? If yes, should they be updated as well?

  2. As far as I can see, WooPay doesn't display this error to the shopper. What do you think about changing the error message to better indicate the error and include the order_id and meta_order_id in the message itself? This would make it easier to get this onto production as we wouldn't need the WC dependency.

@hsingyuc
Copy link
Contributor Author

I see a few other instances of the We're not able to process this payment. Please try again later. exception in the update_order_status function. Do we know if these can be reached in the WooPay flow? If yes, should they be updated as well?

I did process of elimination, we are not going through the other exception while testing this error. Let me know if you found an edge case otherwise I think we don't need to worry about it.

As far as I can see, WooPay doesn't display this error to the shopper. What do you think about changing the error message to better indicate the error and include the order_id and meta_order_id in the message itself? This would make it easier to get this onto production as we wouldn't need the WC dependency.

I agree with more clear error message but we do display the message to the shopper on the WooPay checkout page(See below). Since you mentioned, it seems weird we show this message to shoppers.

Screen Shot 2023-12-20 at 4 42 37 PM

@malithsen
Copy link
Member

I agree with more clear error message but we do display the message to the shopper on the WooPay checkout page(See below). Since you mentioned, it seems weird we show this message to shoppers.

@hsingyuc Ah thanks, you're right. WDYT of removing the WCPay error message from WooPay and showing only the generic "Merchant store order creation failed" part.

If the merchant order fails, I don't think there'll be any actionable input for the shopper in the complete error message. We will still log the complete error in WooPay logs. I am suggesting this because, this way, we can include intent_meta_order_id and order_id directly in the error message and avoid introducing changes to the WC core, and associated backward compatibility issues.

@hsingyuc
Copy link
Contributor Author

WDYT of removing the WCPay error message from WooPay and showing only the generic "Merchant store order creation failed" part.
If the merchant order fails, I don't think there'll be any actionable input for the shopper in the complete error message. We will still log the complete error in WooPay logs. I am suggesting this because, this way, we can include intent_meta_order_id and order_id directly in the error message and avoid introducing changes to the WC core, and associated backward compatibility issues.

For a quick fix, that's a good approach. Do we need to get any input from designer, @pierorocca?

@hsingyuc
Copy link
Contributor Author

@malithsen After thinking about it more, does that mean we also change all the error messages to a generic message like We're not able to process this request. Please refresh the page and try again.. Meaning shoppers won't see Nonce is invalid and Coupon usage limit has been reached anymore?

@malithsen
Copy link
Member

malithsen commented Dec 22, 2023

@hsingyuc

Meaning shoppers won't see Nonce is invalid and Coupon usage limit has been reached anymore?

Nonce is invalid is not actionable to a shopper. "Coupon usage limit..." can be useful though.

Just taking a step back, do you think we still need this logging, given that order number mismatches are visible via the Stripe logs? (context: p1703179801368429/1703043494.702709-slack-C02CCT3F1QA)

The intention of implementing getAdditionalData is to get the mismatched order IDs logged, so that it'd help debug the intermittent order failures further. Since the order ID mismatches are visible on the Stripe logs, it would be enough to continue the investigation without further logs?

Edit: We seem to have failed orders that go against my initial hypothesis that they are failing because the woopay order id is equal to the merchant order id. So adding logs closer to the check would still be useful. P2: pdpOw2-45Y-p2#comment-3865

@pierorocca
Copy link
Contributor

If I'm following along correctly there seem to be different categories of errors - some not actionable, some too obscure for shopper comprehension, some that would be useful.

Could you please summarize all the use cases that need feedback?

@malithsen
Copy link
Member

After thinking about it more, does that mean we also change all the error messages to a generic message like We're not able to process this request. Please refresh the page and try again. Meaning shoppers won't see Nonce is invalid and Coupon usage limit has been reached anymore?

That's what I was initially thinking but to avoid a review of error messages that would increase the scope of this PR, perhaps we can handle the order_id_mismatch error separately. We append the order IDs to the error message, and on the WooPay side we extract it and log it in WooPayLogger. Finally, to avoid order ids from showing up on the frontend, remove them before throwing the error back. It's not as neat as the current solution, but avoids WC core changes and keeps the error notices visible to shopper as is.

@hsingyuc
Copy link
Contributor Author

If I'm following along correctly there seem to be different categories of errors - some not actionable, some too obscure for shopper comprehension, some that would be useful.
Could you please summarize all the use cases that need feedback?

That's correct. We have three types of error messages below showing to shoppers. Initially, Malith mentioned updating the three messages below to one generic message and showing it to shoppers. But now we might not do that because Coupon usage limit has been reached is actually helpful to shoppers. Since we have you here, do you think we should remove Merchant store order creation failed with the following error: or leave it as it is?

  1. Nonce is invalid
  2. Coupon usage limit has been reached
  3. Merchant store order creation failed with the following error: We're not able to process this payment. Please try again later. -----> This happens because the order id is not the same as the intent meta order id

image

@hsingyuc
Copy link
Contributor Author

We append the order IDs to the error message, and on the WooPay side we extract it and log it in WooPayLogger. Finally, to avoid order ids from showing up on the frontend, remove them before throwing the error back. It's not as neat as the current solution, but avoids WC core changes and keeps the error notices visible to shopper as is.

Are we confirming doing it this way? Do you think we should do both or close this PR? If we confirm doing this way, I can open PRs.

@malithsen
Copy link
Member

Are we confirming doing it this way? Do you think we should do both or close this PR? If we confirm doing this way, I can open PRs.

@hsingyuc If you don't have any concerns about the new approach, I think we should do that as it would allow us to get these logging out faster.

@hsingyuc hsingyuc mentioned this pull request Dec 29, 2023
6 tasks
@hsingyuc
Copy link
Contributor Author

PR created #7951

@pierorocca
Copy link
Contributor

Thanks @hsingyuc and @malithsen. Besides preventing errors as the first line of defense:

  1. For supported errors like coupon code is invalid or limit has been reached, these would be displayed to the user in plain language in a way that provides useful information or further instruction

  2. For non-recoverable errors, like "nonce is invalid" unrelated to payments processing, instead of surfacing a technical error to the user I'm thinking a plain language generic like "Oops, we've run into a problem. Please check out as guest." so that the shopper at least gets back to the store and tries again using another payment method. The actual technical message should still be logged.

  3. For "Merchant store order creation failed with the following error:" this seems like a serious, critical bug that would be better off resolved than improving the error message. Is there any circumstance where this error would legitimately occur? Agree with Malith's assessment to not include the order id in the shopper message but to include it in the logs.

@gpressutto5 recently updated many notifications to a new component. That work should be a good inventory of existing errors and error messages. Would there be value in taking that inventory of those error codes and come up with a revised list of front-end error messages?

@hsingyuc
Copy link
Contributor Author

hsingyuc commented Jan 12, 2024

Close the PR because this PR fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants