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
88 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->get_param( 'start' ) ); |
| 20 | $end = date_create( $request->get_param( 'end' ) ); |
| 21 | |
| 22 | // Setup args for give_count_payments |
| 23 | $args = array( |
| 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 | $completed = property_exists( $payments, 'give_subscription' ) ? $payments->publish + $payments->give_subscription : $payments->publish; |
| 31 | |
| 32 | return [ |
| 33 | 'labels' => [ |
| 34 | 'Completed', |
| 35 | 'Pending', |
| 36 | 'Refunded', |
| 37 | 'Abandoned', |
| 38 | 'Cancelled', |
| 39 | 'Failed', |
| 40 | ], |
| 41 | 'datasets' => [ |
| 42 | [ |
| 43 | 'data' => [ |
| 44 | $completed, |
| 45 | $payments->pending, |
| 46 | $payments->refunded, |
| 47 | $payments->abandoned, |
| 48 | $payments->cancelled, |
| 49 | $payments->failed, |
| 50 | ], |
| 51 | 'tooltips' => [ |
| 52 | [ |
| 53 | 'title' => $completed . ' ' . __( 'Payments', 'give' ), |
| 54 | 'body' => __( 'Completed', 'give' ), |
| 55 | 'footer' => '', |
| 56 | ], |
| 57 | [ |
| 58 | 'title' => $payments->pending . ' ' . __( 'Payments', 'give' ), |
| 59 | 'body' => __( 'Pending', 'give' ), |
| 60 | 'footer' => '', |
| 61 | ], |
| 62 | [ |
| 63 | 'title' => $payments->refunded . ' ' . __( 'Payments', 'give' ), |
| 64 | 'body' => __( 'Refunded', 'give' ), |
| 65 | 'footer' => '', |
| 66 | ], |
| 67 | [ |
| 68 | 'title' => $payments->abandoned . ' ' . __( 'Payments', 'give' ), |
| 69 | 'body' => __( 'Abandoned', 'give' ), |
| 70 | 'footer' => '', |
| 71 | ], |
| 72 | [ |
| 73 | 'title' => $payments->cancelled . ' ' . __( 'Payments', 'give' ), |
| 74 | 'body' => __( 'Cancelled', 'give' ), |
| 75 | 'footer' => '', |
| 76 | ], |
| 77 | [ |
| 78 | 'title' => $payments->failed . ' ' . __( 'Payments', 'give' ), |
| 79 | 'body' => __( 'Failed', 'give' ), |
| 80 | 'footer' => '', |
| 81 | ], |
| 82 | ], |
| 83 | ], |
| 84 | ], |
| 85 | ]; |
| 86 | } |
| 87 | } |
| 88 |