PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.2.4
LatePoint – Calendar Booking Plugin for Appointments and Events v5.2.4
5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / models / payment_request_model.php
latepoint / lib / models Last commit date
activity_model.php 11 months ago agent_meta_model.php 1 year ago agent_model.php 1 year ago booking_meta_model.php 1 year ago booking_model.php 11 months ago bundle_meta_model.php 11 months ago bundle_model.php 11 months ago cart_item_model.php 1 year ago cart_meta_model.php 1 year ago cart_model.php 1 year ago connector_model.php 1 year ago customer_meta_model.php 1 year ago customer_model.php 9 months ago invoice_model.php 1 year ago join_bundles_services_model.php 1 year ago location_category_model.php 9 months ago location_model.php 1 year ago meta_model.php 1 year ago model.php 9 months ago off_period_model.php 1 year ago order_intent_meta_model.php 1 year ago order_intent_model.php 9 months ago order_item_model.php 1 year ago order_meta_model.php 1 year ago order_model.php 11 months ago otp_model.php 9 months ago payment_request_model.php 1 year ago process_job_model.php 1 year ago process_model.php 1 year ago recurrence_model.php 1 year ago service_category_model.php 9 months ago service_meta_model.php 1 year ago service_model.php 9 months ago session_model.php 1 year ago settings_model.php 1 year ago step_settings_model.php 1 year ago transaction_intent_model.php 1 year ago transaction_model.php 1 year ago transaction_refund_model.php 1 year ago work_period_model.php 1 year ago
payment_request_model.php
122 lines
1 <?php
2 /*
3 * Copyright (c) 2022 LatePoint LLC. All rights reserved.
4 */
5
6 class OsPaymentRequestModel extends OsModel {
7 var $id,
8 $invoice_id,
9 $order_id,
10 $portion,
11 $charge_amount,
12 $due_at,
13 $updated_at,
14 $created_at;
15
16 function __construct( $id = false ) {
17 parent::__construct();
18 $this->table_name = LATEPOINT_TABLE_PAYMENT_REQUESTS;
19
20 if ( $id ) {
21 $this->load_by_id( $id );
22 }
23 }
24
25
26 public function get_invoice(): OsInvoiceModel {
27 if ( $this->invoice_id ) {
28 if ( ! isset( $this->invoice ) || ( isset( $this->invoice ) && ( $this->invoice->id != $this->invoice_id ) ) ) {
29 $this->invoice = new OsInvoiceModel( $this->invoice_id );
30 }
31 } else {
32 $this->invoice = new OsInvoiceModel();
33 }
34
35 return $this->invoice;
36 }
37
38
39 public function properties_to_query(): array {
40 return [
41 'portion' => __( 'Payment Portion', 'latepoint' ),
42 ];
43 }
44
45 public function get_readable_due_at(): string {
46 try {
47 return OsTimeHelper::get_readable_date( new OsWpDateTime( $this->due_at, new DateTimeZone( 'UTC' ) ) );
48 } catch ( Exception $e ) {
49 return 'n/a';
50 }
51 }
52
53 public function get_order(): OsOrderModel {
54 if ( $this->order_id ) {
55 if ( ! isset( $this->order ) || ( isset( $this->order ) && ( $this->order->id != $this->order_id ) ) ) {
56 $this->order = new OsOrderModel( $this->order_id );
57 }
58 } else {
59 $this->order = new OsOrderModel();
60 }
61
62 return $this->order;
63 }
64
65 public function get_customer(): OsCustomerModel {
66 return $this->get_order()->get_customer();
67 }
68
69 public function generate_data_vars(): array {
70
71 $vars['id'] = $this->id;
72 $vars['portion'] = $this->portion;
73 $vars['charge_amount'] = $this->charge_amount;
74 $vars['due_at'] = $this->due_at;
75 $vars['invoice_id'] = $this->invoice_id;
76 $vars['order_id'] = $this->order_id;
77 $vars['customer'] = $this->get_customer()->get_data_vars();
78 $vars['order'] = $this->get_order()->get_data_vars();
79
80 return $vars;
81 }
82
83
84 protected function params_to_sanitize() {
85 return [
86 'charge_amount' => 'money',
87 ];
88 }
89
90 protected function params_to_save( $role = 'admin' ) {
91 $params_to_save = [
92 'id',
93 'portion',
94 'charge_amount',
95 'due_at',
96 'invoice_id',
97 'order_id'
98 ];
99
100 return $params_to_save;
101 }
102
103 protected function allowed_params( $role = 'admin' ) {
104 $allowed_params = [
105 'id',
106 'portion',
107 'charge_amount',
108 'due_at',
109 'invoice_id',
110 'order_id'
111 ];
112
113 return $allowed_params;
114 }
115
116
117 protected function properties_to_validate() {
118 $validations = [];
119
120 return $validations;
121 }
122 }