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