PaymentSimulator.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ HoxCzJVEmR+lB0qrMQ7dh79qOVSfCzOr4zZGzs/rb+Q=
  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.2
  11. */
  12. /**
  13. * payment simulator gateway model class
  14. */
  15. namespace Ppb\Model\PaymentGateway;
  16. use Cube\Controller\Request\AbstractRequest;
  17. class PaymentSimulator extends AbstractPaymentGateway
  18. {
  19. /**
  20. * payment gateway name
  21. */
  22. const NAME = 'PaymentSimulator';
  23. /**
  24. * payment simulator description
  25. */
  26. protected $_description = 'Payment Simulator description.';
  27. public function __construct($userId = null)
  28. {
  29. parent::__construct(self::NAME, $userId);
  30. }
  31. public function enabled()
  32. {
  33. return true;
  34. }
  35. public function formElements()
  36. {
  37. return array(
  38. array(
  39. 'id' => 'transaction_id',
  40. 'value' => $this->getTransactionId(),
  41. 'element' => 'hidden',
  42. ),
  43. );
  44. }
  45. /**
  46. *
  47. * get payment box post url
  48. *
  49. * @return string
  50. */
  51. public function getPostUrl()
  52. {
  53. return parent::getIpnUrl();
  54. }
  55. /**
  56. *
  57. * process ipn
  58. *
  59. * @param \Cube\Controller\Request\AbstractRequest $request
  60. * @return bool return true if ipn is valid (for the simulator it will always be true
  61. */
  62. public function processIpn(AbstractRequest $request)
  63. {
  64. if ($request->isPost()) {
  65. $this->setTransactionId($_POST['transaction_id'])
  66. ->setGatewayPaymentStatus('Completed')
  67. ->setGatewayTransactionCode('SimulatorTXN');
  68. return true;
  69. }
  70. return false;
  71. }
  72. /**
  73. *
  74. * for the payment simulator, this will always be true
  75. *
  76. * @param float $amount
  77. * @param string $currency
  78. * @return bool
  79. */
  80. public function checkIpnAmount($amount, $currency)
  81. {
  82. return true;
  83. }
  84. }