• Resolved nikhilprasad25

    (@nikhilprasad25)


    I am using the “Donation Platform for WooCommerce: Fundraising & Donation Management” plugin on my WordPress site and have encountered an issue when trying to configure the transaction fee recovery feature.

    According to my bank, the transaction fee is 4%. However, when I enter 4 in the percentage transaction cost field, the site returns the following error:

    Error: {“readyState”:4,”responseText”:”{\”code\”:\”internal_server_error\”,\”message\”:\”<p>There has been a critical error on this website.<\\/p><p><a href=\\\”https:\\/\\/ww.wp.xz.cn\\/documentation\\/article\\/faq-troubleshooting\\/\\\”>Learn more about troubleshooting WordPress.<\\/a><\\/p>\”,\”data\”:{\”status\”:500},\”additional_errors\”:[]}”,”responseJSON”:{“code”:”internal_server_error”,”message”:”<p>There has been a critical error on this website.</p><p><a href=\”https://ww.wp.xz.cn/documentation/article/faq-troubleshooting/\”>Learn more about troubleshooting WordPress.</a></p>”,”data”:{“status”:500},”additional_errors”:[]},”status”:500,”statusText”:”error”}

    Interestingly, the fee recovery feature works perfectly when I set the percentage to 5%. This leads me to believe there may be an issue with how the plugin handles the 4% value.

    Could you please help me understand why this is happening and how I can successfully configure the fee to 4%?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jonas

    (@flinnn)

    Hi nikhilprasad25,

    thanks for reaching out.
    This error sound strange. Could you please check the PHP error log to better help me debug the issue? https://www.wc-donation.com/documentation/troubleshooting/how-to-access-the-php-error-log/

    Best,
    Jonas

    Thread Starter nikhilprasad25

    (@nikhilprasad25)

    Hi Jonas,
    The issue that I am encountering is, When the transaction fee (set at 4%) is added to the donation amount, the resulting value sometimes becomes excessively large—up to 51 digits in certain cases.

    This creates a compatibility issue with the payment gateway we’re using (MasterCard plugin), as it only accepts values up to 15 digits. When the total amount exceeds this limit, the payment cannot be processed.

    To resolve this, we need a way to round off the total amount (donation + fee) to ensure it does not exceed 15 digits before being passed to the payment gateway. Could you guide us on how to address this issue, or if there’s an update or workaround available in the plugin?

    This is the error the payment plugin is showing when donation amount is $30
    INVALID_REQUEST: Value ‘31.1999999…5732421875’ is invalid. Length is 51 characters, but must be less than 15.

    Looking forward to your response.

    Regards,
    Nikhil

    Plugin Author Jonas

    (@flinnn)

    Hi,

    Thanks for your reply. You can use the following filter to round the fee:

    // Define a filter to round the fee amount
    function round_fee_amount($fee, $payment_method, $cart) {
    // Round the fee to 2 decimal places (adjust as needed)
    return round($fee, 2);
    }

    // Add the filter to 'wcdp_fee_amount'
    add_filter('wcdp_fee_amount', 'round_fee_amount', 10, 3);

    Best, Jonas

    Thread Starter nikhilprasad25

    (@nikhilprasad25)

    Hi Jonas,

    Thank you for your response.

    I have added the provided function and filter, but unfortunately, the issue persists. I wanted to confirm if I placed the code in the correct location. Currently, I’ve added it to the functions.php file of my active theme. Should this code be added to one of the plugin files instead? if yes, please let me know the name of the file.

    Your guidance on this would be greatly appreciated.

    Regards,
    Nikhil

    Plugin Author Jonas

    (@flinnn)

    Hi Nikhil,

    could you please try adding an error_log(‘XYZ’) to the filter so we can confirm that it’s executing the code? I generally recommend to use the free Code Snippets plugin: https://www.wc-donation.com/documentation/integrations/how-to-add-custom-code-to-your-page-using-the-code-snippets-plugin/

    Best,
    Jonas

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Recovery fee’ is closed to new replies.