€ 0,00 refund triggered on deleting payments
rvdsteege opened this issue · 3 comments
It seems that deleting payments can trigger refunds of € 0,00:
This seems to be caused by operands of incompatible types (float
vs string
):
wp-pronamic-pay-woocommerce/src/Extension.php
Lines 762 to 769 in 64fe6c9
Internal Help Scout ticket: https://secure.helpscout.net/conversation/2077581202/24843/
@remcotolsma I propose the below change, but find it a bit strange to first cast the meta to float
and then to string
— only to end up with string 0
instead of an empty string if there is no _pronamic_amount_refunded
order meta. Any other ideas? Money
and Number
classes do not have a to_float()
method, otherwise we could maybe use that?
if ( (string) $wc_refunded_amount === $refunded_value ) {
Should we introduce a equals
method in the Number
and/or Money
class?
https://github.com/pronamic/wp-number/blob/c26538f223ae4326e8758679ed7372020d15b1d1/src/Number.php
A bit like:
https://github.com/moneyphp/money/blob/43580b8a94142ae5db9e4c86c6ecaabea66f27c9/src/Money.php#L109-L127
And/or we should not create a refund if $amount_difference
is zero?
https://github.com/pronamic/wp-number/blob/c26538f223ae4326e8758679ed7372020d15b1d1/src/Number.php#L186-L196
Discussed with @remcotolsma at Pronamic HQ and resolved in 2ed4a20.