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 / Webhooks / Webhook.php

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

58 lines 1.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\Framework\PaymentGateways\Webhooks;
4
5 use Give\Framework\Exceptions\Primitives\Exception;
6 use Give\Framework\PaymentGateways\PaymentGateway;
7
8 /**
9 * @since 4.5.0
10 */
11 class Webhook
12 {
13 /**
14 * @since 4.5.0
15 *
16 * @var string $webhookNotificationsListener
17 */
18 private $webhookNotificationsListener = 'webhookNotificationsListener';
19
20 /**
21 * @since 4.5.0
22 *
23 * @var PaymentGateway $paymentGateway
24 */
25 private $paymentGateway;
26
27 /**
28 * @since 4.5.0
29 *
30 * @var WebhookEvents $webhookEvents
31 */
32 public $events;
33
34 public function __construct(PaymentGateway &$paymentGateway)
35 {
36 if ($paymentGateway->canListeningWebhookNotifications()) {
37 $paymentGateway->routeMethods[] = $this->webhookNotificationsListener;
38 }
39
40 $this->paymentGateway = &$paymentGateway;
41 $this->events = new WebhookEvents($paymentGateway::id());
42 }
43
44 /**
45 * @since 4.5.0
46 *
47 * @throws Exception
48 */
49 public function getNotificationUrl(array $args = []): string
50 {
51 if ( ! $this->paymentGateway->canListeningWebhookNotifications()) {
52 throw new Exception('Gateway does not support listening to webhook notifications.');
53 }
54
55 return $this->paymentGateway->generateGatewayRouteUrl($this->webhookNotificationsListener, $args);
56 }
57 }
58