oxuserpayment.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class oxUserPayment extends oxBase
00010 {
00011 
00012     // you can change this if you want more security
00013     // DO NOT !! CHANGE THIS FILE AND STORE CREDIT CARD INFORMATION
00014     // THIS IS MORE THAN LIKELY ILLEGAL !!
00015     // CHECK YOUR CREDIT CARD CONTRACT
00016 
00022     protected $_sPaymentKey = 'fq45QS09_fqyx09239QQ';
00023 
00029     protected $_sClassName = 'oxuserpayment';
00030 
00036     protected $_blStoreCreditCardInfo = null;
00037 
00043     protected $_oPayment = null;
00044 
00050     protected $_aDynValues = null;
00051 
00059     public function __get( $sName )
00060     {
00061         //due to compatibility with templates
00062         if ( $sName == 'oxpayments__oxdesc' ) {
00063             if ( !$this->_oPayment ) {
00064                 $this->_oPayment = oxNew( 'oxpayment' );
00065                 $this->_oPayment->load( $this->oxuserpayments__oxpaymentsid->value );
00066             }
00067             return $this->_oPayment->oxpayments__oxdesc;
00068         }
00069         if ( $sName == 'aDynValues' ) {
00070             if ( !$this->_aDynValues ) {
00071                 $this->_aDynValues = $this->getDynValues();
00072             }
00073             return $this->_aDynValues;
00074         }
00075     }
00076 
00080     public function __construct()
00081     {
00082         parent::__construct();
00083         $this->init( 'oxuserpayments' );
00084         $this->_sPaymentKey = oxUtils::getInstance()->strRot13( $this->_sPaymentKey );
00085         $this->setStoreCreditCardInfo( $this->getConfig()->getConfigParam( 'blStoreCreditCardInfo' ) );
00086     }
00087 
00093     public function getPaymentKey()
00094     {
00095         return $this->_sPaymentKey;
00096     }
00097 
00105     public function load( $sOxId )
00106     {
00107         $sSelect = 'select oxid, oxuserid, oxpaymentsid, DECODE( oxvalue, "'.$this->getPaymentKey().'" ) as oxvalue
00108                     from oxuserpayments where oxid = '. oxDb::getDb()->quote( $sOxId );
00109 
00110         return $this->assignRecord( $sSelect );
00111     }
00112 
00113 
00119     protected function _insert()
00120     {
00121         // we do not store credit card information
00122         // check and in case skip it
00123         if ( !$this->getStoreCreditCardInfo() && $this->oxuserpayments__oxpaymentsid->value == 'oxidcreditcard' ) {
00124             return true;
00125         }
00126 
00127         //encode sensitive data
00128         if ( $sValue = $this->oxuserpayments__oxvalue->value ) {
00129             $sEncodedValue = oxDb::getDb()->getOne( "select encode( '$sValue', '" . $this->getPaymentKey() . "' )" );
00130             $this->oxuserpayments__oxvalue->setValue($sEncodedValue);
00131         }
00132 
00133         return parent::_insert();
00134     }
00135 
00141     protected function _update()
00142     {
00143         //encode sensitive data
00144         if ( $sValue = $this->oxuserpayments__oxvalue->value ) {
00145             $sEncodedValue = oxDb::getDb()->getOne( "select encode( '$sValue', '" . $this->getPaymentKey() . "' )" );
00146             $this->oxuserpayments__oxvalue->setValue($sEncodedValue);
00147         }
00148 
00149         return parent::_update();
00150     }
00151 
00159     public function setStoreCreditCardInfo( $blStoreCreditCardInfo )
00160     {
00161         $this->_blStoreCreditCardInfo = $blStoreCreditCardInfo;
00162     }
00163 
00169     public function getStoreCreditCardInfo()
00170     {
00171         return $this->_blStoreCreditCardInfo;
00172     }
00173 
00182     public function getPaymentByPaymentType( $oUser = null, $sPaymentType = null )
00183     {
00184         $sOxId = null;
00185         
00186         if ( $oUser && !empty($sPaymentType) ) {
00187             $sSelect  = 'select oxid from oxuserpayments where oxpaymentsid="'.$sPaymentType.'" and oxuserid="'.$oUser->getId().'" ';
00188             
00189             $sOxId = oxDb::getDb()->getOne( $sSelect );
00190         }
00191         
00192         if ( $sOxId ) {
00193             $this->load( $sOxId );
00194             return true;
00195         } else {
00196             return false;
00197         }
00198     }    
00199 
00205     public function getDynValues()
00206     {
00207         if ( !$this->getStoreCreditCardInfo() && $this->oxuserpayments__oxpaymentsid->value == 'oxidcreditcard' ) {
00208             return null;
00209         }
00210         
00211         if ( !$this->_aDynValues ) {
00212             $this->_aDynValues = oxUtils::getInstance()->assignValuesFromText( $this->oxuserpayments__oxvalue->value );
00213         }
00214         return $this->_aDynValues;
00215     }
00216 
00224     public function setDynValues( $aDynValues )
00225     {
00226         $this->_aDynValues = $aDynValues;
00227     }
00228 
00229 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5