pronamic/wp-pronamic-pay-woocommerce

€ 0,00 refund triggered on deleting payments

rvdsteege opened this issue · 3 comments

It seems that deleting payments can trigger refunds of € 0,00:

Scherm­afbeelding 2022-11-24 om 14 26 22

This seems to be caused by operands of incompatible types (float vs string):

$wc_refunded_amount = (float) $order->get_meta( '_pronamic_amount_refunded', true );
$refunded_value = $refunded_amount->get_value();
if ( $wc_refunded_amount === $refunded_value ) {
return;
}

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 ) {

Discussed with @remcotolsma at Pronamic HQ and resolved in 2ed4a20.