PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.19.6
GiveWP – Donation Plugin and Fundraising Platform v2.19.6
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 2.31.1 All 253 releases
give / src / Donations / ServiceProvider.php
ServiceProvider.php
70 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Donations;
4
5 use Give\Donations\LegacyListeners\DispatchGiveInsertPayment;
6 use Give\Donations\LegacyListeners\DispatchGiveRecurringAddSubscriptionPaymentAndRecordPayment;
7 use Give\Donations\LegacyListeners\DispatchGiveUpdatePaymentStatus;
8 use Give\Donations\LegacyListeners\InsertSequentialId;
9 use Give\Donations\LegacyListeners\RemoveSequentialId;
10 use Give\Donations\LegacyListeners\UpdateDonorPaymentIds;
11 use Give\Donations\LegacyListeners\UpdateSequentialId;
12 use Give\Donations\Models\Donation;
13 use Give\Donations\Repositories\DonationRepository;
14 use Give\Helpers\Call;
15 use Give\Helpers\Hooks;
16 use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface;
17
18 class ServiceProvider implements ServiceProviderInterface
19 {
20 /**
21 * @inheritDoc
22 */
23 public function register()
24 {
25 give()->singleton('donations', DonationRepository::class);
26 }
27
28 /**
29 * @inheritDoc
30 */
31 public function boot()
32 {
33 $this->bootLegacyListeners();
34 }
35
36 /**
37 * Legacy Listeners
38 *
39 * @since 2.19.6
40 */
41 private function bootLegacyListeners()
42 {
43 add_action('give_donation_created', function (Donation $donation) {
44 Call::invoke(InsertSequentialId::class, $donation);
45 Call::invoke(DispatchGiveInsertPayment::class, $donation);
46 Call::invoke(UpdateDonorPaymentIds::class, $donation);
47
48 if ($donation->subscriptionId) {
49 Call::invoke(DispatchGiveRecurringAddSubscriptionPaymentAndRecordPayment::class, $donation);
50 }
51
52 /**
53 * @notice
54 * Anytime we call give_update_payment_status the donor purchase_value and purchase_count get affected.
55 * We are doing this in the gateway api and in many other places.
56 * The listener below matches the functionality but the count seems to be overwritten elsewhere.
57 * Leaving this commented out until resolved or needed.
58 */
59 //Call::invoke(UpdateDonorPurchaseValueAndCount::class, $donation);
60 });
61
62 add_action('give_donation_updated', function (Donation $donation) {
63 Call::invoke(DispatchGiveUpdatePaymentStatus::class, $donation);
64 Call::invoke(UpdateSequentialId::class, $donation);
65 });
66
67 Hooks::addAction('give_donation_deleted', RemoveSequentialId::class);
68 }
69 }
70