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
← All changes | src/Revenue/DonationHandler.php +8 -22 2.30.04.16.9 View file →
@@ -16,8 +16,9 @@
16 16 {
17 17 /**
18 18 * Handle new donation.
19 19 *
20 + * @since 4.0.0 - set campaign id
20 21 * @since 2.9.0
21 22 *
22 23 * @param int $donationId
23 24 *
@@ -23,34 +24,19 @@
23 24 *
24 25 */
25 26 public function handle($donationId)
26 27 {
27 - /* @var Revenue $revenue */
28 - $revenue = give(Revenue::class);
29 -
30 - $revenue->insert($this->getData($donationId));
31 - }
32 -
33 - /**
34 - * Get revenue data.
35 - *
36 - * @since 2.9.0
37 - *
38 - * @param int $donationId
39 - *
40 - * @return array
41 - */
42 - public function getData($donationId)
43 - {
44 - /* @var Revenue $revenue */
45 28 $amount = give_donation_amount($donationId);
46 29 $currency = give_get_option('currency');
47 - $money = Money::of($amount, $currency);
48 30 $formId = give_get_payment_form_id($donationId);
31 + $campaign = give()->campaigns->getByFormId($formId);
49 32
50 - return [
33 + $data = [
51 34 'donation_id' => $donationId,
52 - 'form_id' => $formId,
53 - 'amount' => $money->getMinorAmount(),
35 + 'form_id' => $formId,
36 + 'amount' => Money::of($amount, $currency)->getMinorAmount(),
37 + 'campaign_id' => $campaign ? $campaign->id : null,
54 38 ];
39 +
40 + give(Revenue::class)->insert($data);
55 41 }
56 42 }