# give/4.16.9/src/TestData/Addons/FeeRecovery/FeeRecovery.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.16.9. 48 lines.

- Page: https://pluginprobe.com/plugins/give/4.16.9/code/src/TestData/Addons/FeeRecovery/FeeRecovery.php
- Raw: https://pluginprobe.com/plugins/give/4.16.9/raw/src/TestData/Addons/FeeRecovery/FeeRecovery.php
- Modified: 2021-11-23T23:55:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.16.9/code/src/TestData/Addons/FeeRecovery/FeeRecovery.php#L10-L20`.

```php
<?php

namespace Give\TestData\Addons\FeeRecovery;

use Exception;
use Give\TestData\Framework\MetaRepository;

class FeeRecovery
{
    /**
     * @param int $donationID
     * @param array $donation
     * @param array $params
     */
    public function addFee($donationID, $donation, $params)
    {
        global $wpdb;

        // Fee recovery is checked?
        if (
            ! isset($params['donation_cover_fees'])
            || ! filter_var($params['donation_cover_fees'], FILTER_VALIDATE_BOOLEAN)
        ) {
            return;
        }

        // Start DB transaction
        $wpdb->query('START TRANSACTION');

        try {
            // Update donation meta
            $metaRepository = new MetaRepository('give_donationmeta', 'donation_id');
            $metaRepository->persist(
                $donationID,
                [
                    '_give_fee_donation_amount' => $donation['payment_total'],
                    '_give_fee_amount' => give_get_option('give_fee_percentage', 2.90),
                ]
            );

            $wpdb->query('COMMIT');
        } catch (Exception $e) {
            $wpdb->query('ROLLBACK');
        }
    }

}

```
