3f09b48d295490cb1deacd2889afbc79c4366486
[civicrm-core.git] / CRM / Financial / DAO / PaymentToken.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Financial/PaymentToken.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:658dc5e879f43747967fc0525bb0700e)
10 */
11
12 /**
13 * Database access object for the PaymentToken entity.
14 */
15 class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.6';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_payment_token';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = FALSE;
33
34 /**
35 * Payment Token ID
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * FK to Contact ID for the owner of the token
43 *
44 * @var int
45 */
46 public $contact_id;
47
48 /**
49 * @var int
50 */
51 public $payment_processor_id;
52
53 /**
54 * Externally provided token string
55 *
56 * @var string
57 */
58 public $token;
59
60 /**
61 * Date created
62 *
63 * @var timestamp
64 */
65 public $created_date;
66
67 /**
68 * Contact ID of token creator
69 *
70 * @var int
71 */
72 public $created_id;
73
74 /**
75 * Date this token expires
76 *
77 * @var datetime
78 */
79 public $expiry_date;
80
81 /**
82 * Email at the time of token creation. Useful for fraud forensics
83 *
84 * @var string
85 */
86 public $email;
87
88 /**
89 * Billing first name at the time of token creation. Useful for fraud forensics
90 *
91 * @var string
92 */
93 public $billing_first_name;
94
95 /**
96 * Billing middle name at the time of token creation. Useful for fraud forensics
97 *
98 * @var string
99 */
100 public $billing_middle_name;
101
102 /**
103 * Billing last name at the time of token creation. Useful for fraud forensics
104 *
105 * @var string
106 */
107 public $billing_last_name;
108
109 /**
110 * Holds the part of the card number or account details that may be retained or displayed
111 *
112 * @var string
113 */
114 public $masked_account_number;
115
116 /**
117 * IP used when creating the token. Useful for fraud forensics
118 *
119 * @var string
120 */
121 public $ip_address;
122
123 /**
124 * Class constructor.
125 */
126 public function __construct() {
127 $this->__table = 'civicrm_payment_token';
128 parent::__construct();
129 }
130
131 /**
132 * Returns localized title of this entity.
133 *
134 * @param bool $plural
135 * Whether to return the plural version of the title.
136 */
137 public static function getEntityTitle($plural = FALSE) {
138 return $plural ? ts('Payment Tokens') : ts('Payment Token');
139 }
140
141 /**
142 * Returns foreign keys and entity references.
143 *
144 * @return array
145 * [CRM_Core_Reference_Interface]
146 */
147 public static function getReferenceColumns() {
148 if (!isset(Civi::$statics[__CLASS__]['links'])) {
149 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
150 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
151 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
152 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
153 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
154 }
155 return Civi::$statics[__CLASS__]['links'];
156 }
157
158 /**
159 * Returns all the column names of this table
160 *
161 * @return array
162 */
163 public static function &fields() {
164 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
165 Civi::$statics[__CLASS__]['fields'] = [
166 'payment_token_id' => [
167 'name' => 'id',
168 'type' => CRM_Utils_Type::T_INT,
169 'title' => ts('Payment Token ID'),
170 'description' => ts('Payment Token ID'),
171 'required' => TRUE,
172 'where' => 'civicrm_payment_token.id',
173 'table_name' => 'civicrm_payment_token',
174 'entity' => 'PaymentToken',
175 'bao' => 'CRM_Financial_DAO_PaymentToken',
176 'localizable' => 0,
177 'html' => [
178 'type' => 'Number',
179 ],
180 'add' => '4.6',
181 ],
182 'contact_id' => [
183 'name' => 'contact_id',
184 'type' => CRM_Utils_Type::T_INT,
185 'title' => ts('Contact ID'),
186 'description' => ts('FK to Contact ID for the owner of the token'),
187 'required' => TRUE,
188 'where' => 'civicrm_payment_token.contact_id',
189 'table_name' => 'civicrm_payment_token',
190 'entity' => 'PaymentToken',
191 'bao' => 'CRM_Financial_DAO_PaymentToken',
192 'localizable' => 0,
193 'FKClassName' => 'CRM_Contact_DAO_Contact',
194 'html' => [
195 'label' => ts("Contact"),
196 ],
197 'add' => '4.6',
198 ],
199 'payment_processor_id' => [
200 'name' => 'payment_processor_id',
201 'type' => CRM_Utils_Type::T_INT,
202 'title' => ts('Payment Processor ID'),
203 'required' => TRUE,
204 'where' => 'civicrm_payment_token.payment_processor_id',
205 'table_name' => 'civicrm_payment_token',
206 'entity' => 'PaymentToken',
207 'bao' => 'CRM_Financial_DAO_PaymentToken',
208 'localizable' => 0,
209 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
210 'html' => [
211 'label' => ts("Payment Processor"),
212 ],
213 'add' => '4.6',
214 ],
215 'token' => [
216 'name' => 'token',
217 'type' => CRM_Utils_Type::T_STRING,
218 'title' => ts('Token'),
219 'description' => ts('Externally provided token string'),
220 'required' => TRUE,
221 'maxlength' => 255,
222 'size' => CRM_Utils_Type::HUGE,
223 'where' => 'civicrm_payment_token.token',
224 'table_name' => 'civicrm_payment_token',
225 'entity' => 'PaymentToken',
226 'bao' => 'CRM_Financial_DAO_PaymentToken',
227 'localizable' => 0,
228 'add' => '4.6',
229 ],
230 'created_date' => [
231 'name' => 'created_date',
232 'type' => CRM_Utils_Type::T_TIMESTAMP,
233 'title' => ts('Created Date'),
234 'description' => ts('Date created'),
235 'where' => 'civicrm_payment_token.created_date',
236 'default' => 'CURRENT_TIMESTAMP',
237 'table_name' => 'civicrm_payment_token',
238 'entity' => 'PaymentToken',
239 'bao' => 'CRM_Financial_DAO_PaymentToken',
240 'localizable' => 0,
241 'add' => '4.6',
242 ],
243 'created_id' => [
244 'name' => 'created_id',
245 'type' => CRM_Utils_Type::T_INT,
246 'title' => ts('Created ID'),
247 'description' => ts('Contact ID of token creator'),
248 'where' => 'civicrm_payment_token.created_id',
249 'table_name' => 'civicrm_payment_token',
250 'entity' => 'PaymentToken',
251 'bao' => 'CRM_Financial_DAO_PaymentToken',
252 'localizable' => 0,
253 'FKClassName' => 'CRM_Contact_DAO_Contact',
254 'html' => [
255 'label' => ts("Created"),
256 ],
257 'add' => '4.6',
258 ],
259 'expiry_date' => [
260 'name' => 'expiry_date',
261 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
262 'title' => ts('Expiry Date'),
263 'description' => ts('Date this token expires'),
264 'where' => 'civicrm_payment_token.expiry_date',
265 'table_name' => 'civicrm_payment_token',
266 'entity' => 'PaymentToken',
267 'bao' => 'CRM_Financial_DAO_PaymentToken',
268 'localizable' => 0,
269 'add' => '4.6',
270 ],
271 'email' => [
272 'name' => 'email',
273 'type' => CRM_Utils_Type::T_STRING,
274 'title' => ts('Email'),
275 'description' => ts('Email at the time of token creation. Useful for fraud forensics'),
276 'maxlength' => 255,
277 'size' => CRM_Utils_Type::HUGE,
278 'where' => 'civicrm_payment_token.email',
279 'table_name' => 'civicrm_payment_token',
280 'entity' => 'PaymentToken',
281 'bao' => 'CRM_Financial_DAO_PaymentToken',
282 'localizable' => 0,
283 'add' => '4.6',
284 ],
285 'billing_first_name' => [
286 'name' => 'billing_first_name',
287 'type' => CRM_Utils_Type::T_STRING,
288 'title' => ts('Billing First Name'),
289 'description' => ts('Billing first name at the time of token creation. Useful for fraud forensics'),
290 'maxlength' => 255,
291 'size' => CRM_Utils_Type::HUGE,
292 'where' => 'civicrm_payment_token.billing_first_name',
293 'table_name' => 'civicrm_payment_token',
294 'entity' => 'PaymentToken',
295 'bao' => 'CRM_Financial_DAO_PaymentToken',
296 'localizable' => 0,
297 'add' => '4.6',
298 ],
299 'billing_middle_name' => [
300 'name' => 'billing_middle_name',
301 'type' => CRM_Utils_Type::T_STRING,
302 'title' => ts('Billing Middle Name'),
303 'description' => ts('Billing middle name at the time of token creation. Useful for fraud forensics'),
304 'maxlength' => 255,
305 'size' => CRM_Utils_Type::HUGE,
306 'where' => 'civicrm_payment_token.billing_middle_name',
307 'table_name' => 'civicrm_payment_token',
308 'entity' => 'PaymentToken',
309 'bao' => 'CRM_Financial_DAO_PaymentToken',
310 'localizable' => 0,
311 'add' => '4.6',
312 ],
313 'billing_last_name' => [
314 'name' => 'billing_last_name',
315 'type' => CRM_Utils_Type::T_STRING,
316 'title' => ts('Billing Last Name'),
317 'description' => ts('Billing last name at the time of token creation. Useful for fraud forensics'),
318 'maxlength' => 255,
319 'size' => CRM_Utils_Type::HUGE,
320 'where' => 'civicrm_payment_token.billing_last_name',
321 'table_name' => 'civicrm_payment_token',
322 'entity' => 'PaymentToken',
323 'bao' => 'CRM_Financial_DAO_PaymentToken',
324 'localizable' => 0,
325 'add' => '4.6',
326 ],
327 'masked_account_number' => [
328 'name' => 'masked_account_number',
329 'type' => CRM_Utils_Type::T_STRING,
330 'title' => ts('Masked Account Number'),
331 'description' => ts('Holds the part of the card number or account details that may be retained or displayed'),
332 'maxlength' => 255,
333 'size' => CRM_Utils_Type::HUGE,
334 'where' => 'civicrm_payment_token.masked_account_number',
335 'table_name' => 'civicrm_payment_token',
336 'entity' => 'PaymentToken',
337 'bao' => 'CRM_Financial_DAO_PaymentToken',
338 'localizable' => 0,
339 'add' => '4.6',
340 ],
341 'ip_address' => [
342 'name' => 'ip_address',
343 'type' => CRM_Utils_Type::T_STRING,
344 'title' => ts('IP Address'),
345 'description' => ts('IP used when creating the token. Useful for fraud forensics'),
346 'maxlength' => 255,
347 'size' => CRM_Utils_Type::HUGE,
348 'where' => 'civicrm_payment_token.ip_address',
349 'table_name' => 'civicrm_payment_token',
350 'entity' => 'PaymentToken',
351 'bao' => 'CRM_Financial_DAO_PaymentToken',
352 'localizable' => 0,
353 'add' => '4.6',
354 ],
355 ];
356 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
357 }
358 return Civi::$statics[__CLASS__]['fields'];
359 }
360
361 /**
362 * Return a mapping from field-name to the corresponding key (as used in fields()).
363 *
364 * @return array
365 * Array(string $name => string $uniqueName).
366 */
367 public static function &fieldKeys() {
368 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
369 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
370 }
371 return Civi::$statics[__CLASS__]['fieldKeys'];
372 }
373
374 /**
375 * Returns the names of this table
376 *
377 * @return string
378 */
379 public static function getTableName() {
380 return self::$_tableName;
381 }
382
383 /**
384 * Returns if this table needs to be logged
385 *
386 * @return bool
387 */
388 public function getLog() {
389 return self::$_log;
390 }
391
392 /**
393 * Returns the list of fields that can be imported
394 *
395 * @param bool $prefix
396 *
397 * @return array
398 */
399 public static function &import($prefix = FALSE) {
400 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'payment_token', $prefix, []);
401 return $r;
402 }
403
404 /**
405 * Returns the list of fields that can be exported
406 *
407 * @param bool $prefix
408 *
409 * @return array
410 */
411 public static function &export($prefix = FALSE) {
412 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'payment_token', $prefix, []);
413 return $r;
414 }
415
416 /**
417 * Returns the list of indices
418 *
419 * @param bool $localize
420 *
421 * @return array
422 */
423 public static function indices($localize = TRUE) {
424 $indices = [];
425 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
426 }
427
428 }