Home / eCommerce / Donation Fee Calculation
Duplicate Snippet

Embed Snippet on Your Site

Donation Fee Calculation

Code Preview
php
<?php
/**
 * 2. Calculate the exact Stripe Fee (2.9% + .30) if "Yes" is selected
 */
add_filter( 'charitable_get_donation_amount', function( $amount, $data ) {
    if ( isset( $data['cover_fee_choice'] ) && 'yes' === $data['cover_fee_choice'] ) {
        
        // Reverse math formula: (Amount + Fixed Fee) / (1 - Percentage)
        
        $amount = ( $amount + 0.30 ) / ( 1 - 0.029 );
        
        $amount = round( $amount, 2 );
    }
    return $amount;
}, 10, 2 );

Comments

Add a Comment