UserVerification.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ SH8YQMYfdNAiBYNU3547+9v96/kJcaRxUV/Gn4UF4s0=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * user verification fee class
  14. */
  15. namespace Ppb\Service\Fees;
  16. use Cube\Controller\Front,
  17. Ppb\Service;
  18. class UserVerification extends Service\Fees
  19. {
  20. /**
  21. *
  22. * fees to be included
  23. *
  24. * @var array
  25. */
  26. protected $_fees = array(
  27. self::USER_VERIFICATION => 'User Verification Fee',
  28. );
  29. /**
  30. *
  31. * completed payment redirect path
  32. *
  33. * @var array
  34. */
  35. protected $_redirect = array(
  36. 'module' => 'members',
  37. 'controller' => 'summary',
  38. 'action' => 'index'
  39. );
  40. /**
  41. *
  42. * class constructor
  43. *
  44. * @param integer|string|\Ppb\Db\Table\Row\User $user the user that will be paying and for which the signup action will apply
  45. */
  46. public function __construct($user = null)
  47. {
  48. parent::__construct();
  49. if ($user !== null) {
  50. $this->setUser($user);
  51. }
  52. }
  53. /**
  54. *
  55. * activate the affected user
  56. *
  57. * @param bool $ipn true if payment is completed, false otherwise
  58. * @param array $post array keys: {user_id, recurring, refund}
  59. * @return $this
  60. */
  61. public function callback($ipn, array $post)
  62. {
  63. $usersService = new Service\Users();
  64. $user = $usersService->findBy('id', $post['user_id']);
  65. $flag = ($ipn) ? 1 : 0;
  66. if (count($user) > 0) {
  67. $user->updateUserVerification($flag, true, $post['recurring'], $post['refund']);
  68. }
  69. return $this;
  70. }
  71. public function getTotalAmount()
  72. {
  73. $settings = $this->getSettings();
  74. return $this->_addTax($settings['user_verification_fee']);
  75. }
  76. }