woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
237 stars 207 forks source link

Apple Pay / Google Pay ignoring additional fields on block checkout #3431

Open crot4lus opened 2 months ago

crot4lus commented 2 months ago

Describe the bug In our installation we've registered a checkout field in the block based checkout for a delivery date. This is created using the woocommerce_register_additional_checkout_field WooCommerce function. When checking out via Apple Pay on Stripe, I can see in the request params to /?wc-ajax=wc_stripe_create_order that the field is included:

additional_information-order-date: 2024-09-13

However this gets ignored, and doesn't get added as a meta field. On a standard checkout process this would be stored in the wp_wc_orders_meta table as _wc_other/order-date.

I have a fallback for normal orders where this might fail using the woocommerce_store_api_checkout_order_processed hook to set it to the first available delivery date if the request doesn't contain it, but this doesn't get used during the Stripe Apple Pay/Gpay process either.

crot4lus commented 2 months ago

As an aside to this, there is no obvious way for the end user to see we have a date field as it's located at the bottom of the checkout page. It also ignores the checkbox for Terms & Conditions.

The PayPal plugin does things differently, it allows you to choose Apple / Google Pay, authorise the payment then returns you to the checkout to complete any additional information and confirm your acceptance of the Terms.

A similar process for Stripe would be great.

annemirasol commented 1 month ago

There are a couple of challenges in supporting additional fields for Express Checkout (Apple Pay/Google Pay). I am listing them in order of complexity as I see it.

  1. We need to manually extract the additional fields and add them to the data we are passing when creating the order. We are already doing this for shortcode checkout; we need to add support for blocks checkout.
  2. Even with the above, Express Checkout uses WooCommerce's WC_Checkout::process_checkout() function, which at the moment does not support additional fields.
    • Regular (non-express) checkout uses Store API which supports it.
    • We need to add support for additional fields to WC_Checkout::process_checkout(), or maybe consider shifting to Store API?
  3. This needs more design thinking. Express Checkout is available in the checkout, cart and product pages.
    • The above-described manual extraction of additional field values from the checkout form will not work for the cart and product pages, where said form is not present. Even if we limit our scope of support to the checkout page, this approach assumes the additional field is already populated, e.g. the user knows to fill it out beforehand, before the express checkout is triggered.