payments.php
73 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Gateways\Table_Views; |
| 5 | |
| 6 | use Jet_Form_Builder\Admin\Table_Views\Columns\Record_Id_Column_Advanced; |
| 7 | use Jet_Form_Builder\Admin\Table_Views\View_Advanced_Base; |
| 8 | use Jet_Form_Builder\Exceptions\Query_Builder_Exception; |
| 9 | use Jet_Form_Builder\Gateways\Db_Models\Payment_To_Payer_Shipping_Model; |
| 10 | use Jet_Form_Builder\Gateways\Db_Models\Payment_To_Record; |
| 11 | use Jet_Form_Builder\Gateways\Query_Views\Payment_Count_View; |
| 12 | use Jet_Form_Builder\Gateways\Query_Views\Payment_View; |
| 13 | use Jet_Form_Builder\Gateways\Paypal\Rest_Endpoints; |
| 14 | use Jet_Form_Builder\Admin\Table_Views\Columns\Created_At_Column; |
| 15 | use Jet_Form_Builder\Gateways\Rest_Api\Receive_Payments; |
| 16 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Gross_Column; |
| 17 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Header_Actions_Column; |
| 18 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Payer_Column; |
| 19 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Payment_Status_Column; |
| 20 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Payment_Type_Column; |
| 21 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Row_Actions_Column; |
| 22 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Transaction_Column; |
| 23 | |
| 24 | class Payments extends View_Advanced_Base { |
| 25 | |
| 26 | public function get_raw_list( array $args ): array { |
| 27 | try { |
| 28 | return ( new Payment_View() ) |
| 29 | ->set_table_args( $args ) |
| 30 | ->query() |
| 31 | ->query_all(); |
| 32 | } catch ( Query_Builder_Exception $exception ) { |
| 33 | return array(); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | public function get_dependencies(): array { |
| 38 | return array( |
| 39 | new Payment_To_Payer_Shipping_Model(), |
| 40 | new Payment_To_Record(), |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | public function get_rest_url(): string { |
| 45 | return Receive_Payments::rest_url(); |
| 46 | } |
| 47 | |
| 48 | public function get_rest_methods(): string { |
| 49 | return Receive_Payments::get_methods(); |
| 50 | } |
| 51 | |
| 52 | public function get_total(): int { |
| 53 | return Payment_Count_View::count(); |
| 54 | } |
| 55 | |
| 56 | public function get_empty_message(): string { |
| 57 | return __( 'No payments found.', 'jet-form-builder' ); |
| 58 | } |
| 59 | |
| 60 | public function get_columns(): array { |
| 61 | return array( |
| 62 | 'type' => new Payment_Type_Column(), |
| 63 | 'date' => new Created_At_Column(), |
| 64 | 'payment_status' => new Payment_Status_Column(), |
| 65 | 'gross' => new Gross_Column(), |
| 66 | 'payer' => new Payer_Column(), |
| 67 | 'id' => new Record_Id_Column_Advanced(), |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | |
| 73 |