PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / TestData / Addons / FeeRecovery / FeeRecovery.php

FeeRecovery.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/TestData/Addons/FeeRecovery/FeeRecovery.php

48 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\TestData\Addons\FeeRecovery;
4
5 use Exception;
6 use Give\TestData\Framework\MetaRepository;
7
8 class FeeRecovery
9 {
10 /**
11 * @param int $donationID
12 * @param array $donation
13 * @param array $params
14 */
15 public function addFee($donationID, $donation, $params)
16 {
17 global $wpdb;
18
19 // Fee recovery is checked?
20 if (
21 ! isset($params['donation_cover_fees'])
22 || ! filter_var($params['donation_cover_fees'], FILTER_VALIDATE_BOOLEAN)
23 ) {
24 return;
25 }
26
27 // Start DB transaction
28 $wpdb->query('START TRANSACTION');
29
30 try {
31 // Update donation meta
32 $metaRepository = new MetaRepository('give_donationmeta', 'donation_id');
33 $metaRepository->persist(
34 $donationID,
35 [
36 '_give_fee_donation_amount' => $donation['payment_total'],
37 '_give_fee_amount' => give_get_option('give_fee_percentage', 2.90),
38 ]
39 );
40
41 $wpdb->query('COMMIT');
42 } catch (Exception $e) {
43 $wpdb->query('ROLLBACK');
44 }
45 }
46
47 }
48