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 / Framework / PaymentGateways / CommandHandlers / SubscriptionProcessingHandler.php

SubscriptionProcessingHandler.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Framework/PaymentGateways/CommandHandlers/SubscriptionProcessingHandler.php

67 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\PaymentGateways\CommandHandlers;
4
5 use Exception;
6 use Give\Donations\Models\Donation;
7 use Give\Donations\ValueObjects\DonationStatus;
8 use Give\Framework\PaymentGateways\Commands\SubscriptionProcessing;
9 use Give\Subscriptions\Models\Subscription;
10 use Give\Subscriptions\ValueObjects\SubscriptionStatus;
11
12 /**
13 * @since 2.23.2
14 */
15 class SubscriptionProcessingHandler
16 {
17 /**
18 * @since 2.23.2
19 * @var SubscriptionProcessing
20 */
21 private $subscriptionComplete;
22 /**
23 * @since 2.23.2
24 * @var Subscription
25 */
26 private $subscription;
27 /**
28 * @since 2.23.2
29 * @var Donation
30 */
31 private $donation;
32
33 /**
34 * @since 2.23.2
35 */
36 public function __construct(
37 SubscriptionProcessing $subscriptionComplete,
38 Subscription $subscription,
39 Donation $donation
40 ) {
41 $this->subscriptionComplete = $subscriptionComplete;
42 $this->subscription = $subscription;
43 $this->donation = $donation;
44 }
45
46 /**
47 * @since 2.23.2
48 * @return void
49 * @throws Exception
50 */
51 public function __invoke()
52 {
53 $this->donation->status = DonationStatus::PROCESSING();
54 $this->subscription->status = SubscriptionStatus::PENDING();
55 $this->subscription->gatewaySubscriptionId = $this->subscriptionComplete->gatewaySubscriptionId;
56
57 // Only save no-empty gateway transaction ids.
58 if ($this->subscriptionComplete->gatewayTransactionId) {
59 $this->donation->gatewayTransactionId = $this->subscriptionComplete->gatewayTransactionId;
60 $this->subscription->transactionId = $this->subscriptionComplete->gatewayTransactionId;
61 }
62
63 $this->donation->save();
64 $this->subscription->save();
65 }
66 }
67