woocommerce / woocommerce-square

Square POS and Payments Integration
https://woo.com/products/square
Other
10 stars 4 forks source link

Failed subscription renewal orders when using Avatax #16

Open shevene opened 1 year ago

shevene commented 1 year ago

Describe the bug

Subscription renewal orders fail with a critical error when using Square and the latest versions of Avatax and WooCommerce.

To reproduce

  1. Purchase a subscription using Square with the latest version of Avatax installed.
  2. Try processing a subscription renewal. You'll see that it fails with a critical error.
Fatal Error logs ``` 2023-02-19T00:06:26+00:00 CRITICAL Uncaught Error: Call to a member function getUid() on null in /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Gateway/API/Requests/Orders.php:300 Stack trace: #0 /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Gateway/API/Requests/Orders.php(210): WooCommerce\Square\Gateway\API\Requests\Orders->apply_taxes(Array, Object(WC_Order_Item_Product)) woocommerce/woocommerce-square-private#1 /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Gateway/API/Requests/Orders.php(71): WooCommerce\Square\Gateway\API\Requests\Orders->get_api_line_items(Object(Automattic\WooCommerce\Admin\Overrides\Order), Array, Array) woocommerce/woocommerce-square-private#2 /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Gateway/API.php(328): WooCommerce\Square\Gateway\API\Requests\Orders->set_create_order_data('LJ1SM9VTTBB8K', Object(Automattic\WooCommerce\Admin\Overrides\Order)) woocommerce/woocommerce-square-private#3 /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Gateway.php(343): WooCommerce\Square\Gateway\API->create_order('LJ1SM9VTTBB8K', Object(Automattic\WooCommerce\Admin\Overrides\Order)) woocommerce/woocommerce-square-private#4 /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway_Direct.php(298): WooCommerce\Square\Gateway->do_transaction(Object(Automattic\WooCommerce\Admin\Overrides\Order)) woocommerce/woocommerce-square-private#5 /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Integrations/Payment_Gateway_Integration_Subscriptions.php(230): WooCommerce\Square\Framework\PaymentGateway\Payment_Gateway_Direct->process_payment(1624) woocommerce/woocommerce-square-private#6 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(308): WooCommerce\Square\Framework\PaymentGateway\Integrations\Payment_Gateway_Integration_Subscriptions->process_renewal_payment('162.38', Object(Automattic\WooCommerce\Admin\Overrides\Order)) woocommerce/woocommerce-square-private#7 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) woocommerce/woocommerce-square-private#8 /wordpress/core/6.1.1/wp-includes/plugin.php(517): WP_Hook->do_action(Array) woocommerce/woocommerce-square-private#9 /srv/htdocs/wp-content/plugins/woocommerce-subscriptions/includes/gateways/class-wc-subscriptions-payment-gateways.php(97): do_action('woocommerce_sch...', '162.38', Object(Automattic\WooCommerce\Admin\Overrides\Order)) woocommerce/woocommerce-square-private#10 /srv/htdocs/wp-content/plugins/woocommerce-subscriptions/includes/gateways/class-wc-subscriptions-payment-gateways.php(81): WC_Subscriptions_Payment_Gateways::trigger_gateway_renewal_payment_hook(Object(Automattic\WooCommerce\Admin\Overrides\Order)) woocommerce/woocommerce-square-private#11 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(308): WC_Subscriptions_Payment_Gateways::gateway_scheduled_subscription_payment(1589) woocommerce/woocommerce-square-private#12 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) woocommerce/woocommerce-square-private#13 /wordpress/core/6.1.1/wp-includes/plugin.php(565): WP_Hook->do_action(Array) woocommerce/woocommerce-square-private#14 /srv/htdocs/wp-content/plugins/woocommerce/packages/action-scheduler/classes/actions/ActionScheduler_Action.php(43): do_action_ref_array('woocommerce_sch...', Array) woocommerce/woocommerce-square-private#15 /srv/htdocs/wp-content/plugins/woocommerce/packages/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php(65): ActionScheduler_Action->execute() woocommerce/woocommerce-square-private#16 /srv/htdocs/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_QueueRunner.php(166): ActionScheduler_Abstract_QueueRunner->process_action(16644, 'WP Cron') woocommerce/woocommerce-square-private#17 /srv/htdocs/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_QueueRunner.php(136): ActionScheduler_QueueRunner->do_batch(25, 'WP Cron') woocommerce/woocommerce-square-private#18 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(308): ActionScheduler_QueueRunner->run('WP Cron') woocommerce/woocommerce-square-private#19 /wordpress/core/6.1.1/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) woocommerce/woocommerce-square-private#20 /wordpress/core/6.1.1/wp-includes/plugin.php(565): WP_Hook->do_action(Array) woocommerce/woocommerce-square-private#21 /wordpress/core/6.1.1/wp-cron.php(188): do_action_ref_array('action_schedule...', Array) woocommerce/woocommerce-square-private#22 {main} thrown in /srv/htdocs/wp-content/plugins/woocommerce-square/includes/Gateway/API/Requests/Orders.php on line 300 ```

Expected behavior

Subscription renewals should process when using the latest versions of Avatax, Square and WooCommerce.

Environment:

Additional details

Workaround: To resolve the issue, downgrade to WooCommerce 7.3.0 and Avatax 1.17.0.

5958400-zen

brucealdridge commented 1 year ago

also reported in https://github.com/woocommerce/woocommerce-blocks/issues/8473

shevene commented 1 year ago

+1 5975082-zen

opr commented 1 year ago

Hey @brucealdridge I don't think this is the exact same issue as https://github.com/woocommerce/woocommerce-blocks/issues/8473 due to the error being slightly different - the error in https://github.com/woocommerce/woocommerce-blocks/issues/8473 is caused by our callback for the woocommerce_customer_taxable_address filter expecting a session to be set up, but when renewing orders, it is not.

Just letting you know in case this affects how you approach and test this problem, cheers.

brucealdridge commented 1 year ago

I don't think this is the exact same issue as https://github.com/woocommerce/woocommerce-blocks/issues/8473

You're correct, there seems to be something there that is related. Not sure what it is. The proposed PR fix that we have for this issue solves the issue with WC Square and instead triggers the error in WC Blocks.

opr commented 1 year ago

Glad you fixed your issue! But I think the one in Blocks now is definitely the woocommerce_customer_taxable_address hook trying to get a session that doesn't exist. This is something we'll need to fix on our end. The issue has been given high priority.

shevene commented 1 year ago

5998972-zen

haszari commented 1 year ago

@brucealdridge can you update this issue with the latest info? As I understand it this issue is upstream (WC blocks/core) and we're no longer planning a fix in Square. Can you clarify & link to the primary issue?

shevene commented 1 year ago

6003351-zen

brucealdridge commented 1 year ago

As I understand it this issue is upstream (WC blocks/core) and we're no longer planning a fix in Square. Can you clarify & link to the primary issue?

The bug was upstream in both WC Blocks and in WC AvaTax. Fix was pushed out in WC 7.4.1 and there will be a new release of WC Avatax soon: p1677681493796439/1677255092.761729-slack-C02MLCP85LP.

Based on this I'm going to close this issue, if there are additional occurrences with WC 7.4.1+ and WC Avatax 2.2.0+ please re-open.

WillBrubaker commented 11 months ago

Re-opening because we have 7236530-zen using:

WooCommerce Square: by WooCommerce – 4.3.0 Woo Subscriptions: by WooCommerce – 5.6.0 WooCommerce: by Automattic – 8.2.1 Avalara AvaTax: by Avalara – 2.6.1 WC Blocks Version: ✔ 11.1.2

scheduled action 116863 (subscription payment) failed to finish processing due to the following exception: Call to a member function getUid() on null
jeffpaul commented 11 months ago

@brucealdridge @WillBrubaker are we still considering this an upstream issue?

WillBrubaker commented 11 months ago

My understanding is that upstream things have been fixed ¯_(ツ)_/¯

I've asked this user for an error log/stack trace.