103 $this->
init(
'oxpayments');
113 $this->_blPaymentVatOnTop = $blOnTop;
123 if ($this->_oGroups == null && ($sOxid = $this->
getId())) {
126 $this->_oGroups =
oxNew(
'oxlist',
'oxgroups');
130 $sSelect =
"select {$sViewName}.* from {$sViewName}, oxobject2group
131 where oxobject2group.oxobjectid = '{$sOxid}'
132 and oxobject2group.oxgroupsid={$sViewName}.oxid ";
133 $this->_oGroups->selectString($sSelect);
146 $this->_aDynValues = $aDynValues;
157 $this->_aDynValues[$oKey] = $oVal;
167 if (!$this->_aDynValues) {
168 $sRawDynValue = null;
169 if (is_object($this->oxpayments__oxvaldesc)) {
170 $sRawDynValue = $this->oxpayments__oxvaldesc->getRawValue();
190 if ($this->oxpayments__oxaddsumtype->value ==
"%") {
191 $dRet = $dBasePrice * $this->oxpayments__oxaddsum->value / 100;
193 $oCur = $this->
getConfig()->getActShopCurrencyObject();
194 $dRet = $this->oxpayments__oxaddsum->value * $oCur->rate;
197 if (($dRet * -1) > $dBasePrice) {
215 $iRules = $this->oxpayments__oxaddsumrules->value;
218 if (!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_ALLGOODS)) {
219 $dBasketPrice += $oBasket->getProductsPrice()->getSum($oBasket->isCalculationModeNetto());
223 if ((!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_DISCOUNTS)) &&
224 ($oCosts = $oBasket->getTotalDiscount())
226 $dBasketPrice -= $oCosts->getPrice();
230 if (!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_VOUCHERS)) {
231 $dBasketPrice -= $oBasket->getVoucherDiscValue();
235 if ((!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_SHIPCOSTS)) &&
236 ($oCosts = $oBasket->getCosts(
'oxdelivery'))
238 if ($oBasket->isCalculationModeNetto()) {
239 $dBasketPrice += $oCosts->getNettoPrice();
241 $dBasketPrice += $oCosts->getBruttoPrice();
247 if (($iRules & self::PAYMENT_ADDSUMRULE_GIFTS) &&
248 ($oCosts = $oBasket->getCosts(
'oxwrapping'))
250 if ($oBasket->isCalculationModeNetto()) {
251 $dBasketPrice += $oCosts->getNettoPrice();
253 $dBasketPrice += $oCosts->getBruttoPrice();
258 if (($iRules & self::PAYMENT_ADDSUMRULE_GIFTS) &&
259 ($oCosts = $oBasket->getCosts(
'oxgiftcard'))
262 if ($oBasket->isCalculationModeNetto()) {
263 $dBasketPrice += $oCosts->getNettoPrice();
265 $dBasketPrice += $oCosts->getBruttoPrice();
269 return $dBasketPrice;
284 $oPrice =
oxNew(
'oxPrice');
285 $oPrice->setNettoMode($this->_blPaymentVatOnTop);
287 $oPrice->setPrice($dPrice);
289 $oPrice->setVat($oBasket->getAdditionalServicesVatPercent());
292 $this->_oPrice = $oPrice;
356 if ($this->_aCountries === null) {
358 $this->_aCountries = array();
359 $sSelect =
'select oxobjectid from oxobject2payment where oxpaymentid=' . $oDb->quote($this->
getId()) .
' and oxtype = "oxcountry" ';
360 $rs = $oDb->getCol($sSelect);
361 $this->_aCountries = $rs;
374 public function delete($sOxId = null)
376 if (parent::delete($sOxId)) {
378 $sOxId = $sOxId ? $sOxId : $this->
getId();
382 $rs = $oDb->execute(
"delete from oxobject2payment where oxpaymentid = " . $oDb->quote($sOxId));
401 public function isValidPayment($aDynValue, $sShopId, $oUser, $dBasketPrice, $sShipSetId)
404 if ($this->oxpayments__oxid->value ==
'oxempty') {
406 if (!$this->oxpayments__oxactive->value || !
$myConfig->getConfigParam(
"blOtherCountryOrder")) {
407 $this->_iPaymentError = -2;
413 ->getDeliverySetList(
415 $oUser->getActiveCountry()
419 $this->_iPaymentError = -3;
427 $mxValidationResult =
oxRegistry::get(
"oxInputValidator")->validatePaymentInputData($this->oxpayments__oxid->value, $aDynValue);
429 if (is_integer($mxValidationResult)) {
430 $this->_iPaymentError = $mxValidationResult;
433 } elseif ($mxValidationResult ===
false) {
434 $this->_iPaymentError = 1;
439 $oCur =
$myConfig->getActShopCurrencyObject();
440 $dBasketPrice = $dBasketPrice / $oCur->rate;
443 $aPaymentList =
oxRegistry::get(
"oxPaymentList")->getPaymentList($sShipSetId, $dBasketPrice, $oUser);
445 if (!array_key_exists($this->
getId(), $aPaymentList)) {
446 $this->_iPaymentError = -3;
451 $this->_iPaymentError = -2;