PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.1.0
GiveWP – Donation Plugin and Fundraising Platform v4.1.0
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 / API / Endpoints / Reports / PaymentStatuses.php
PaymentStatuses.php
119 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Reports base endpoint
5 *
6 * @package Give
7 */
8
9 namespace Give\API\Endpoints\Reports;
10
11 class PaymentStatuses extends Endpoint
12 {
13
14 public function __construct()
15 {
16 $this->endpoint = 'payment-statuses';
17 }
18
19 public function getReport($request)
20 {
21 $start = date_create($request->get_param('start'));
22 $end = date_create($request->get_param('end'));
23
24 $gatewayObjects = give_get_payment_gateways();
25 $paymentModeKeyCompare = '!=';
26
27 if ($this->testMode === false) {
28 unset($gatewayObjects['manual']);
29 $paymentModeKeyCompare = '=';
30 }
31
32 $gateway = array_keys($gatewayObjects);
33
34 $args = [
35 'number' => -1,
36 'paged' => 1,
37 'orderby' => 'date',
38 'order' => 'DESC',
39 'start_date' => $request->get_param('start'),
40 'end_date' => $request->get_param('end'),
41 'gateway' => $gateway,
42 'meta_query' => [
43 [
44 'key' => '_give_payment_currency',
45 'value' => $this->currency,
46 'compare' => '=',
47 ],
48 [
49 'key' => '_give_payment_mode',
50 'value' => 'live',
51 'compare' => $paymentModeKeyCompare,
52 ],
53 ],
54 ];
55
56 // Use give_count_payments logic to get payments
57 $payments = give_count_payments($args);
58 $completed = property_exists(
59 $payments,
60 'give_subscription'
61 ) ? $payments->publish + $payments->give_subscription : $payments->publish;
62
63 return [
64 'labels' => [
65 'Completed',
66 'Pending',
67 'Refunded',
68 'Abandoned',
69 'Cancelled',
70 'Failed',
71 ],
72 'datasets' => [
73 [
74 'data' => [
75 $completed,
76 $payments->pending,
77 $payments->refunded,
78 $payments->abandoned,
79 $payments->cancelled,
80 $payments->failed,
81 ],
82 'tooltips' => [
83 [
84 'title' => $completed . ' ' . __('Payments', 'give'),
85 'body' => __('Completed', 'give'),
86 'footer' => '',
87 ],
88 [
89 'title' => $payments->pending . ' ' . __('Payments', 'give'),
90 'body' => __('Pending', 'give'),
91 'footer' => '',
92 ],
93 [
94 'title' => $payments->refunded . ' ' . __('Payments', 'give'),
95 'body' => __('Refunded', 'give'),
96 'footer' => '',
97 ],
98 [
99 'title' => $payments->abandoned . ' ' . __('Payments', 'give'),
100 'body' => __('Abandoned', 'give'),
101 'footer' => '',
102 ],
103 [
104 'title' => $payments->cancelled . ' ' . __('Payments', 'give'),
105 'body' => __('Cancelled', 'give'),
106 'footer' => '',
107 ],
108 [
109 'title' => $payments->failed . ' ' . __('Payments', 'give'),
110 'body' => __('Failed', 'give'),
111 'footer' => '',
112 ],
113 ],
114 ],
115 ],
116 ];
117 }
118 }
119