97 $this->
init(
'oxpayments' );
109 $this->_blPaymentVatOnTop = $blOnTop;
119 if ( $this->_oGroups == null && ( $sOxid = $this->
getId() ) ) {
122 $this->_oGroups =
oxNew(
'oxlist',
'oxgroups' );
126 $sSelect =
"select {$sViewName}.* from {$sViewName}, oxobject2group
127 where oxobject2group.oxobjectid = '{$sOxid}'
128 and oxobject2group.oxgroupsid={$sViewName}.oxid ";
129 $this->_oGroups->selectString( $sSelect );
144 $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();
189 if ( $this->oxpayments__oxaddsumtype->value ==
"%") {
190 $dRet = $dBasePrice * $this->oxpayments__oxaddsum->value/100;
192 $oCur = $this->
getConfig()->getActShopCurrencyObject();
193 $dRet = $this->oxpayments__oxaddsum->value * $oCur->rate;
196 if ( ($dRet * -1 ) > $dBasePrice ) {
214 $iRules = $this->oxpayments__oxaddsumrules->value;
217 if ( !$iRules || ( $iRules & self::PAYMENT_ADDSUMRULE_ALLGOODS ) ) {
218 $dBasketPrice += $oBasket->getProductsPrice()->getSum( $oBasket->isCalculationModeNetto() );
222 if ( ( !$iRules || ( $iRules & self::PAYMENT_ADDSUMRULE_DISCOUNTS ) ) &&
223 ( $oCosts = $oBasket->getTotalDiscount() ) ) {
224 $dBasketPrice -= $oCosts->getPrice();
228 if ( !$iRules || ( $iRules & self::PAYMENT_ADDSUMRULE_VOUCHERS ) ) {
229 $dBasketPrice -= $oBasket->getVoucherDiscValue();
233 if ( ( !$iRules || ( $iRules & self::PAYMENT_ADDSUMRULE_SHIPCOSTS ) ) &&
234 ( $oCosts = $oBasket->getCosts(
'oxdelivery' ) ) ) {
235 if ($oBasket->isCalculationModeNetto()) {
236 $dBasketPrice += $oCosts->getNettoPrice();
238 $dBasketPrice += $oCosts->getBruttoPrice();
244 if ( ( $iRules & self::PAYMENT_ADDSUMRULE_GIFTS ) &&
245 ( $oCosts = $oBasket->getCosts(
'oxwrapping' ) ) ) {
246 if ($oBasket->isCalculationModeNetto()) {
247 $dBasketPrice += $oCosts->getNettoPrice();
249 $dBasketPrice += $oCosts->getBruttoPrice();
254 if ( ( $iRules & self::PAYMENT_ADDSUMRULE_GIFTS ) &&
255 ( $oCosts = $oBasket->getCosts(
'oxgiftcard' ) ) ) {
257 if ($oBasket->isCalculationModeNetto()) {
258 $dBasketPrice += $oCosts->getNettoPrice();
260 $dBasketPrice += $oCosts->getBruttoPrice();
264 return $dBasketPrice;
296 $oPrice =
oxNew(
'oxPrice' );
297 if ( !$this->_blPaymentVatOnTop ) {
298 $oPrice->setBruttoPriceMode();
300 $oPrice->setNettoPriceMode();
303 $oPrice->setPrice( $dPrice );
305 $oPrice->setVat( $oBasket->getAdditionalServicesVatPercent() );
308 $this->_oPrice = $oPrice;
372 if ( $this->_aCountries === null ) {
374 $this->_aCountries = array();
375 $sSelect =
'select oxobjectid from oxobject2payment where oxpaymentid='.$oDb->quote( $this->
getId() ).
' and oxtype = "oxcountry" ';
376 $rs = $oDb->select( $sSelect );
377 if ( $rs && $rs->recordCount()) {
378 while ( !$rs->EOF ) {
379 $this->_aCountries[] = $rs->fields[0];
394 public function delete( $sOXID = null )
396 if ( parent::delete( $sOXID ) ) {
398 $sOXID = $sOXID?$sOXID:$this->
getId();
402 $rs = $oDb->execute(
"delete from oxobject2payment where oxpaymentid = ".$oDb->quote( $sOXID ) );
420 public function isValidPayment( $aDynValue, $sShopId, $oUser, $dBasketPrice, $sShipSetId )
423 if ( $this->oxpayments__oxid->value ==
'oxempty' ) {
425 if ( !$this->oxpayments__oxactive->value || !
$myConfig->getConfigParam(
"blOtherCountryOrder" ) ) {
426 $this->_iPaymentError = -2;
430 ->getDeliverySetList(
432 $oUser->getActiveCountry()
435 $this->_iPaymentError = -3;
441 $mxValidationResult =
oxRegistry::get(
"oxInputValidator")->validatePaymentInputData( $this->oxpayments__oxid->value, $aDynValue );
443 if ( is_integer($mxValidationResult) ) {
444 $this->_iPaymentError = $mxValidationResult;
446 } elseif ($mxValidationResult ===
false) {
447 $this->_iPaymentError = 1;
451 $oCur =
$myConfig->getActShopCurrencyObject();
452 $dBasketPrice = $dBasketPrice / $oCur->rate;
455 $aPaymentList =
oxRegistry::get(
"oxPaymentList")->getPaymentList( $sShipSetId, $dBasketPrice, $oUser );
457 if ( !array_key_exists( $this->
getId(), $aPaymentList ) ) {
458 $this->_iPaymentError = -3;
462 $this->_iPaymentError = -2;