The calculated payment gateway fee is not accurate; does NOT match the amount actually withheld by the payment gateway.
The formula in the “Calculate Fee” routine uses a simple formula (based on settings) to calculate the payment gateway fee and then adds that to the total. However, the payment gateway calculates their fee on the “New” order total (not the original amount). Therefore the actual payment gateway fee withheld is more than the amount calculated by the plugin.
We have modified, tested, and validated the formulae in the “Calculate Fee” routine that calculates the actual amount withheld by payment gateways.
The below version WORKS.
/**
* Calculate Fee.
*
* @return float
*/
/**
* Calculate Fee for Customer to pay ENTIRE gateway payment fee with fixed amount plus variable amount fees.
* Simple equation of Cart_subtotal * fee percent + fixed fee does NOT cover ENTIRE fee withheld by the payment gateway.
* WooCommerce calculates fee from amount charged to Customer Credit Cart, i.e. Order Total.
*/
public static function fee_value( $fee_details, $cart_obj ) {
extract( $fee_details ) ;
if ( ‘gateway’ == $type ) {
$cart_subtotal = ( ‘1’ == $percentage_type ) ? efw_get_wc_cart_subtotal( $cart_obj ) : efw_get_wc_cart_total( $cart_obj ) ;
} else {
$cart_subtotal = efw_get_wc_cart_subtotal( $cart_obj ) ;
}
if ( ! empty( $min_sub_total ) && empty( $max_sub_total ) ) {
if ( $cart_subtotal $max_sub_total ) {
return 0 ;
}
} elseif ( ! empty( $min_sub_total ) && ! empty( $max_sub_total ) ) {
if ( ! ( ( $cart_subtotal > $min_sub_total ) && ( $cart_subtotal $min_fee ) ? $percent_value : $min_fee ;
$fee_value = ( ( ( $cart_subtotal ) / ( 1 – ( $cart_sub_total / 100 ) ) ) – $cart_subtotal ) ;
} else {
$percent_value = ( ( $cart_sub_total / 100 ) * $cart_subtotal ) ;
$percent_value = ( $percent_value > $min_fee ) ? $percent_value : $min_fee ;
$fee_value = ( ( ( $cart_subtotal + $fixed_value ) / ( 1 – ( $cart_sub_total / 100 ) ) ) – $cart_subtotal ) ;
}
return $fee_value ;
Open
Last updated: January 31, 2023
0 comments
Log in to comment on this feature request.