mollie / WooCommerce

Official Mollie extension for WooCommerce
https://wordpress.org/plugins/mollie-payments-for-woocommerce/
Other
129 stars 52 forks source link

[PIWOO-422] TypeError merchant capture feature #882

Closed inpsyde-maticluznar closed 4 months ago

inpsyde-maticluznar commented 6 months ago

Handles: PIWOO-422

In the Webhook method, we have to check if the payment object is a payment. If it is not, we don't have to run it.

@mmaymo Maybe it would be better to remove the Payment type from this function https://github.com/mollie/WooCommerce/blob/develop/src/MerchantCapture/MerchantCaptureModule.php#L156 and check here what kind of object we received. What do you think?

mmaymo commented 6 months ago

It's true that the hook is only used by the merchant capture in our code now, so this would work.. but onWebhookAction the $payment object can be an order and we would then limit the use of that hook for other purposes (maybe some third party plugin could be using it and this could break them). The name of that variable leads to confusion, not only here.. we need to address that in the refactor. But I think it would be less prone to conflict if we remove the payment type in the merchant capture method, and if it's not what we want, then bail there.

inpsyde-maticluznar commented 6 months ago

It's true that the hook is only used by the merchant capture in our code now, so this would work.. but onWebhookAction the $payment object can be an order and we would then limit the use of that hook for other purposes (maybe some third party plugin could be using it and this could break them). The name of that variable leads to confusion, not only here.. we need to address that in the refactor. But I think it would be less prone to conflict if we remove the payment type in the merchant capture method, and if it's not what we want, then bail there.

Yes I agree. Thank you! I updated the code.