AverageDonation.php
6 years ago
DonationsVsIncome.php
6 years ago
Endpoint.php
6 years ago
FormPerformance.php
6 years ago
Income.php
6 years ago
IncomeBreakdown.php
6 years ago
PaymentMethods.php
6 years ago
PaymentStatuses.php
6 years ago
RecentDonations.php
6 years ago
TopDonors.php
6 years ago
TotalDonors.php
6 years ago
TotalIncome.php
6 years ago
TotalRefunds.php
6 years ago
PaymentStatuses.php
94 lines
| 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 | public function __construct() { |
| 14 | $this->endpoint = 'payment-statuses'; |
| 15 | } |
| 16 | |
| 17 | public function get_report( $request ) { |
| 18 | |
| 19 | $start = date_create( $request['start'] ); |
| 20 | $end = date_create( $request['end'] ); |
| 21 | |
| 22 | // Setup args for give_count_payments |
| 23 | $args = [ |
| 24 | 'start-date' => $start->format( 'Y-m-d H:i:s' ), |
| 25 | 'end-date' => $end->format( 'Y-m-d H:i:s' ), |
| 26 | ]; |
| 27 | |
| 28 | // Use give_count_payments logic to get payments |
| 29 | $payments = give_count_payments( $args ); |
| 30 | |
| 31 | $status = $this->get_give_status(); |
| 32 | |
| 33 | return new \WP_REST_Response( |
| 34 | [ |
| 35 | 'status' => $status, |
| 36 | 'data' => [ |
| 37 | 'labels' => [ |
| 38 | 'Completed', |
| 39 | 'Pending', |
| 40 | 'Refunded', |
| 41 | 'Abandoned', |
| 42 | 'Cancelled', |
| 43 | 'Failed', |
| 44 | ], |
| 45 | 'datasets' => [ |
| 46 | [ |
| 47 | 'data' => [ |
| 48 | $payments->publish + $payments->give_subscription, |
| 49 | $payments->pending, |
| 50 | $payments->refunded, |
| 51 | $payments->abandoned, |
| 52 | $payments->cancelled, |
| 53 | $payments->failed, |
| 54 | ], |
| 55 | 'tooltips' => [ |
| 56 | [ |
| 57 | 'title' => $payments->publish + $payments->give_subscription . ' ' . __( 'Payments', 'give' ), |
| 58 | 'body' => __( 'Completed', 'give' ), |
| 59 | 'footer' => '', |
| 60 | ], |
| 61 | [ |
| 62 | 'title' => $payments->pending . ' ' . __( 'Payments', 'give' ), |
| 63 | 'body' => __( 'Pending', 'give' ), |
| 64 | 'footer' => '', |
| 65 | ], |
| 66 | [ |
| 67 | 'title' => $payments->refunded . ' ' . __( 'Payments', 'give' ), |
| 68 | 'body' => __( 'Refunded', 'give' ), |
| 69 | 'footer' => '', |
| 70 | ], |
| 71 | [ |
| 72 | 'title' => $payments->abandoned . ' ' . __( 'Payments', 'give' ), |
| 73 | 'body' => __( 'Abandoned', 'give' ), |
| 74 | 'footer' => '', |
| 75 | ], |
| 76 | [ |
| 77 | 'title' => $payments->cancelled . ' ' . __( 'Payments', 'give' ), |
| 78 | 'body' => __( 'Cancelled', 'give' ), |
| 79 | 'footer' => '', |
| 80 | ], |
| 81 | [ |
| 82 | 'title' => $payments->failed . ' ' . __( 'Payments', 'give' ), |
| 83 | 'body' => __( 'Failed', 'give' ), |
| 84 | 'footer' => '', |
| 85 | ], |
| 86 | ], |
| 87 | ], |
| 88 | ], |
| 89 | ], |
| 90 | ] |
| 91 | ); |
| 92 | } |
| 93 | } |
| 94 |