Fix: set order status to refunded when a PayPal transaction is refunded

Commit c7a3fd2 changed the logic to check if the refund is a full refund to use the strict equal operator (`===`) in the following line:

25be9fc13c/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php (L295)

This change broke the comparison as `$order->get_total()` will return the value respecting the number of decimals after the decimal point set in the option `woocommerce_price_num_decimals` and `wc_format_decimal()`, when called without a second parameter, will not format the received value to use the same number of decimals set in `woocommerce_price_num_decimals`. To fix this issue, this commit passes `wc_get_price_decimals()` as the second parameter to `wc_format_decimal()`. This way both values will always have the same number of decimals and the comparison should work when handling a full refund.

Fixes #20551
This commit is contained in:
Rodrigo Primo 2018-06-19 10:07:52 -03:00
parent e0ccc64571
commit 9263a0b169
1 changed files with 1 additions and 1 deletions

View File

@ -292,7 +292,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
*/
protected function payment_status_refunded( $order, $posted ) {
// Only handle full refunds, not partial.
if ( $order->get_total() === wc_format_decimal( $posted['mc_gross'] * -1 ) ) {
if ( $order->get_total() === wc_format_decimal( $posted['mc_gross'] * -1, wc_get_price_decimals() ) ) {
/* translators: %s: payment status. */
$order->update_status( 'refunded', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), strtolower( $posted['payment_status'] ) ) );