BxBaseModPaymentProvider.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BasePayment Base classes for Payment like modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. interface iBxBaseModPaymentProvider
  12. {
  13. public function initializeCheckout($iPendingId, $aCartInfo, $bRecurring = false, $iRecurringDays = 0);
  14. public function finalizeCheckout(&$aData);
  15. public function checkoutFinished();
  16. }
  17. class BxBaseModPaymentProvider extends BxDol
  18. {
  19. protected $MODULE;
  20. protected $_oModule;
  21. protected $_sLangsPrefix;
  22. protected $_iId;
  23. protected $_sName;
  24. protected $_sCaption;
  25. protected $_sPrefix;
  26. protected $_aOptions;
  27. protected $_bRedirectOnResult;
  28. function __construct($aConfig)
  29. {
  30. parent::__construct();
  31. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  32. $this->_sLangsPrefix = $this->_oModule->_oConfig->getPrefix('langs');
  33. $this->_iId = (int)$aConfig['id'];
  34. $this->_sName = $aConfig['name'];
  35. $this->_sCaption = _t($aConfig['caption']);
  36. $this->_sPrefix = $aConfig['option_prefix'];
  37. $this->_aOptions = !empty($aConfig['options']) ? $aConfig['options'] : array();
  38. $this->_bRedirectOnResult = false;
  39. }
  40. /**
  41. * TODO: Check whether the method is needed or not.
  42. * Is used on success only.
  43. */
  44. public function needRedirect()
  45. {
  46. return $this->_bRedirectOnResult;
  47. }
  48. protected function getOptionsByPending($iPendingId)
  49. {
  50. $aPending = $this->_oModule->_oDb->getPending(array(
  51. 'type' => 'id',
  52. 'id' => (int)$iPendingId
  53. ));
  54. return $this->_oModule->_oDb->getOptions((int)$aPending['seller_id'], $this->_iId);
  55. }
  56. protected function getOption($sName)
  57. {
  58. return isset($this->_aOptions[$this->_sPrefix . $sName]) ? $this->_aOptions[$this->_sPrefix . $sName]['value'] : "";
  59. }
  60. }
  61. /** @} */