Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Give_Payment often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Give_Payment, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 58 | final class Give_Payment { |
||
| 59 | |||
| 60 | /** |
||
| 61 | * The Payment ID. |
||
| 62 | * |
||
| 63 | * @since 1.5 |
||
| 64 | * |
||
| 65 | * @var int |
||
| 66 | */ |
||
| 67 | public $ID = 0; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Protected non-read $_ID. |
||
| 71 | * |
||
| 72 | * @var int |
||
| 73 | */ |
||
| 74 | protected $_ID = 0; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Identify if the payment is a new one or existing. |
||
| 78 | * |
||
| 79 | * @since 1.5 |
||
| 80 | * @access protected |
||
| 81 | * |
||
| 82 | * @var boolean |
||
| 83 | */ |
||
| 84 | protected $new = false; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * The Payment number (for use with sequential payments). |
||
| 88 | * |
||
| 89 | * @since 1.5 |
||
| 90 | * @access protected |
||
| 91 | * |
||
| 92 | * @var string |
||
| 93 | */ |
||
| 94 | protected $number = ''; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * The Gateway mode the payment was made in. |
||
| 98 | * |
||
| 99 | * @since 1.5 |
||
| 100 | * @access protected |
||
| 101 | * |
||
| 102 | * @var string |
||
| 103 | */ |
||
| 104 | protected $mode = 'live'; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Is donations is Import or not. |
||
| 108 | * |
||
| 109 | * @since 1.8.13 |
||
| 110 | * @access protected |
||
| 111 | * |
||
| 112 | * @var bool |
||
| 113 | */ |
||
| 114 | protected $import = false; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * The unique donation payment key. |
||
| 118 | * |
||
| 119 | * @since 1.5 |
||
| 120 | * @access protected |
||
| 121 | * |
||
| 122 | * @var string |
||
| 123 | */ |
||
| 124 | protected $key = ''; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * The Donation Form Title |
||
| 128 | * |
||
| 129 | * @since 1.5 |
||
| 130 | * @access protected |
||
| 131 | * |
||
| 132 | * @var string |
||
| 133 | */ |
||
| 134 | protected $form_title = 0; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * The Donation Form ID |
||
| 138 | * |
||
| 139 | * @since 1.5 |
||
| 140 | * @access protected |
||
| 141 | * |
||
| 142 | * @var string |
||
| 143 | */ |
||
| 144 | protected $form_id = 0; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * The Donation Form Price ID |
||
| 148 | * |
||
| 149 | * @since 1.5 |
||
| 150 | * @access protected |
||
| 151 | * |
||
| 152 | * @var string|int |
||
| 153 | */ |
||
| 154 | protected $price_id = 0; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * The total amount of the donation payment. |
||
| 158 | * |
||
| 159 | * @since 1.5 |
||
| 160 | * @access protected |
||
| 161 | * |
||
| 162 | * @var float |
||
| 163 | */ |
||
| 164 | protected $total = 0.00; |
||
| 165 | |||
| 166 | /** |
||
| 167 | * The Subtotal fo the payment. |
||
| 168 | * |
||
| 169 | * @since 1.5 |
||
| 170 | * @access protected |
||
| 171 | * |
||
| 172 | * @var float |
||
| 173 | */ |
||
| 174 | protected $subtotal = 0; |
||
| 175 | |||
| 176 | /** |
||
| 177 | * The date the payment was created |
||
| 178 | * |
||
| 179 | * @since 1.5 |
||
| 180 | * @access protected |
||
| 181 | * |
||
| 182 | * @var string |
||
| 183 | */ |
||
| 184 | protected $date = ''; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * The date the payment post was created. |
||
| 188 | * |
||
| 189 | * @var string |
||
| 190 | */ |
||
| 191 | protected $post_date = ''; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * The date the payment was marked as 'complete'. |
||
| 195 | * |
||
| 196 | * @since 1.5 |
||
| 197 | * @access protected |
||
| 198 | * |
||
| 199 | * @var string |
||
| 200 | */ |
||
| 201 | protected $completed_date = ''; |
||
| 202 | |||
| 203 | /** |
||
| 204 | * The status of the donation payment. |
||
| 205 | * |
||
| 206 | * @since 1.5 |
||
| 207 | * @access protected |
||
| 208 | * |
||
| 209 | * @var string |
||
| 210 | */ |
||
| 211 | protected $status = 'pending'; |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Donation Status. |
||
| 215 | * |
||
| 216 | * @var string |
||
| 217 | */ |
||
| 218 | protected $post_status = 'pending'; // Same as $status but here for backwards compat. |
||
| 219 | |||
| 220 | /** |
||
| 221 | * When updating, the old status prior to the change |
||
| 222 | * |
||
| 223 | * @since 1.5 |
||
| 224 | * @access protected |
||
| 225 | * |
||
| 226 | * @var string |
||
| 227 | */ |
||
| 228 | protected $old_status = ''; |
||
| 229 | |||
| 230 | /** |
||
| 231 | * The display name of the current payment status. |
||
| 232 | * |
||
| 233 | * @since 1.5 |
||
| 234 | * @access protected |
||
| 235 | * |
||
| 236 | * @var string |
||
| 237 | */ |
||
| 238 | protected $status_nicename = ''; |
||
| 239 | |||
| 240 | /** |
||
| 241 | * The donor ID that made the payment. |
||
| 242 | * |
||
| 243 | * @since 1.5 |
||
| 244 | * @access protected |
||
| 245 | * |
||
| 246 | * @var integer |
||
| 247 | */ |
||
| 248 | protected $customer_id = null; |
||
| 249 | |||
| 250 | /** |
||
| 251 | * The Donor ID (if logged in) that made the payment |
||
| 252 | * |
||
| 253 | * @since 1.8.13 |
||
| 254 | * @access protected |
||
| 255 | * |
||
| 256 | * @var integer |
||
| 257 | */ |
||
| 258 | protected $donor_id = 0; |
||
| 259 | |||
| 260 | /** |
||
| 261 | * The User ID (if logged in) that made the payment |
||
| 262 | * |
||
| 263 | * @since 1.5 |
||
| 264 | * @access protected |
||
| 265 | * |
||
| 266 | * @var integer |
||
| 267 | */ |
||
| 268 | protected $user_id = 0; |
||
| 269 | |||
| 270 | /** |
||
| 271 | * The Title Prefix/Salutation of the Donor. |
||
| 272 | * |
||
| 273 | * @since 2.2 |
||
| 274 | * |
||
| 275 | * @var string |
||
| 276 | */ |
||
| 277 | protected $title_prefix = ''; |
||
| 278 | |||
| 279 | /** |
||
| 280 | * The first name of the payee |
||
| 281 | * |
||
| 282 | * @since 1.5 |
||
| 283 | * @access protected |
||
| 284 | * |
||
| 285 | * @var string |
||
| 286 | */ |
||
| 287 | protected $first_name = ''; |
||
| 288 | |||
| 289 | /** |
||
| 290 | * The last name of the payee |
||
| 291 | * |
||
| 292 | * @since 1.5 |
||
| 293 | * @access protected |
||
| 294 | * |
||
| 295 | * @var string |
||
| 296 | */ |
||
| 297 | protected $last_name = ''; |
||
| 298 | |||
| 299 | /** |
||
| 300 | * The email used for the payment |
||
| 301 | * |
||
| 302 | * @since 1.5 |
||
| 303 | * @access protected |
||
| 304 | * |
||
| 305 | * @var string |
||
| 306 | */ |
||
| 307 | protected $email = ''; |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Legacy (not to be accessed) array of user information |
||
| 311 | * |
||
| 312 | * @since 1.5 |
||
| 313 | * @access private |
||
| 314 | * |
||
| 315 | * @var array |
||
| 316 | */ |
||
| 317 | private $user_info = array(); |
||
| 318 | |||
| 319 | /** |
||
| 320 | * Legacy (not to be accessed) payment meta array |
||
| 321 | * |
||
| 322 | * @since 1.5 |
||
| 323 | * @access private |
||
| 324 | * |
||
| 325 | * @var array |
||
| 326 | */ |
||
| 327 | private $payment_meta = array(); |
||
| 328 | |||
| 329 | /** |
||
| 330 | * The physical address used for the payment if provided |
||
| 331 | * |
||
| 332 | * @since 1.5 |
||
| 333 | * @access protected |
||
| 334 | * |
||
| 335 | * @var array |
||
| 336 | */ |
||
| 337 | protected $address = array(); |
||
| 338 | |||
| 339 | /** |
||
| 340 | * The transaction ID returned by the gateway |
||
| 341 | * |
||
| 342 | * @since 1.5 |
||
| 343 | * @access protected |
||
| 344 | * |
||
| 345 | * @var string |
||
| 346 | */ |
||
| 347 | protected $transaction_id = ''; |
||
| 348 | |||
| 349 | /** |
||
| 350 | * IP Address payment was made from |
||
| 351 | * |
||
| 352 | * @since 1.5 |
||
| 353 | * @access protected |
||
| 354 | * |
||
| 355 | * @var string |
||
| 356 | */ |
||
| 357 | protected $ip = ''; |
||
| 358 | |||
| 359 | /** |
||
| 360 | * The gateway used to process the payment |
||
| 361 | * |
||
| 362 | * @since 1.5 |
||
| 363 | * @access protected |
||
| 364 | * |
||
| 365 | * @var string |
||
| 366 | */ |
||
| 367 | protected $gateway = ''; |
||
| 368 | |||
| 369 | /** |
||
| 370 | * The the payment was made with |
||
| 371 | * |
||
| 372 | * @since 1.5 |
||
| 373 | * @access protected |
||
| 374 | * |
||
| 375 | * @var string |
||
| 376 | */ |
||
| 377 | protected $currency = ''; |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Array of items that have changed since the last save() was run. |
||
| 381 | * This is for internal use, to allow fewer update_payment_meta calls to be run. |
||
| 382 | * |
||
| 383 | * @since 1.5 |
||
| 384 | * @access private |
||
| 385 | * |
||
| 386 | * @var array |
||
| 387 | */ |
||
| 388 | private $pending; |
||
| 389 | |||
| 390 | /** |
||
| 391 | * The parent payment (if applicable) |
||
| 392 | * |
||
| 393 | * @since 1.5 |
||
| 394 | * @access protected |
||
| 395 | * |
||
| 396 | * @var integer |
||
| 397 | */ |
||
| 398 | protected $parent_payment = 0; |
||
| 399 | |||
| 400 | /** |
||
| 401 | * Setup the Give Payments class |
||
| 402 | * |
||
| 403 | * @since 1.5 |
||
| 404 | * @access public |
||
| 405 | * |
||
| 406 | * @param int|bool $payment_id A given payment. |
||
| 407 | * |
||
| 408 | * @return mixed void|false |
||
|
|
|||
| 409 | */ |
||
| 410 | public function __construct( $payment_id = false ) { |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Magic GET function. |
||
| 421 | * |
||
| 422 | * @since 1.5 |
||
| 423 | * @access public |
||
| 424 | * |
||
| 425 | * @param string $key The property. |
||
| 426 | * |
||
| 427 | * @return mixed The value. |
||
| 428 | */ |
||
| 429 | public function __get( $key ) { |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Magic SET function |
||
| 446 | * |
||
| 447 | * Sets up the pending array for the save method |
||
| 448 | * |
||
| 449 | * @since 1.5 |
||
| 450 | * @access public |
||
| 451 | * |
||
| 452 | * @param string $key The property name. |
||
| 453 | * @param mixed $value The value of the property. |
||
| 454 | */ |
||
| 455 | public function __set( $key, $value ) { |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Magic ISSET function, which allows empty checks on protected elements |
||
| 473 | * |
||
| 474 | * @since 1.5 |
||
| 475 | * @access public |
||
| 476 | * |
||
| 477 | * @param string $name The attribute to get. |
||
| 478 | * |
||
| 479 | * @return boolean|null If the item is set or not |
||
| 480 | */ |
||
| 481 | public function __isset( $name ) { |
||
| 488 | |||
| 489 | /** |
||
| 490 | * Setup payment properties |
||
| 491 | * |
||
| 492 | * @since 1.5 |
||
| 493 | * @access private |
||
| 494 | * |
||
| 495 | * @param int $payment_id The payment ID. |
||
| 496 | * |
||
| 497 | * @return bool If the setup was successful or not |
||
| 498 | */ |
||
| 499 | private function setup_payment( $payment_id ) { |
||
| 606 | |||
| 607 | |||
| 608 | /** |
||
| 609 | * Payment class object is storing various meta value in object parameter. |
||
| 610 | * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically |
||
| 611 | * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. |
||
| 612 | * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ). |
||
| 613 | * |
||
| 614 | * @since 1.6 |
||
| 615 | * @access public |
||
| 616 | * |
||
| 617 | * @param int $payment_id Payment ID. |
||
| 618 | * |
||
| 619 | * @return void |
||
| 620 | */ |
||
| 621 | public function update_payment_setup( $payment_id ) { |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Create the base of a payment. |
||
| 630 | * |
||
| 631 | * @since 1.5 |
||
| 632 | * @access private |
||
| 633 | * |
||
| 634 | * @return int|bool False on failure, the payment ID on success. |
||
| 635 | */ |
||
| 636 | private function insert_payment() { |
||
| 789 | |||
| 790 | /** |
||
| 791 | * Save |
||
| 792 | * |
||
| 793 | * Once items have been set, an update is needed to save them to the database. |
||
| 794 | * |
||
| 795 | * @access public |
||
| 796 | * |
||
| 797 | * @return bool True of the save occurred, false if it failed or wasn't needed |
||
| 798 | */ |
||
| 799 | public function save() { |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Add a donation to a given payment |
||
| 1040 | * |
||
| 1041 | * @since 1.5 |
||
| 1042 | * @access public |
||
| 1043 | * |
||
| 1044 | * @param int $form_id The donation form to add. |
||
| 1045 | * @param array $args Other arguments to pass to the function. |
||
| 1046 | * @param array $options List of donation options. |
||
| 1047 | * |
||
| 1048 | * @return bool True when successful, false otherwise |
||
| 1049 | */ |
||
| 1050 | public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
||
| 1134 | |||
| 1135 | /** |
||
| 1136 | * Remove a donation from the payment |
||
| 1137 | * |
||
| 1138 | * @since 1.5 |
||
| 1139 | * @access public |
||
| 1140 | * |
||
| 1141 | * @param int $form_id The form ID to remove. |
||
| 1142 | * @param array $args Arguments to pass to identify (quantity, amount, price_id). |
||
| 1143 | * |
||
| 1144 | * @return bool If the item was removed or not |
||
| 1145 | */ |
||
| 1146 | public function remove_donation( $form_id, $args = array() ) { |
||
| 1176 | |||
| 1177 | |||
| 1178 | /** |
||
| 1179 | * Add a note to a payment |
||
| 1180 | * |
||
| 1181 | * @since 1.5 |
||
| 1182 | * @access public |
||
| 1183 | * |
||
| 1184 | * @param string|bool $note The note to add. |
||
| 1185 | * |
||
| 1186 | * @return bool If the note was specified or not |
||
| 1187 | */ |
||
| 1188 | public function add_note( $note = false ) { |
||
| 1196 | |||
| 1197 | /** |
||
| 1198 | * Increase the payment's subtotal |
||
| 1199 | * |
||
| 1200 | * @since 1.5 |
||
| 1201 | * @access private |
||
| 1202 | * |
||
| 1203 | * @param float $amount The amount to increase the payment subtotal by. |
||
| 1204 | * |
||
| 1205 | * @return void |
||
| 1206 | */ |
||
| 1207 | private function increase_subtotal( $amount = 0.00 ) { |
||
| 1213 | |||
| 1214 | /** |
||
| 1215 | * Decrease the payment's subtotal. |
||
| 1216 | * |
||
| 1217 | * @since 1.5 |
||
| 1218 | * @access private |
||
| 1219 | * |
||
| 1220 | * @param float $amount The amount to decrease the payment subtotal by. |
||
| 1221 | * |
||
| 1222 | * @return void |
||
| 1223 | */ |
||
| 1224 | private function decrease_subtotal( $amount = 0.00 ) { |
||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Set or update the total for a payment. |
||
| 1237 | * |
||
| 1238 | * @since 1.5 |
||
| 1239 | * @since 2.1.4 reset total in pending property |
||
| 1240 | * @access private |
||
| 1241 | * |
||
| 1242 | * @return void |
||
| 1243 | */ |
||
| 1244 | private function recalculate_total() { |
||
| 1247 | |||
| 1248 | /** |
||
| 1249 | * Set the payment status and run any status specific changes necessary. |
||
| 1250 | * |
||
| 1251 | * @since 1.5 |
||
| 1252 | * @access public |
||
| 1253 | * |
||
| 1254 | * @param string|bool $status The status to set the payment to. |
||
| 1255 | * |
||
| 1256 | * @return bool $updated Returns if the status was successfully updated. |
||
| 1257 | */ |
||
| 1258 | public function update_status( $status = false ) { |
||
| 1318 | |||
| 1319 | /** |
||
| 1320 | * Change the status of the payment to refunded, and run the necessary changes |
||
| 1321 | * |
||
| 1322 | * @since 1.5 |
||
| 1323 | * @access public |
||
| 1324 | * |
||
| 1325 | * @return void |
||
| 1326 | */ |
||
| 1327 | public function refund() { |
||
| 1334 | |||
| 1335 | /** |
||
| 1336 | * Get a post meta item for the payment |
||
| 1337 | * |
||
| 1338 | * @since 1.5 |
||
| 1339 | * @access public |
||
| 1340 | * |
||
| 1341 | * @param string $meta_key The Meta Key. |
||
| 1342 | * @param boolean $single Return single item or array. |
||
| 1343 | * |
||
| 1344 | * @return mixed The value from the post meta |
||
| 1345 | */ |
||
| 1346 | public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
||
| 1378 | |||
| 1379 | /** |
||
| 1380 | * Update the post meta |
||
| 1381 | * |
||
| 1382 | * @since 1.5 |
||
| 1383 | * @access public |
||
| 1384 | * |
||
| 1385 | * @param string $meta_key The meta key to update. |
||
| 1386 | * @param string $meta_value The meta value. |
||
| 1387 | * @param string $prev_value Previous meta value. |
||
| 1388 | * |
||
| 1389 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
||
| 1390 | */ |
||
| 1391 | public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
||
| 1406 | |||
| 1407 | /** |
||
| 1408 | * Process Donation Status. |
||
| 1409 | * |
||
| 1410 | * @param string $status Donation Status. |
||
| 1411 | * |
||
| 1412 | * @since 2.0.2 |
||
| 1413 | * @access private |
||
| 1414 | * |
||
| 1415 | * @return void |
||
| 1416 | */ |
||
| 1417 | private function process_status( $status ) { |
||
| 1466 | |||
| 1467 | /** |
||
| 1468 | * Used during the process of moving to refunded or pending, to decrement stats |
||
| 1469 | * |
||
| 1470 | * @since 1.5 |
||
| 1471 | * @access private |
||
| 1472 | * |
||
| 1473 | * @param bool $alter_store_earnings If the method should alter the store earnings. |
||
| 1474 | * @param bool $alter_customer_value If the method should reduce the donor value. |
||
| 1475 | * @param bool $alter_customer_purchase_count If the method should reduce the donor's purchase count. |
||
| 1476 | * |
||
| 1477 | * @return void |
||
| 1478 | */ |
||
| 1479 | private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
||
| 1503 | |||
| 1504 | /** |
||
| 1505 | * Delete sales logs for this donation |
||
| 1506 | * |
||
| 1507 | * @since 1.5 |
||
| 1508 | * @access private |
||
| 1509 | * |
||
| 1510 | * @return void |
||
| 1511 | */ |
||
| 1512 | private function delete_sales_logs() { |
||
| 1516 | |||
| 1517 | /** |
||
| 1518 | * Setup functions only, these are not to be used by developers. |
||
| 1519 | * These functions exist only to allow the setup routine to be backwards compatible with our old |
||
| 1520 | * helper functions. |
||
| 1521 | * |
||
| 1522 | * These will run whenever setup_payment is called, which should only be called once. |
||
| 1523 | * To update an attribute, update it directly instead of re-running the setup routine |
||
| 1524 | */ |
||
| 1525 | |||
| 1526 | /** |
||
| 1527 | * Setup the payment completed date |
||
| 1528 | * |
||
| 1529 | * @since 1.5 |
||
| 1530 | * @access private |
||
| 1531 | * |
||
| 1532 | * @return string The date the payment was completed |
||
| 1533 | */ |
||
| 1534 | private function setup_completed_date() { |
||
| 1545 | |||
| 1546 | /** |
||
| 1547 | * Setup the payment mode |
||
| 1548 | * |
||
| 1549 | * @since 1.5 |
||
| 1550 | * @access private |
||
| 1551 | * |
||
| 1552 | * @return string The payment mode |
||
| 1553 | */ |
||
| 1554 | private function setup_mode() { |
||
| 1557 | |||
| 1558 | /** |
||
| 1559 | * Setup the payment import data |
||
| 1560 | * |
||
| 1561 | * @since 1.8.13 |
||
| 1562 | * @access private |
||
| 1563 | * |
||
| 1564 | * @return bool The payment import |
||
| 1565 | */ |
||
| 1566 | private function setup_import() { |
||
| 1569 | |||
| 1570 | /** |
||
| 1571 | * Setup the payment total |
||
| 1572 | * |
||
| 1573 | * @since 1.5 |
||
| 1574 | * @access private |
||
| 1575 | * |
||
| 1576 | * @return float The payment total |
||
| 1577 | */ |
||
| 1578 | private function setup_total() { |
||
| 1583 | |||
| 1584 | /** |
||
| 1585 | * Setup the payment subtotal |
||
| 1586 | * |
||
| 1587 | * @since 1.5 |
||
| 1588 | * @access private |
||
| 1589 | * |
||
| 1590 | * @return float The subtotal of the payment |
||
| 1591 | */ |
||
| 1592 | private function setup_subtotal() { |
||
| 1597 | |||
| 1598 | /** |
||
| 1599 | * Setup the currency code |
||
| 1600 | * |
||
| 1601 | * @since 1.5 |
||
| 1602 | * @since 2.0 Set currency from _give_payment_currency meta key |
||
| 1603 | * @access private |
||
| 1604 | * |
||
| 1605 | * @return string The currency for the payment |
||
| 1606 | */ |
||
| 1607 | View Code Duplication | private function setup_currency() { |
|
| 1624 | |||
| 1625 | /** |
||
| 1626 | * Setup the gateway used for the payment |
||
| 1627 | * |
||
| 1628 | * @since 1.5 |
||
| 1629 | * @access private |
||
| 1630 | * |
||
| 1631 | * @return string The gateway |
||
| 1632 | */ |
||
| 1633 | private function setup_gateway() { |
||
| 1638 | |||
| 1639 | /** |
||
| 1640 | * Setup the donation ID |
||
| 1641 | * |
||
| 1642 | * @since 1.5 |
||
| 1643 | * @access private |
||
| 1644 | * |
||
| 1645 | * @return string The donation ID |
||
| 1646 | */ |
||
| 1647 | View Code Duplication | private function setup_transaction_id() { |
|
| 1657 | |||
| 1658 | /** |
||
| 1659 | * Setup the IP Address for the payment |
||
| 1660 | * |
||
| 1661 | * @since 1.5 |
||
| 1662 | * @since 2.0 Set ip address from _give_payment_donor_ip meta key |
||
| 1663 | * @access private |
||
| 1664 | * |
||
| 1665 | * @return string The IP address for the payment |
||
| 1666 | */ |
||
| 1667 | private function setup_ip() { |
||
| 1672 | |||
| 1673 | /** |
||
| 1674 | * Setup the donor ID. |
||
| 1675 | * |
||
| 1676 | * @since 1.5 |
||
| 1677 | * @since 2.0 Set id from _give_payment_donor_id meta key |
||
| 1678 | * @access private |
||
| 1679 | * |
||
| 1680 | * @return int The Donor ID. |
||
| 1681 | */ |
||
| 1682 | private function setup_donor_id() { |
||
| 1687 | |||
| 1688 | /** |
||
| 1689 | * Setup the User ID associated with the donation |
||
| 1690 | * |
||
| 1691 | * @since 1.5 |
||
| 1692 | * @since 2.0 Get user id connect to donor from donor table instead of payment meta. |
||
| 1693 | * |
||
| 1694 | * @access private |
||
| 1695 | * |
||
| 1696 | * @return int The User ID |
||
| 1697 | */ |
||
| 1698 | private function setup_user_id() { |
||
| 1706 | |||
| 1707 | /** |
||
| 1708 | * Setup the email address for the donation. |
||
| 1709 | * |
||
| 1710 | * @since 1.5 |
||
| 1711 | * @since 2.0 Set email from _give_payment_donor_email meta key |
||
| 1712 | * |
||
| 1713 | * @access private |
||
| 1714 | * |
||
| 1715 | * @return string The email address for the payment. |
||
| 1716 | */ |
||
| 1717 | private function setup_email() { |
||
| 1726 | |||
| 1727 | /** |
||
| 1728 | * Setup the user info. |
||
| 1729 | * |
||
| 1730 | * @since 1.5 |
||
| 1731 | * @access private |
||
| 1732 | * |
||
| 1733 | * @return array The user info associated with the payment. |
||
| 1734 | */ |
||
| 1735 | private function setup_user_info() { |
||
| 1799 | |||
| 1800 | /** |
||
| 1801 | * Setup the Address for the payment. |
||
| 1802 | * |
||
| 1803 | * @since 1.5 |
||
| 1804 | * @access private |
||
| 1805 | * |
||
| 1806 | * @return array The Address information for the payment. |
||
| 1807 | */ |
||
| 1808 | private function setup_address() { |
||
| 1818 | |||
| 1819 | /** |
||
| 1820 | * Setup the form title. |
||
| 1821 | * |
||
| 1822 | * @since 1.5 |
||
| 1823 | * @access private |
||
| 1824 | * |
||
| 1825 | * @return string The Form Title. |
||
| 1826 | */ |
||
| 1827 | private function setup_form_title() { |
||
| 1833 | |||
| 1834 | /** |
||
| 1835 | * Setup the form ID. |
||
| 1836 | * |
||
| 1837 | * @since 1.5 |
||
| 1838 | * @access private |
||
| 1839 | * |
||
| 1840 | * @return int The Form ID |
||
| 1841 | */ |
||
| 1842 | private function setup_form_id() { |
||
| 1848 | |||
| 1849 | /** |
||
| 1850 | * Setup the price ID. |
||
| 1851 | * |
||
| 1852 | * @since 1.5 |
||
| 1853 | * @access private |
||
| 1854 | * |
||
| 1855 | * @return int The Form Price ID. |
||
| 1856 | */ |
||
| 1857 | private function setup_price_id() { |
||
| 1862 | |||
| 1863 | /** |
||
| 1864 | * Setup the payment key. |
||
| 1865 | * |
||
| 1866 | * @since 1.5 |
||
| 1867 | * @access private |
||
| 1868 | * |
||
| 1869 | * @return string The Payment Key. |
||
| 1870 | */ |
||
| 1871 | private function setup_payment_key() { |
||
| 1876 | |||
| 1877 | /** |
||
| 1878 | * Setup the payment number. |
||
| 1879 | * |
||
| 1880 | * @since 1.5 |
||
| 1881 | * @access private |
||
| 1882 | * |
||
| 1883 | * @return int|string Integer by default, or string if sequential order numbers is enabled. |
||
| 1884 | */ |
||
| 1885 | private function setup_payment_number() { |
||
| 1888 | |||
| 1889 | /** |
||
| 1890 | * Converts this object into an array for special cases. |
||
| 1891 | * |
||
| 1892 | * @access public |
||
| 1893 | * |
||
| 1894 | * @return array The payment object as an array. |
||
| 1895 | */ |
||
| 1896 | public function array_convert() { |
||
| 1899 | |||
| 1900 | |||
| 1901 | /** |
||
| 1902 | * Flag to check if donation is completed or not. |
||
| 1903 | * |
||
| 1904 | * @since 1.8 |
||
| 1905 | * @access public |
||
| 1906 | * |
||
| 1907 | * @return bool |
||
| 1908 | */ |
||
| 1909 | public function is_completed() { |
||
| 1912 | |||
| 1913 | /** |
||
| 1914 | * Retrieve payment completion date. |
||
| 1915 | * |
||
| 1916 | * @since 1.5 |
||
| 1917 | * @access private |
||
| 1918 | * |
||
| 1919 | * @return string Date payment was completed. |
||
| 1920 | */ |
||
| 1921 | private function get_completed_date() { |
||
| 1924 | |||
| 1925 | /** |
||
| 1926 | * Retrieve payment subtotal. |
||
| 1927 | * |
||
| 1928 | * @since 1.5 |
||
| 1929 | * @access private |
||
| 1930 | * |
||
| 1931 | * @return float Payment subtotal. |
||
| 1932 | */ |
||
| 1933 | private function get_subtotal() { |
||
| 1936 | |||
| 1937 | /** |
||
| 1938 | * Retrieve payment currency. |
||
| 1939 | * |
||
| 1940 | * @since 1.5 |
||
| 1941 | * @access private |
||
| 1942 | * |
||
| 1943 | * @return string Payment currency code. |
||
| 1944 | */ |
||
| 1945 | private function get_currency() { |
||
| 1948 | |||
| 1949 | /** |
||
| 1950 | * Retrieve payment gateway. |
||
| 1951 | * |
||
| 1952 | * @since 1.5 |
||
| 1953 | * @access private |
||
| 1954 | * |
||
| 1955 | * @return string Gateway used. |
||
| 1956 | */ |
||
| 1957 | private function get_gateway() { |
||
| 1960 | |||
| 1961 | /** |
||
| 1962 | * Retrieve donation ID. |
||
| 1963 | * |
||
| 1964 | * @since 1.5 |
||
| 1965 | * @access private |
||
| 1966 | * |
||
| 1967 | * @return string Donation ID from merchant processor. |
||
| 1968 | */ |
||
| 1969 | private function get_transaction_id() { |
||
| 1972 | |||
| 1973 | /** |
||
| 1974 | * Retrieve payment IP |
||
| 1975 | * |
||
| 1976 | * @since 1.5 |
||
| 1977 | * @access private |
||
| 1978 | * |
||
| 1979 | * @return string Payment IP address |
||
| 1980 | */ |
||
| 1981 | private function get_ip() { |
||
| 1984 | |||
| 1985 | /** |
||
| 1986 | * Retrieve payment donor ID. |
||
| 1987 | * |
||
| 1988 | * @since 1.5 |
||
| 1989 | * @access private |
||
| 1990 | * |
||
| 1991 | * @return int Payment donor ID. |
||
| 1992 | */ |
||
| 1993 | private function get_donor_id() { |
||
| 1996 | |||
| 1997 | /** |
||
| 1998 | * Retrieve payment user ID. |
||
| 1999 | * |
||
| 2000 | * @since 1.5 |
||
| 2001 | * @access private |
||
| 2002 | * |
||
| 2003 | * @return int Payment user ID. |
||
| 2004 | */ |
||
| 2005 | private function get_user_id() { |
||
| 2008 | |||
| 2009 | /** |
||
| 2010 | * Retrieve payment email. |
||
| 2011 | * |
||
| 2012 | * @since 1.5 |
||
| 2013 | * @access private |
||
| 2014 | * |
||
| 2015 | * @return string Payment donor email. |
||
| 2016 | */ |
||
| 2017 | private function get_email() { |
||
| 2020 | |||
| 2021 | /** |
||
| 2022 | * Retrieve payment user info. |
||
| 2023 | * |
||
| 2024 | * @since 1.5 |
||
| 2025 | * @access private |
||
| 2026 | * |
||
| 2027 | * @return array Payment user info. |
||
| 2028 | */ |
||
| 2029 | private function get_user_info() { |
||
| 2032 | |||
| 2033 | /** |
||
| 2034 | * Retrieve payment billing address. |
||
| 2035 | * |
||
| 2036 | * @since 1.5 |
||
| 2037 | * @access private |
||
| 2038 | * |
||
| 2039 | * @return array Payment billing address. |
||
| 2040 | */ |
||
| 2041 | private function get_address() { |
||
| 2044 | |||
| 2045 | /** |
||
| 2046 | * Retrieve payment key. |
||
| 2047 | * |
||
| 2048 | * @since 1.5 |
||
| 2049 | * @access private |
||
| 2050 | * |
||
| 2051 | * @return string Payment key. |
||
| 2052 | */ |
||
| 2053 | private function get_key() { |
||
| 2056 | |||
| 2057 | /** |
||
| 2058 | * Retrieve payment form id |
||
| 2059 | * |
||
| 2060 | * @since 1.5 |
||
| 2061 | * @access private |
||
| 2062 | * |
||
| 2063 | * @return string Payment form id |
||
| 2064 | */ |
||
| 2065 | private function get_form_id() { |
||
| 2068 | |||
| 2069 | /** |
||
| 2070 | * Retrieve payment number |
||
| 2071 | * |
||
| 2072 | * @since 1.5 |
||
| 2073 | * @access private |
||
| 2074 | * |
||
| 2075 | * @return int|string Payment number |
||
| 2076 | */ |
||
| 2077 | private function get_number() { |
||
| 2080 | |||
| 2081 | /** |
||
| 2082 | * Get serial code |
||
| 2083 | * |
||
| 2084 | * @since 2.1 |
||
| 2085 | * |
||
| 2086 | * @param array $args List of arguments. |
||
| 2087 | * |
||
| 2088 | * @return string |
||
| 2089 | */ |
||
| 2090 | public function get_serial_code( $args = array() ) { |
||
| 2093 | } |
||
| 2094 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.