PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 2.31.0 All 254 releases
give / src / Revenue / DonationHandler.php

DonationHandler.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Revenue/DonationHandler.php

43 lines 982 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Revenue;
4
5 use Give\Revenue\Repositories\Revenue;
6 use Give\ValueObjects\Money;
7
8 /**
9 * Class OnDonationHandler
10 * @package Give\Revenue
11 * @since 2.9.0
12 *
13 * use this class to insert revenue when new donation create.
14 */
15 class DonationHandler
16 {
17 /**
18 * Handle new donation.
19 *
20 * @since 4.0.0 - set campaign id
21 * @since 2.9.0
22 *
23 * @param int $donationId
24 *
25 */
26 public function handle($donationId)
27 {
28 $amount = give_donation_amount($donationId);
29 $currency = give_get_option('currency');
30 $formId = give_get_payment_form_id($donationId);
31 $campaign = give()->campaigns->getByFormId($formId);
32
33 $data = [
34 'donation_id' => $donationId,
35 'form_id' => $formId,
36 'amount' => Money::of($amount, $currency)->getMinorAmount(),
37 'campaign_id' => $campaign ? $campaign->id : null,
38 ];
39
40 give(Revenue::class)->insert($data);
41 }
42 }
43