actions
3 years ago
columns
3 years ago
payer-box.php
3 years ago
payer-shipping-box.php
3 years ago
payment-details-box.php
3 years ago
payment-info-for-record.php
3 years ago
payment-details-box.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Gateways\Meta_Boxes; |
| 5 | |
| 6 | use Jet_Form_Builder\Admin\Exceptions\Not_Found_Page_Exception; |
| 7 | use Jet_Form_Builder\Admin\Single_Pages\Meta_Boxes\Base_List_Box; |
| 8 | use Jet_Form_Builder\Admin\Table_Views\Columns\Created_At_Column; |
| 9 | use Jet_Form_Builder\Admin\Table_Views\Columns\Updated_At_Column; |
| 10 | use Jet_Form_Builder\Exceptions\Query_Builder_Exception; |
| 11 | use Jet_Form_Builder\Gateways\Meta_Boxes\Actions\Delete_Payment_Action; |
| 12 | use Jet_Form_Builder\Gateways\Meta_Boxes\Columns\Gateway_Type_Column; |
| 13 | use Jet_Form_Builder\Gateways\Meta_Boxes\Columns\Payment_Amount_Column; |
| 14 | use Jet_Form_Builder\Gateways\Meta_Boxes\Columns\Payment_Currency_Column; |
| 15 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Transaction_Column; |
| 16 | use Jet_Form_Builder\Gateways\Pages\Single_Payment_Page; |
| 17 | use Jet_Form_Builder\Gateways\Query_Views\Payment_View; |
| 18 | use Jet_Form_Builder\Gateways\Rest_Api\Receive_Payment; |
| 19 | use Jet_Form_Builder\Gateways\Table_Views\Columns\Payment_Status_Column; |
| 20 | |
| 21 | class Payment_Details_Box extends Base_List_Box { |
| 22 | |
| 23 | public function get_title(): string { |
| 24 | return __( 'Payment Details', 'jet-form-builder' ); |
| 25 | } |
| 26 | |
| 27 | public function get_columns(): array { |
| 28 | return array( |
| 29 | 'amount' => new Payment_Amount_Column(), |
| 30 | 'code' => new Payment_Currency_Column(), |
| 31 | 'gateway' => new Gateway_Type_Column(), |
| 32 | 'status' => new Payment_Status_Column(), |
| 33 | 'transaction' => new Transaction_Column(), |
| 34 | 'created_at' => new Created_At_Column(), |
| 35 | 'updated_at' => new Updated_At_Column(), |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | public function get_actions(): array { |
| 40 | if ( ! is_a( jet_fb_current_page(), Single_Payment_Page::class ) ) { |
| 41 | return array(); |
| 42 | } |
| 43 | |
| 44 | return array( |
| 45 | new Delete_Payment_Action(), |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | public function get_rest_url(): string { |
| 50 | return Receive_Payment::dynamic_rest_url( |
| 51 | array( 'id' => $this->get_id() ) |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | public function get_rest_methods(): string { |
| 56 | return Receive_Payment::get_methods(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @return array |
| 61 | * @throws Not_Found_Page_Exception |
| 62 | */ |
| 63 | public function get_list(): array { |
| 64 | try { |
| 65 | return Payment_View::findById( $this->get_id() ); |
| 66 | } catch ( Query_Builder_Exception $exception ) { |
| 67 | throw new Not_Found_Page_Exception( $exception->getMessage(), ...$exception->get_additional() ); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 |