diff --git a/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php b/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php index c79166aa3e4..9b9bc4cf88d 100644 --- a/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php +++ b/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php @@ -181,6 +181,12 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response { if ( 'completed' === $posted['payment_status'] ) { $this->payment_complete( $order, ( ! empty( $posted['txn_id'] ) ? wc_clean( $posted['txn_id'] ) : '' ), __( 'IPN payment completed', 'woocommerce' ) ); + + if ( isset( $posted['mc_fee'] ) ) { + // log paypal transaction fee + update_post_meta( $order->id, '_paypal_standard_txn_fee', $posted['mc_fee'] ); + } + } else { $this->payment_on_hold( $order, sprintf( __( 'Payment pending: %s', 'woocommerce' ), $posted['pending_reason'] ) ); } diff --git a/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php b/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php index 0580dceb86c..4e2093b294b 100644 --- a/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php +++ b/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php @@ -75,6 +75,11 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response { $this->payment_on_hold( $order, sprintf( __( 'Validation error: PayPal amounts do not match (amt %s).', 'woocommerce' ), $amount ) ); } else { $this->payment_complete( $order, $transaction, __( 'PDT payment completed', 'woocommerce' ) ); + + if ( isset( $_REQUEST['mc_fee'] ) ) { + // log paypal transaction fee + update_post_meta( $order->id, '_paypal_standard_txn_fee', $_REQUEST['mc_fee'] ); + } } } }