annamaria-daneswood-25102012 /administrator/components/com_virtuemart/html/checkout.epay_result.php

Language PHP Lines 204
MD5 Hash 4f126bd01766eb67cc4fd62d76d53b97 Estimated Cost $2,738 (why?)
Repository https://bitbucket.org/dgough/annamaria-daneswood-25102012.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php 
/**
* @version $Id: checkout.epay_result.php,v 1.4 2005/05/22 09:21:15 soeren_nb Exp $
* @package VirtueMart
* @subpackage html
* @copyright (C) 2007-2008 Thomas Knudsen
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*
* www.VirtueMart.net
*
* ePay Order Confirmation Handler
*/
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );   

function addPaymentLog($dbConn, $log, $order_id)
{
	$dbConn->query( "UPDATE #__{vm}_order_payment SET order_payment_log = concat('" . $dbConn->getEscaped($log) . "<br>', order_payment_log) where order_id = '" .$dbConn->getEscaped( $order_id ) . "'");
}

function orderPaymentNotYetUpdated($dbConn, $order_id, $tid)
{
	$res = false;
	$dbConn->query("SELECT COUNT(*) `qty` FROM `#__{vm}_order_payment` WHERE `order_payment_number` = '" . $dbConn->getEscaped($order_id ) . "' and order_payment_trans_id = '" .$dbConn->getEscaped( $tid) . "'");
	if($dbConn->next_record()) {
		if ($dbConn->f('qty') == 0) {
			$res = true;
		}
	}
	return $res;
}

require_once(  CLASSPATH ."payment/ps_epay.cfg.php");

$accept = $_REQUEST["accept"];
$tid = $_REQUEST["tid"];
$order_id = $_REQUEST["orderid"];
$order_amount = $_REQUEST["amount"];
$order_currency = $_REQUEST["cur"];
$order_ekey = $_REQUEST["eKey"];
$error = $_REQUEST["error"];
$order_currency = $_REQUEST["cur"];



//////////////////////



////////////////////////

//
// Now validat on the MD5 stamping. If the MD5 key is valid or if MD5 is disabled
//
if(($order_ekey == md5( $order_amount . $order_id . $tid  . EPAY_MD5_KEY)) || EPAY_MD5_TYPE == 0 ) {
	
			//
			// Find the corresponding order in the database
			//  
      $qv = "SELECT order_id, order_number FROM #__{vm}_orders WHERE order_id='".$order_id."'";
      $dbo = new ps_DB;
      $dbo->query($qv);
      if($dbo->next_record()) {
        $d['order_id'] = $dbo->f("order_id");
        
        //
        // Switch on the order accept code
        // accept = 1 (standard redirect) accept = 2 (callback)
        //
        if( empty($_REQUEST['errorcode']) && ($accept == "1" || $accept == "2") ) {	
        	
        	//
        	// Only update the order information once
        	//
        	if (orderPaymentNotYetUpdated($dbo, $order_id, $tid)) {
        		
            
	            // UPDATE THE ORDER STATUS to 'VALID'
	            $d['order_status'] = EPAY_VERIFIED_STATUS;
	            // Setting this to "Y" = yes is required by Danish Law
	            $d['notify_customer'] = "Y";
	            $d['include_comment'] = "Y";
	            // Notifying the customer about the transaction key and
	            // the order Status Update
	            $d['order_comment'] = $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_ORDER_COMMENT') . urldecode($tid)."\n";
	                
	            require_once ( CLASSPATH . 'ps_order.php' );
	            $ps_order= new ps_order;
	            $ps_order->order_status_update($d);
	            
	            //
	            // Order payment
	            //
	            $dbo->query( "UPDATE #__{vm}_order_payment SET order_payment_number = '" . $dbo->getEscaped($order_id ). "', order_payment_trans_id = '" . $tid . "', order_payment_code = 0 where order_id = '" .$dbo->getEscaped( $order_id ). "'");
	            
	            // add history callback info
	            if ($accept == "2") {
	            	addPaymentLog($dbo, $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_CALLBACK'), $order_id);
	            }
	            
	            // payment fee
	            if ($_REQUEST["transfee"]) {
	            	addPaymentLog($dbo, $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_FEE') . $_REQUEST["transfee"], $order_id);
	            }
	            
	            // payment date
	            if ($_REQUEST["date"]) {
	            	addPaymentLog($dbo, $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_DATE') . $_REQUEST["date"], $order_id);
	            }
	            
	            // payment fraud control
	            if ($_REQUEST["fraud"]) {
	            	addPaymentLog($dbo, sprintf($VM_LANG->_('PHPSHOP_EPAY_FRAUD'), $_REQUEST["fraud"]), $order_id);
	            }
	            
	            // card id
	            if ($_REQUEST["cardid"]) {
	               $cardname = "Unknown";
	               $cardimage = "c" . $_REQUEST["cardid"] . ".gif";
	               switch ($_REQUEST["cardid"])
	               {
                    case 1: $cardname = 'Dankort (DK)'; break;
                    case 2: $cardname = 'Visa/Dankort (DK)'; break;
                    case 3: $cardname = 'Visa Electron (Udenlandsk)'; break;
                    case 4: $cardname = 'Mastercard (DK)'; break;
                    case 5: $cardname = 'Mastercard (Udenlandsk)'; break;
                    case 6: $cardname = 'Visa Electron (DK)'; break;
                    case 7: $cardname = 'JCB (Udenlandsk)'; break;
                    case 8: $cardname = 'Diners (DK)'; break;
                    case 9: $cardname = 'Maestro (DK)'; break;
                    case 10: $cardname = 'American Express (DK)'; break;
                    case 11: $cardname = 'Ukendt'; break;
                    case 12: $cardname = 'eDankort (DK)'; break;
                    case 13: $cardname = 'Diners (Udenlandsk)'; break;
                    case 14: $cardname = 'American Express (Udenlandsk)'; break;
                    case 15: $cardname = 'Maestro (Udenlandsk)'; break;
                    case 16: $cardname = 'Forbrugsforeningen (DK)'; break;
                    case 17: $cardname = 'eWire'; break;
                    case 18: $cardname = 'VISA'; break;
                    case 19: $cardname = 'IKANO'; break;
                    case 20: $cardname = 'Andre'; break;
                    case 21: $cardname = 'Nordea'; break;
                    case 22: $cardname = 'Danske Bank'; break;
                    case 23: $cardname = 'Danske Bank'; break;
                 }
	               addPaymentLog($dbo, sprintf($VM_LANG->_('PHPSHOP_EPAY_PAYMENT_CARDTYPE'), $cardname, $cardimage), $order_id);
	            	  
	            }
	            
	            // creation information
	            addPaymentLog($dbo, $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_LOG_TID') . $tid . $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_EPAY_LINK'), $order_id);
	        }
  
?> 
            <img src="<?php echo VM_THEMEURL ?>images/button_ok.png" align="middle" alt="Success" border="0" />
            <h2><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_TRANSACTION_SUCCESS'); ?></h2>
<?php
        }
        elseif( $accept == "0" ) {
            // the Payment wasn't successful. Maybe the Payment couldn't
            // be verified and is pending
            // UPDATE THE ORDER STATUS to 'INVALID'
            $d['order_status'] = EPAY_INVALID_STATUS;
            // Setting this to "Y" = yes is required by Danish Law
            $d['notify_customer'] = "Y";
            $d['include_comment'] = "Y";
            // Notifying the customer about the transaction key and
            // the order Status Update
            $d['order_comment'] = $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_DECLINE') . $fejl;
            require_once ( CLASSPATH . 'ps_order.php' );
            $ps_order= new ps_order;
            $ps_order->order_status_update($d);
            
?> 
            <img src="<?php echo VM_THEMEURL ?>images/button_cancel.png" align="middle" alt="Failure" border="0" />
            <h2><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_ERROR') ?></h2>
<?php
		
           
						echo $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_RETRY_PAYMENT');
        }
        
?>
        <br/>
        <p><a href="<?php @$sess->purl( SECUREURL."index.php?option=com_virtuemart&page=account.order_details&order_id=$order_id" ) ?>">
           <?php echo $VM_LANG->_('PHPSHOP_ORDER_LINK') ?></a>
        </p>
<?php
      }
      else {
        ?>
        <img src="<?php echo VM_THEMEURL ?>images/button_cancel.png" align="middle" alt="Failure" border="0" />
        <span class="message"><? echo $VM_LANG->_('PHPSHOP_PAYMENT_ERROR') . $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_ORDER_NOT_FOUND') ?> </span><?php
      }
}
else{
        ?>
        <img src="<?php echo VM_THEMEURL ?>images/button_cancel.png" align="middle" alt="Failure" border="0" />
        <span class="message"><? echo $VM_LANG->_('PHPSHOP_PAYMENT_ERROR') . $VM_LANG->_('PHPSHOP_EPAY_PAYMENT_MD5_CHECK_FAILURE') ?> </span><?php
  }
  ?>
Back to Top