Closed inpsyde-maticluznar closed 4 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.
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.
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?