AccountBalance.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ 3sVzNGrHFB2XR6Wevhc9YUgrq1w+ytPVYiS9JX2aapc=
  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 account balance crediting/debiting fee class
  14. */
  15. namespace Ppb\Service\Fees;
  16. use Ppb\Service;
  17. class AccountBalance extends Service\Fees
  18. {
  19. /**
  20. *
  21. * completed payment redirect path
  22. *
  23. * @var array
  24. */
  25. protected $_redirect = array(
  26. 'module' => 'members',
  27. 'controller' => 'summary',
  28. 'action' => 'index'
  29. );
  30. /**
  31. *
  32. * update the balance of the selected user
  33. *
  34. * @param bool $ipn true if payment is completed, false otherwise
  35. * @param array $post array keys: {user_id, amount}
  36. * @return $this
  37. */
  38. public function callback($ipn, array $post)
  39. {
  40. if ($ipn) {
  41. $usersService = new Service\Users();
  42. $user = $usersService->findBy('id', $post['user_id']);
  43. if (count($user) > 0) {
  44. $user->updateBalance((-1) * $post['amount']);
  45. }
  46. }
  47. return $this;
  48. }
  49. }