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

Order of WooCommerce checkout actions causing incompatibility with AvaTax address validation (375) #335

Closed
nikolas4175-godaddy opened this issue Oct 19, 2021 · 8 comments · Fixed by #341
Labels
bug Something isn't working
Milestone

Comments

@nikolas4175-godaddy
Copy link

nikolas4175-godaddy commented Oct 19, 2021

Description

PayPal Payments is causing the woocommerce_checkout_order_processed action to run before woocommerce_after_checkout_validation when processing payment, which is reverse of how those actions are usually ran in WC.

AvaTax stores its wc_avatax_address_validated flag in session data, and this is later checked during woocommerce_after_checkout_validation . However, session data is reset during woocommerce_checkout_order_processed , so by calling that action first, PayPal Payments is causing the validation flag to be cleared before it can be verified.

This prevents payment from being processed and causes the “Please validate your address to continue” message to appear at checkout, even if the address had already been validated.

The issue occurs consistently on a default theme with only WooCommerce, PayPal Payments, and AvaTax plugins enabled.

A default checkout option like COD runs the actions in the correct order.

I also tested with a SkyVerge gateway plugin that has a similar off-site redirect to that of PayPal Payments, and the actions ran in the expected order there, allowing payment to process with a validated address.

To reproduce

  1. Install and activate PayPal Payments alongside SkyVerge's WooCommerce AvaTax plugin
  2. Navigate to the AvaTax plugin settings: WooCommerce > Settings > Tax > AvaTax
  3. Enable AvaTax address validation and set Require for Tax Calculation to true
  4. Add a product to your cart and proceed to checkout
  5. Enter a valid billing address, validate w/ AvaTax's "Validate Address" button
  6. Attempt to submit payment via PayPal Payments. After submitting payment information, the checkout page will return with a "Please validate your address to continue" error message

Expected behavior

For customers: When my address is validated at checkout, address validation should not prevent me from completing payment.

For AvaTax & other plugins: PayPal Payments should call WooCommerce checkout actions in the expected order, specifically woocommerce_checkout_order_processed should only run after woocommerce_after_checkout_validation

Environment:
Tested on:

  • WordPress version 5.8.1
  • WooCommerce version 5.7.0 and 5.8.0
  • WooCommerce PayPal Payments plugin version 1.5.1 and 1.6.1
  • Chrome version 94.0.4606.81
  • WooCommerce AvaTax version 1 .13.2

Additional details

A8C Ref: 4322337-zen
SV Ref: 179556

@Dinamiko Dinamiko changed the title Order of WooCommerce checkout actions causing incompatibility with AvaTax address validation Order of WooCommerce checkout actions causing incompatibility with AvaTax address validation (375) Oct 22, 2021
@Dinamiko Dinamiko added the bug Something isn't working label Oct 22, 2021
@Dinamiko
Copy link
Contributor

Hello @nikolas4175-godaddy,

I took a look but I can not reproduce following the current steps, also I've checked the order of execution and seems woocommerce_checkout_order_processed is executed after woocommerce_after_checkout_validation.

When you have time please let us know how can we reproduce it, maybe we are missing something here but seems working on latest release (1.6.1)
https://user-images.githubusercontent.com/456223/138459021-7000b500-6caa-4b61-af33-2ef04732db42.mp4

@nikolas4175-godaddy
Copy link
Author

nikolas4175-godaddy commented Oct 22, 2021

Hi @Dinamiko 👋 Thanks for taking a look!

It looks like I missed a key setting earlier, sorry about that! Could you please test with Require for Tax Calculation enabled in the AvaTax Address Validation settings as well? I believe that will produce the error.

I've also reviewed my logging of the order of execution and can clarify on that a bit. What I'm seeing is woocommerce_after_checkout_validation and then woocommerce_checkout_order_processed being called in that order when the customer is first sent to the PayPal payment page, but then woocommerce_after_checkout_validation is called again upon returning from the payment page, which seems to be triggering the error since our validation was already cleared in woocommerce_checkout_order_processed.

@nikolas4175-godaddy
Copy link
Author

Hey there!

Checking back in to let you know that this issue appears to be causing a conflict with another of our plugins, Local Pickup Plus, as well. Our plugin allows customers to select a location where they will pickup their order during checkout, and this location data is stored first as session data before being written to the WooCommerce order itself. That session data is verified and saved during woocommerce_after_checkout_validation, and again is cleared during woocommerce_checkout_order_processed.

Since PayPal Payments seems to be calling woocommerce_after_checkout_validation again after session data has been cleared during woocommerce_checkout_order_processed, this causes the now empty pickup data to override whatever selection the customer made at checkout.

So, as with the AvaTax conflict, it seems that the additional call to woocommerce_after_checkout_validation after session data has been cleared is causing some of our key checkout processes to fail.

Let me know if you have any questions on that or if I can help with any other details here 🙂

@Dinamiko
Copy link
Contributor

Hi @nikolas4175-godaddy,

Thanks for the detailed info! I´m able to reproduce it now, as you said it does call woocommerce_after_checkout_validation a second time while it should not do it.

We´re now investigating it, once I have more info I´ll let you know, thanks.

@Dinamiko
Copy link
Contributor

Dinamiko commented Oct 28, 2021

Hi @nikolas4175-godaddy,

Seems we have found a solution for fixing the validation problem, here is the PR with the related info: #341

When you have time would be great if you can give it a try to ensure the fix works on your side, I´m attaching the package with the fix here just in case:
PCP-327-woocommerce-paypal-payments.zip

@isabellainpsyde isabellainpsyde added this to the Next Version milestone Oct 28, 2021
@Dinamiko
Copy link
Contributor

Dinamiko commented Nov 4, 2021

Create a new issue after upcoming release to improve the validation when creating the PayPal order from checkout page, while we're expecting to see a reduction of support issues related to WC failed orders (we are now creating the WC order only after PayPal order is approved and WC checkout form is validated correctly) there is still room for improvement related to validation when creating the PayPal order.

@tzuk-godaddy
Copy link

Hi @Dinamiko, I'm stepping in as @nikolas4175-godaddy is taking some time off right now. I tested the pre-release you shared here and was able to process an order successfully! 🚀
I'll let the merchant know that this issue has been addressed. Do you have an approximate timeframe for when this fix will be deployed? Are we able to share the pre-release with the merchant in the meantime?
Thanks!

@Dinamiko
Copy link
Contributor

Dinamiko commented Nov 5, 2021

Hi @tzuk-godaddy,

That sounds great, thanks for checking it!

We are currently preparing the upcoming release so it should not take too long. Regarding sharing the pre-release package, feel free to do it, the more we test it the better :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants