woocommerce / woocommerce-blocks

(Deprecated) This plugin has been merged into woocommerce/woocommerce
https://wordpress.org/plugins/woo-gutenberg-products-block/
GNU General Public License v3.0
403 stars 219 forks source link

Checkout block and WC Pay result in 'payment_method_data[billing_details][name]' type errors #4880

Closed melek closed 2 years ago

melek commented 2 years ago

Describe the bug

The Checkout block causes a validation issue when checking out with WC Pay in test mode. I did not test this in live mode.

To reproduce

Steps to reproduce the behavior:

  1. Install WooCommerce with Storefront, WooCommerce, WooCommerce Blocks, and WooCommerce Payments set to 'Test Mode'.
  2. On the checkout page, add a checkout block with a phone field set as Optional.
  3. As a guest user in a private window, add an item to cart and try to checkout with no phone number added.
  4. See error:

    You passed an empty string for 'payment_method_data[billing_details][name]'. We assume empty values are an attempt to unset a parameter; however 'payment_method_data[billing_details][name]' cannot be unset. You should remove 'payment_method_data[billing_details][name]' from your request or supply a non-empty value.

  5. Try again on the same page. The error repeats.
  6. Refresh the checkout page. Checkout with a phone number entered such as 555-555-5555.
  7. See error repeat, but with [phone] instead of [name] (and shows up twice for me)
  8. Refresh the checkout page. Optionally remove the phone number, and check out.
  9. Checkout succeeds. It appears checkout will continue to succeed for the same guest session, indicating to me there is something session-related happening.

I had this happen when logged in as well with [phone], I think it was because I had no phone number in my profile - but I didn't test that. It was a little finicky, but I can reliably reproduce.

Expected behavior

No error should occur.

Screenshots

Screenshot
If you do not see the image, please click here.

Environment

WordPress (please complete the following information):

Desktop (please complete the following information):

Additional context

nerrad commented 2 years ago

This looks like it is potentially an issue with WooCommerce Payments and not Checkout Blocks given the error appears to be coming from WooCommerce Payments. I'm going to move the issue for initial triage to that repository.