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

feat: error message on 1M+ amount #8793

Merged
merged 9 commits into from May 17, 2024
Merged

Conversation

frosso
Copy link
Contributor

@frosso frosso commented May 7, 2024

Fixes #7485

Changes proposed in this Pull Request

Adds an error notice when the amount exceeds 1M in the settlement currency (EUR, USD, etc.).

Testing instructions

  • Create a product to the cart to exceed the 1M (e.g.: $1000000 USD or 1000000€)
  • Go to the blocks or shortcode checkout
  • Select WooPayments as the processor
  • The error should appear in place of the payment element component
    • You might notice there is a console error related to Stripe fingerprinting, but I wasn't able to resolve it 😬
    • I wasn't able to remove the "save payment method" checkbox on blocks checkout

Blocks checkout with SEPA/Card
Screenshot 2024-05-07 at 6 43 06 PM
Screenshot 2024-05-07 at 6 42 56 PM

Shortcode checkout with TT4 theme & SEPA
Screenshot 2024-05-07 at 6 11 29 PM

Shortcode checkout with Storefront theme & SEPA/Card
Screenshot 2024-05-07 at 6 10 58 PM
Screenshot 2024-05-07 at 6 10 52 PM


  • 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

@botwoo
Copy link
Collaborator

botwoo commented May 7, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 8793 or branch name feat/error-notice-on-1m-amount 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: 3e60a91
  • Build time: 2024-05-17 08:11:08 UTC

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

Copy link
Contributor

github-actions bot commented May 7, 2024

Size Change: +317 B (0%)

Total Size: 1.25 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout.js 56.2 kB +152 B (0%)
release/woocommerce-payments/dist/checkout.js 37.4 kB +165 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.08 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.08 kB
release/woocommerce-payments/assets/css/success.css 172 B
release/woocommerce-payments/assets/css/success.rtl.css 172 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.06 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.07 kB
release/woocommerce-payments/dist/bnpl-announcement-rtl.css 530 B
release/woocommerce-payments/dist/bnpl-announcement.css 531 B
release/woocommerce-payments/dist/bnpl-announcement.js 20 kB
release/woocommerce-payments/dist/cart-block.js 21.4 kB
release/woocommerce-payments/dist/cart.js 4.44 kB
release/woocommerce-payments/dist/checkout-rtl.css 599 B
release/woocommerce-payments/dist/checkout.css 599 B
release/woocommerce-payments/dist/index-rtl.css 40.7 kB
release/woocommerce-payments/dist/index.css 40.7 kB
release/woocommerce-payments/dist/index.js 293 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.28 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 59.6 kB
release/woocommerce-payments/dist/multi-currency.css 3.29 kB
release/woocommerce-payments/dist/multi-currency.js 54.7 kB
release/woocommerce-payments/dist/order-rtl.css 733 B
release/woocommerce-payments/dist/order.css 735 B
release/woocommerce-payments/dist/order.js 41.9 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.21 kB
release/woocommerce-payments/dist/payment-gateways.css 1.21 kB
release/woocommerce-payments/dist/payment-gateways.js 38.7 kB
release/woocommerce-payments/dist/payment-request-rtl.css 155 B
release/woocommerce-payments/dist/payment-request.css 155 B
release/woocommerce-payments/dist/payment-request.js 12 kB
release/woocommerce-payments/dist/product-details-rtl.css 398 B
release/woocommerce-payments/dist/product-details.css 402 B
release/woocommerce-payments/dist/product-details.js 17.2 kB
release/woocommerce-payments/dist/settings-rtl.css 11.1 kB
release/woocommerce-payments/dist/settings.css 10.9 kB
release/woocommerce-payments/dist/settings.js 201 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 527 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 527 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 19.4 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 693 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 18.5 kB
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 236 B
release/woocommerce-payments/dist/tos.js 21 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 4.81 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 155 B
release/woocommerce-payments/dist/woopay-express-button.css 155 B
release/woocommerce-payments/dist/woopay-express-button.js 21 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.25 kB
release/woocommerce-payments/dist/woopay.css 4.22 kB
release/woocommerce-payments/dist/woopay.js 69.4 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 622 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 815 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.44 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 196 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 196 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 627 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 628 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 202 B
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-connection/src/sso/jetpack-sso-admin-create-user.css 214 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 523 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 722 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 408 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 230 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.36 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.5 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.36 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

@frosso frosso requested review from a team and FangedParakeet and removed request for a team May 7, 2024 16:52
@frosso frosso marked this pull request as ready for review May 7, 2024 16:52
Copy link
Contributor

@FangedParakeet FangedParakeet left a comment

Choose a reason for hiding this comment

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

This is working as expected for me and the changes look fine.

I wasn't able to remove the "save payment method" checkbox on blocks checkout

I guess, AFAICT, it appears that this option is set when we register the payment gateway and presumably cannot be updated later. Stripe will only inform us of the error after this fact, so I guess we're stuck here.

You might notice there is a console error related to Stripe fingerprinting, but I wasn't able to resolve it 😬

I spent a little time investigating this as well...and was unsurprisingly unable to come up with any more answers than you have. This error does appear to originate from within Stripe's own iframe, so perhaps this is just some error case that they are failing to handle adequately on their end. So it goes.

I did notice this error appearing on the blocks checkout.

paymentRequestPaymentMethod error
Sad

I thought this was particularly peculiar, because it seemed to originate from the paymentRequestPaymentMethod object, which is part of our payment request button implementation. The error message is unsurprisingly unhelpful, but I noticed that this error still appeared even when I disabled the express checkout methods from my store's payments' settings.

It looks like we are registering the payment request button, unless I'm mistaken, in all cases, so perhaps there needs to be additional error handling here--with no fault being given to the changes here nor any onus on resolving this within the current PR.

I did notice one more thing that did give me a little further pause for thought. In both our blocks and shortcode checkouts, when the payment error returns an error and is unusable, the "Place order" button is still selectable.

On the blocks checkout, if we select the "Place order" button, we are returned this error message, which is somewhat meaningful and prevents the checkout from continuing.

Blocks checkout error message
Blocks checkout place order error message

However, on the shortcode, we are presented with this lovely "r is undefined" error message instead.

Shortcode checkout error message
Wut

I was wondering whether you had encountered this rather unattractive message or if you had any thoughts about how we might deal with it? Also, did you consider disabling the "Place order" button at all, in case there are no other payment gateways available. I'm not sure if there is a way for a payment gateway to inform WC that the gateway is inoperable, but I'd presume there isn't one.

Interested to hear your thoughts on the above before proceeding. 🙏

@frosso
Copy link
Contributor Author

frosso commented May 9, 2024

However, on the shortcode, we are presented with this lovely "r is undefined" error message instead.

Ah, good find! While debugging this, I noticed that the exception is being thrown around here on shortcode checkout.

But it's weird that blocks checkout uses the same function, but a different error is thrown 🙄

I'll continue looking into this, thanks for pointing it out! 👍

@frosso
Copy link
Contributor Author

frosso commented May 10, 2024

I'll continue looking into this, thanks for pointing it out! 👍

@FangedParakeet in 5f15aa6 I made a change to align the implementation with the blocks checkout a bit more - on the blocks checkout we rely on the event.complete attribute on the onChange handler. So that's why the error was different.

Now the two implementations should be a little bit more aligned.

Copy link
Contributor

@FangedParakeet FangedParakeet left a comment

Choose a reason for hiding this comment

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

Nice one! Tested on blocks and shortcode, plus a few checkouts with new and saved information just to be safe, and this is working mostly as expected for me. I just want to raise two small peculiarities that I noticed along the way.

Firstly, on my hideous dark-mode test-site, I noticed that the warning was sadly illegible. This isn't necessarily the fault of this PR and I'm not sure if there's much in our power to improve this, so don't think it's a big deal.

Illegible warning
I can't see

Also, I noticed on the shortcode checkout, if I tried to place an order with the payment element prevented from working, the error at the top of the page appeared as expected, but the warning on the payment element disappeared, leaving the gateway empty. On the block checkout, both warnings persisted.

Empty gateway
Sad, lonely gateway

This also isn't really a big deal, because the goal is to prevent the checkout and to show a warning--and one warning is better than none.

Anyways, I don't think either of these problems are showstoppers, so let's keep the train rolling. :shipit:

Comment on lines +404 to +408
upeElement.on( 'change', ( e ) => {
gatewayUPEComponents[ paymentMethodType ].isPaymentInformationComplete =
e.complete;
} );
upeElement.on( 'loaderror', ( e ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
upeElement.on( 'change', ( e ) => {
gatewayUPEComponents[ paymentMethodType ].isPaymentInformationComplete =
e.complete;
} );
upeElement.on( 'loaderror', ( e ) => {
upeElement.on( 'change', ( event ) => {
gatewayUPEComponents[ paymentMethodType ].isPaymentInformationComplete =
event.complete;
} );
upeElement.on( 'loaderror', ( event ) => {

Just sayin'. 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, event is already defined a few lines above, so I can't name this the same :(

https://github.com/Automattic/woocommerce-payments/blob/feat/error-notice-on-1m-amount/client/checkout/classic/payment-processing.js#L392

@frosso
Copy link
Contributor Author

frosso commented May 17, 2024

Firstly, on my hideous dark-mode test-site, I noticed that the warning was sadly illegible. This isn't necessarily the fault of this PR and I'm not sure if there's much in our power to improve this, so don't think it's a big deal.

Do you happen to know if the other WC frontend notices that appear on your site also have insufficient color contrast?

@frosso frosso merged commit 9eab5e4 into develop May 17, 2024
11 of 13 checks passed
@frosso frosso deleted the feat/error-notice-on-1m-amount branch May 17, 2024 08:08
@FangedParakeet
Copy link
Contributor

Do you happen to know if the other WC frontend notices that appear on your site also have insufficient color contrast?

Good point! This main notice also requires some squinting to read too, so likely this is just a result of me making my site as hideous as humanly possible. 😂

Illegible notice
👍

@csmcneill
Copy link
Contributor

I tested this a bit today and have these observations:

  1. The error also shows up on the My account > Payment methods page.

CleanShot 2024-05-20 at 13 33 28@2x

  1. The error notice does not seem to account for some currency-specific formatting:
  • For some currencies, I'd expect for the value in the error to be non-decimal and use the same separators, abbreviations, decimal places, and currency symbols

CleanShot 2024-05-20 at 13 34 37@2x

CleanShot 2024-05-20 at 13 58 42@2x

  • Affected currencies included but are not limited to: ₡ CRC, $ CLP, Fr DJF, Fr GNF, Fr KMF, ₲ PYG, Ush UGX, ₫ VND, CFA XOF, ₪ ILS, and Fr XPF
  • I thought that this affected all zero-decimal currencies, but some of them work just fine because of their standard format: ¥ JPY, ₩ KRW, Ar MGA, Fr RWF, and Vt VUV

CleanShot 2024-05-20 at 13 35 59@2x

@csmcneill
Copy link
Contributor

csmcneill commented May 21, 2024

I did some more testing and found another quirk: saved cards can still be used for orders exceeding the maximum amount, but errors aren't always shown.

On my self-hosted site, using a saved payment via the Checkout Block produces a 400 response. This generates an error on the front-end:

CleanShot 2024-05-20 at 19 23 05@2x

However, on my Atomic site, using a saved payment via the Checkout Block produces a 402 response. This generates no error on the front-end at all because 402 errors are reserved for WP Cloud on Atomic p9F6qB-cgE-p2 🫠

@frosso
Copy link
Contributor Author

frosso commented May 21, 2024

Hey @csmcneill , thanks for testing! 👋
What version of WC were you using for your tests? This PR
(to ensure a 400 is returned instead of 402) should be in one of the latest betas, and it should appear in one of the next releases.

@csmcneill
Copy link
Contributor

@frosso That's it! I was testing the latest Nightly build on my self-hosted site. I forgot to revert back to WooCommerce 8.9.x before testing this :)

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.

No alert if payment is over $999.999.99 or under $0.50 -Card input fields are not rendered.
4 participants