[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <07-æÅ×-2003 14:21:36 sp> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 27 /*! \file checkout.php 28 */ 29 include_once ( 'kernel/classes/ezorder.php' ); 30 include_once ( 'lib/ezutils/classes/ezoperationhandler.php' ); 31 32 include_once ( 'kernel/shop/classes/ezpaymentobject.php' ); 33 34 $http =& eZHTTPTool::instance(); 35 $module =& $Params["Module"]; 36 37 $orderID = eZHTTPTool::sessionVariable( 'MyTemporaryOrderID' ); 38 $order = eZOrder::fetch( $orderID ); 39 40 if ( get_class( $order ) == 'ezorder' ) 41 { 42 if ( $order->attribute( 'is_temporary' ) ) 43 { 44 $paymentObj = eZPaymentObject::fetchByOrderID( $orderID ); 45 if ( $paymentObj != null ) 46 { 47 $startTime = time(); 48 while( ( time() - $startTime ) < 25 ) 49 { 50 eZDebug::writeDebug( "next iteration", "checkout" ); 51 $order = eZOrder::fetch( $orderID ); 52 if ( $order->attribute( 'is_temporary' ) == 0 ) 53 { 54 break; 55 } 56 else 57 { 58 sleep ( 2 ); 59 } 60 } 61 } 62 $order = eZOrder::fetch( $orderID ); 63 if ( $order->attribute( 'is_temporary' ) == 1 && $paymentObj == null ) 64 { 65 $email =& $order->accountEmail(); 66 $order->setAttribute( 'email', $email ); 67 $order->store(); 68 69 include_once ( "lib/ezutils/classes/ezhttptool.php" ); 70 eZHTTPTool::setSessionVariable( "UserOrderID", $order->attribute( 'id' ) ); 71 72 $operationResult = eZOperationHandler::execute( 'shop', 'checkout', array( 'order_id' => $order->attribute( 'id' ) ) ); 73 switch( $operationResult['status'] ) 74 { 75 case EZ_MODULE_OPERATION_HALTED: 76 { 77 if ( isset( $operationResult['redirect_url'] ) ) 78 { 79 $module->redirectTo( $operationResult['redirect_url'] ); 80 return; 81 } 82 else if ( isset( $operationResult['result'] ) ) 83 { 84 $result =& $operationResult['result']; 85 $resultContent = false; 86 if ( is_array( $result ) ) 87 { 88 if ( isset( $result['content'] ) ) 89 $resultContent = $result['content']; 90 if ( isset( $result['path'] ) ) 91 $Result['path'] = $result['path']; 92 } 93 else 94 $resultContent =& $result; 95 $Result['content'] =& $resultContent; 96 return; 97 } 98 }break; 99 case EZ_MODULE_OPERATION_CANCELED: 100 { 101 $Result = array(); 102 include_once ( "kernel/common/template.php" ); 103 $tpl =& templateInit(); 104 $Result['content'] =& $tpl->fetch( "design:shop/cancelcheckout.tpl" ) ; 105 $Result['path'] = array( array( 'url' => false, 106 'text' => ezi18n( 'kernel/shop', 'Checkout' ) ) ); 107 108 return; 109 } 110 111 } 112 } 113 else 114 { 115 if ( $order->attribute( 'is_temporary' ) == 0 ) 116 { 117 eZHTTPTool::removeSessionVariable( "CheckoutAttempt" ); 118 $module->redirectTo( '/shop/orderview/' . $orderID ); 119 return; 120 } 121 else 122 { 123 // Get the attempt number and the order. 124 $attempt = (eZHTTPTool::hasSessionVariable("CheckoutAttempt") ? eZHTTPTool::sessionVariable("CheckoutAttempt") : 0 ); 125 $attemptOrderID = (eZHTTPTool::hasSessionVariable("CheckoutAttemptOrderID") ? eZHTTPTool::sessionVariable("CheckoutAttemptOrderID") : 0 ); 126 127 // This attempt is for another order. So reset the attempt. 128 if ($attempt != 0 && $attemptOrderID != $orderID) $attempt = 0; 129 130 eZHTTPTool::setSessionVariable("CheckoutAttempt", ++$attempt); 131 eZHTTPTool::setSessionVariable("CheckoutAttemptOrderID", $orderID); 132 133 if ( $attempt < 4) 134 { 135 $Result = array(); 136 include_once ( "kernel/common/template.php" ); 137 $tpl =& templateInit(); 138 $tpl->setVariable( 'attempt', $attempt ); 139 $tpl->setVariable( 'orderID', $orderID ); 140 $Result['content'] =& $tpl->fetch( "design:shop/checkoutagain.tpl" ) ; 141 $Result['path'] = array( array( 'url' => false, 142 'text' => ezi18n( 'kernel/shop', 'Checkout' ) ) ); 143 return; 144 } 145 else 146 { 147 // Got no receipt or callback from the payment server. 148 eZHTTPTool::removeSessionVariable( "CheckoutAttempt" ); 149 150 $Result = array(); 151 include_once ( "kernel/common/template.php" ); 152 $tpl =& templateInit(); 153 $tpl->setVariable ("ErrorCode", "NO_CALLBACK"); 154 $tpl->setVariable ("OrderID", $orderID); 155 156 $Result['content'] =& $tpl->fetch( "design:shop/cancelcheckout.tpl" ) ; 157 $Result['path'] = array( array( 'url' => false, 158 'text' => ezi18n( 'kernel/shop', 'Checkout' ) ) ); 159 return; 160 } 161 } 162 } 163 } 164 $module->redirectTo( '/shop/orderview/' . $orderID ); 165 return; 166 167 } 168 169 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |