[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/shop/classes/ -> ezpaymentobject.php (source)

   1  <?php
   2  //
   3  // Definition of eZPaymentObject class
   4  //
   5  // Created on: <11-Jun-2004 14:18:58 dl>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file ezpaymentobject.php
  30  */
  31  
  32  /*!
  33    \class eZPaymentObject ezpaymentobject.php
  34    \brief This is a base class for objects, which
  35    uses in redirectional payment gateways.
  36    They stores in database information about payment processing.
  37    These objects are temporary and will be destroyed after
  38    payment approvement.
  39  
  40  */
  41  
  42  define( "EZ_REDIRECT_PAYMENT_STATUS_NOT_APPROVED"   , 0 );
  43  define( "EZ_REDIRECT_PAYMENT_STATUS_APPROVED"       , 1 );
  44  
  45  
  46  class eZPaymentObject extends eZPersistentObject
  47  {
  48      /*!
  49      Constructor.
  50      */
  51      function eZPaymentObject( $row )
  52      {
  53          $this->eZPersistentObject( $row );
  54      }
  55  
  56      /*!
  57       \static
  58      Creates new object.
  59      */
  60      function &createNew( $workflowprocessID, $orderID, $paymentType )
  61      {
  62          $paymentObject = new eZPaymentObject( array( 'workflowprocess_id'  => $workflowprocessID,
  63                                                       'order_id'            => $orderID,
  64                                                       'payment_string'      => $paymentType ) );
  65          return $paymentObject;
  66      }
  67  
  68      /*!
  69      Approves payment.
  70      */
  71      function approve()
  72      {
  73          $this->setAttribute( 'status', EZ_REDIRECT_PAYMENT_STATUS_APPROVED );
  74          $this->store();
  75      }
  76  
  77      function approved()
  78      {
  79          return ( $this->attribute( 'status' ) == EZ_REDIRECT_PAYMENT_STATUS_APPROVED );
  80      }
  81  
  82      function definition()
  83      {
  84          return array( 'fields' => array( 'id' => array( 'name' => 'ID',
  85                                                          'datatype' => 'integer',
  86                                                          'default'  => 0,
  87                                                          'required' => true ),
  88                                           'workflowprocess_id' => array( 'name' => 'WorkflowProcessID',
  89                                                                          'datatype'=> 'integer',
  90                                                                          'default' => 0,
  91                                                                          'required'=> true,
  92                                                                          'foreign_class' => 'eZWorkflowProcess',
  93                                                                          'foreign_attribute' => 'id',
  94                                                                          'multiplicity' => '1..*' ),
  95                                           'order_id' => array( 'name' => 'OrderID',
  96                                                                'datatype'=> 'integer',
  97                                                                'default' => 0,
  98                                                                'required'=> false,
  99                                                                'foreign_class' => 'eZOrder',
 100                                                                'foreign_attribute' => 'id',
 101                                                                'multiplicity' => '1..*' ),
 102                                           'payment_string' => array( 'name' => 'PaymentString',
 103                                                                      'datatype'=> 'string',
 104                                                                      'default' => 'Payment',
 105                                                                      'required'=> false ),
 106                                           'status' => array( 'name' => 'Status',
 107                                                              'datatype'=> 'integer',
 108                                                              'default' => 0,
 109                                                              'required'=> true ) ),
 110                        'keys' => array( 'id' ),
 111                        'increment_key' => 'id',
 112                        'class_name' => 'eZPaymentObject',
 113                        'name' => 'ezpaymentobject' );
 114      }
 115  
 116      /*!
 117       \static
 118      Returns eZPaymentObject by 'id'.
 119      */
 120      function fetchByID( $transactionID )
 121      {
 122          $object = eZPersistentObject::fetchObject( eZPaymentObject::definition(),
 123                                                     null,
 124                                                     array( 'id' => $transactionID ) );
 125          return $object;
 126      }
 127  
 128      /*!
 129       \static
 130      Returns eZPaymentObject by 'id' of eZOrder.
 131      */
 132      function fetchByOrderID( $orderID )
 133      {
 134          return eZPersistentObject::fetchObject( eZPaymentObject::definition(),
 135                                                  null,
 136                                                  array( 'order_id' => $orderID ) );
 137      }
 138  
 139      /*!
 140       \static
 141      Returns eZPaymentObject by 'id' of eZWorkflowProcess.
 142      */
 143      function fetchByProcessID( $workflowprocessID )
 144      {
 145          return eZPersistentObject::fetchObject( eZPaymentObject::definition(),
 146                                                  null,
 147                                                  array( 'workflowprocess_id' => $workflowprocessID ) );
 148      }
 149  
 150      /*!
 151       \static
 152      Continues workflow after approvement.
 153      */
 154      function continueWorkflow( $workflowProcessID )
 155      {
 156          include_once ( 'kernel/classes/ezworkflowprocess.php' );
 157          include_once ( 'lib/ezutils/classes/ezoperationmemento.php' );
 158          include_once ( 'lib/ezutils/classes/ezoperationhandler.php' );
 159  
 160          $operationResult =  null;
 161          $theProcess      = eZWorkflowProcess::fetch( $workflowProcessID );
 162          if ( $theProcess != null )
 163          {
 164              //restore memento and run it
 165              $bodyMemento = eZOperationMemento::fetchChild( $theProcess->attribute( 'memento_key' ) );
 166              if ( is_null( $bodyMemento ) )
 167              {
 168                  eZDebug::writeError( $bodyMemento, "Empty body memento in workflow.php" );
 169                  return $operationResult;
 170              }
 171              $bodyMementoData =  $bodyMemento->data();
 172              $mainMemento     =& $bodyMemento->attribute( 'main_memento' );
 173              if ( !$mainMemento )
 174              {
 175                  return $operationResult;
 176              }
 177  
 178              $mementoData = $bodyMemento->data();
 179              $mainMementoData = $mainMemento->data();
 180              $mementoData['main_memento'] =& $mainMemento;
 181              $mementoData['skip_trigger'] = false;
 182              $mementoData['memento_key'] = $theProcess->attribute( 'memento_key' );
 183              $bodyMemento->remove();
 184  
 185              $operationParameters = array();
 186              if ( isset( $mementoData['parameters'] ) )
 187                  $operationParameters = $mementoData['parameters'];
 188  
 189              $operationResult = eZOperationHandler::execute( $mementoData['module_name'],
 190                                                              $mementoData['operation_name'],
 191                                                              $operationParameters,
 192                                                              $mementoData );
 193          }
 194  
 195          return $operationResult;
 196      }
 197  }
 198  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7