annamaria-daneswood-25102012 /administrator/components/com_virtuemart/classes/payment/ps_pbs.php

Language PHP Lines 304
MD5 Hash a9b9ad6ad6d231a2513c5be7004c4ec8 Estimated Cost $2,256 (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
*
* @version $Id: ps_pbs.php 1095 2007-12-19 20:19:16Z soeren_nb $
* @package VirtueMart
* @subpackage payment
* @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

/**
* The ps_pbs class, containing the payment processing code
*  for transactions with PBS supported Payment Gateways 
* @author soeren
 */
class ps_pbs {

    var $payment_code = "PBS";
    var $classname = "ps_pbs";
  
    /**
    * Show all configuration parameters for this payment method
    * @returns boolean False when the Payment method has no configration
    */
    function show_configuration() {
    
      global $VM_LANG, $mosConfig_live_site;
      $db =& new ps_DB;
      /** Read current Configuration ***/
      require_once(CLASSPATH ."payment/".$this->classname.".cfg.php");
    ?>
      <table>
        <tr>
            <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PBS_MERCHANT_ID') ?></strong></td>
            <td>
                <input type="text" name="PBS_MERCHANT_ID" class="inputbox" value="<?php echo PBS_MERCHANT_ID ?>" />
            </td>
            <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PBS_MERCHANT_ID_EXPLAIN') ?></td>
        </tr>
        <tr>
            <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PBD_GATEWAY') ?></strong></td>
            <td>
                <select name="PBS_GATEWAY" onchange="updateExtraInfo();" class="inputbox">
                    <option <?php if (PBS_GATEWAY == 'freeway.dk') echo "selected=\"selected\""; ?> value="freeway.dk">freeway.dk</option>
                    <option <?php if (PBS_GATEWAY == 'danhost.dk') echo "selected=\"selected\""; ?> value="danhost.dk">danhost.dk</option>
                    <!--<option <?php if (PBS_GATEWAY == 'webhosting.dk') echo "selected=\"selected\""; ?> value="webhosting.dk">webhosting.dk</option>-->
                    <!--<option <?php if (PBS_GATEWAY == 'interpay.dk') echo "selected=\"selected\""; ?> value="interpay.dk">interpay.dk</option>-->
                    <option <?php if (PBS_GATEWAY == 'wannafind.dk') echo "selected=\"selected\""; ?> value="wannafind.dk">wannafind.dk</option>
                    <option <?php if (PBS_GATEWAY == 'dandomain.dk') echo "selected=\"selected\""; ?> value="dandomain.dk">dandomain.dk</option>
                </select>
            </td>
            <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PBD_GATEWAY_EXPLAIN') ?></td>
        </tr>
        <tr>
            <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PBS_SHOP_ID') ?></strong></td>
            <td>
                <input type="text" name="PBS_SHOP_ID" class="inputbox" value="<?php echo PBS_SHOP_ID ?>" />
            </td>
            <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PBS_SHOP_ID_EXPLAIN') ?></td>
        </tr>
        <tr>
            <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYMENT_ORDERSTATUS_SUCC') ?></strong></td>
            <td>
                <select name="PBS_VERIFIED_STATUS" class="inputbox" >
                <?php
                    $q = "SELECT order_status_name,order_status_code FROM #__{vm}_order_status ORDER BY list_order";
                    $db->query($q);
                    $order_status_code = Array();
                    $order_status_name = Array();
                    
                    while ($db->next_record()) {
                      $order_status_code[] = $db->f("order_status_code");
                      $order_status_name[] =  $db->f("order_status_name");
                    }
                    for ($i = 0; $i < sizeof($order_status_code); $i++) {
                      echo "<option value=\"" . $order_status_code[$i];
                      if (PBS_VERIFIED_STATUS == $order_status_code[$i]) 
                         echo "\" selected=\"selected\">";
                      else
                         echo "\">";
                      echo $order_status_name[$i] . "</option>\n";
                    }?>
                    </select>
            </td>
            <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYMENT_ORDERSTATUS_SUCC_EXPLAIN') ?></td>
        </tr>
            <tr>
            <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYMENT_ORDERSTATUS_FAIL') ?></strong></td>
            <td>
                <select name="PBS_INVALID_STATUS" class="inputbox" >
                <?php
                    for ($i = 0; $i < sizeof($order_status_code); $i++) {
                      echo "<option value=\"" . $order_status_code[$i];
                      if (PBS_INVALID_STATUS == $order_status_code[$i]) 
                         echo "\" selected=\"selected\">";
                      else
                         echo "\">";
                      echo $order_status_name[$i] . "</option>\n";
                    } ?>
                    </select>
            </td>
            <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYMENT_ORDERSTATUS_FAIL_EXPLAIN') ?></td>
        </tr>
        <tr>
            <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_ENABLE_AUTORIZENET_TESTMODE') ?></strong></td>
            <td>
                <select name="PBS_TEST_MODE" class="inputbox" >
                <option <?php if (PBS_TEST_MODE == '1') echo "selected=\"selected\""; ?> value="1"><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_YES') ?></option>
                <option <?php if (PBS_TEST_MODE == '0') echo "selected=\"selected\""; ?> value="0"><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_NO') ?></option>
                </select>
            </td>
            <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_ENABLE_AUTORIZENET_TESTMODE_EXPLAIN') ?>
            </td>
        </tr>
      </table>
      <script type="text/javascript">
      function updateExtraInfo() {
        var form = document.adminForm;
        switch( form.PBS_GATEWAY.selectedIndex ) {
            // FreeWay.dk
            case 0:
                form.payment_extrainfo.value = '<'+'?php\n'
                        +'// This is the Session ID\n'
                        +'// It contains the Order ID, the VirtueMart Session ID and an md5 HASH CheckCode\n'
                        +'$sessionid = sprintf("%08d", $order_id). $_COOKIE[\'virtuemart\'].md5($_SERVER[\'REMOTE_ADDR\']);\n'
                        +'$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);\n'
                        +'$sessionid = base64_encode( $sessionid );\n'
                        +'?>\n'
                        +'<form action="https://pay.freeway.dk/payform/relay.asp/<'+'?php echo PBS_MERCHANT_ID ?>?sessionid=<'+'?php echo $sessionid ?>" method="post" name="paymentform">\n'
                        +'<input type="image" src="components/com_virtuemart/shop_image/ps_image/payment.gif" name="submit" alt="Pay your Order now - Click here!" align="center" border="0" />\n'
                        +'</form>'
                        +'<a href="#" onclick="document.paymentform.submit();">Pay your Order now - Click here!</a>\n';
                break;
            // DanHost.dk
            case 1:
                form.payment_extrainfo.value = '<'+'?php\n'
                        +'// This is the Session ID\n'
                        +'// It contains the Order ID, the VirtueMart Session ID and an md5 HASH CheckCode\n'
                        +'$sessionid = sprintf("%08d", $order_id). $_COOKIE[\'virtuemart\'].md5($_SERVER[\'REMOTE_ADDR\']);\n'
                        +'$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);\n'
                        +'$sessionid = base64_encode( $sessionid );\n'
                        +'?>\n'
                        +'<form action="https://gateway.fuzion.dk/" method="post">\n'
                        +'<input type="image" src="components/com_virtuemart/shop_image/ps_image/payment.gif" name="submit" alt="Pay your Order now - Click here!" align="center" border="0" />\n'
                        +'<input type="hidden" name="shopid" value="<'+'?php echo PBS_SHOP_ID ?>" />\n'
                        +'<input type="hidden" name="sessionid" value="<'+'?php echo $sessionid ?>" />\n'
                        +'<input type="hidden" name="shop_orderid" value="<'+'?php echo $order_id ?>" />\n'
                        +'</form>'
                        +'<a href="#" onclick="document.paymentform.submit();">Pay your Order now - Click here!</a>\n';
                break;
            // Webhosting.dk
            case 2:
                form.payment_extrainfo.value = '<'+'?php\n'
                        +'// This is the Session ID\n'
                        +'// It contains the Order ID, the VirtueMart Session ID and an md5 HASH CheckCode\n'
                        +'$sessionid = sprintf("%08d", $order_id). $_COOKIE[\'virtuemart\'].md5($_SERVER[\'REMOTE_ADDR\']);\n'
                        +'$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);\n'
                        +'$sessionid = base64_encode( $sessionid );\n'
                        +'?>\n'
                        +'<form action="https://secure.webhosting.dk/pbsgateway/index.php" method="post" name="paymentform">\n'
                        +'<input type="image" src="components/com_virtuemart/shop_image/ps_image/payment.gif" name="submit" alt="Pay your Order now - Click here!" align="center" border="0" />\n'
                        +'<input type="hidden" name="shopid" value="<'+'?php echo PBS_SHOP_ID ?>" />\n'
                        +'<input type="hidden" name="sessionid" value="<'+'?php echo $sessionid ?>" />\n'
                        +'<input type="hidden" name="orderid" value="<'+'?php echo $order_id ?>" />\n'
                        +'<input type="hidden" name="currencycode" value="208" />\n'
                        +'<input type="hidden" name="amount" value="<'+'?php echo $db->f("order_total") ?>" />\n'
                        +'</form>'
                        +'<a href="#" onclick="document.paymentform.submit();">Pay your Order now - Click here!</a>\n';
                break;
            // Interpay.dk
            case 3:
                form.payment_extrainfo.value = '<'+'?php\n'
                        +'// This is the Session ID\n'
                        +'// It contains the Order ID, the VirtueMart Session ID and an md5 HASH CheckCode\n'
                        +'$sessionid = sprintf("%08d", $order_id). $_COOKIE[\'virtuemart\'].md5($_SERVER[\'REMOTE_ADDR\']);\n'
                        +'$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);\n'
                        +'$sessionid = base64_encode( $sessionid );\n'
                        +'?>\n'
                        +'<form action="https://pbs.interpay.dk/?sessionid=<'+'?php echo $sessionid ?>&amount=<'+'?php $db->p("order_total") ?>" method="post" name="paymentform">\n'
                        +'<input type="image" src="components/com_virtuemart/shop_image/ps_image/payment.gif" name="submit" alt="Pay your Order now - Click here!" align="center" border="0" />\n'
                        +'</form>'
                        +'<a href="#" onclick="document.paymentform.submit();">Pay your Order now - Click here!</a>\n';
                break;
            // WannaFind.dk
            case 4:
                form.payment_extrainfo.value = '<'+'?php\n'
                        +'// This is the Session ID\n'
                        +'// It contains the Order ID, the VirtueMart Session ID and an md5 HASH CheckCode\n'
                        +'$sessionid = sprintf("%08d", $order_id). $_COOKIE[\'virtuemart\'].md5($_SERVER[\'REMOTE_ADDR\']);\n'
                        +'$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);\n'
                        +'$sessionid = base64_encode( $sessionid );\n'
                        +'?>\n'
                        +'<form action="https://betaling.wannafind.dk/proxy/p.php/<'+'?php echo $mosConfig_live_site ?>/index.php?option=com_virtuemart&page=checkout.wannafind_cc_form&sessionid=<'+'?php echo $sessionid ?>" method="post" name="paymentform">\n'
                        +'<input type="image" src="components/com_virtuemart/shop_image/ps_image/payment.gif" name="submit" alt="Pay your Order now - Click here!" align="center" border="0" />\n'
                        +'<input type="hidden" name="shopid" value="<'+'?php echo PBS_SHOP_ID ?>" />\n'
                        +'<input type="hidden" name="orderid" value="<'+'?php echo $order_id ?>" />\n'
                        +'</form>'
                        +'<a href="#" onclick="document.paymentform.submit();">Pay your Order now - Click here!</a>\n';
                break;
            // DanDomain.dk
            case 5:
                form.payment_extrainfo.value = '<'+'?php\n'
                        +'// This is the Session ID\n'
                        +'// It contains the Order ID, the VirtueMart Session ID and an md5 HASH CheckCode\n'
                        +'$sessionid = sprintf("%08d", $order_id). $_COOKIE[\'virtuemart\'].md5($_SERVER[\'REMOTE_ADDR\']);\n'
                        +'$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);\n'
                        +'$sessionid = base64_encode( $sessionid );\n'
                        +'?>\n'
                        +'<form action="https://pay.dandomain.dk/securetunnel.asp" method="post" name="paymentform">\n'
                        +'<input type="image" src="components/com_virtuemart/shop_image/ps_image/payment.gif" name="submit" alt="Pay your Order now - Click here!" align="center" border="0" />\n'
                        +'<input type="hidden" name="MerchantNumber" value="<'+'?php echo PBS_MERCHANT_ID ?>" />\n'
                        +'<input type="hidden" name="TunnelURL" value="<'+'?php echo $mosConfig_live_site ?>/index.php?option=com_virtuemart&page=checkout.dandomain_cc_form&sessionid=<'+'?php echo $sessionid ?>" />\n'
                        +'<input type="hidden" name="shopid" value="<'+'?php echo PBS_SHOP_ID ?>" />\n'
                        +'<input type="hidden" name="OrderID" value="<'+'?php echo $order_id ?>" />\n'
                        +'<input type="hidden" name="Amount" value="<'+'?php echo str_replace(".", ",", $db->f("order_total")) ?>" />\n'
                        +'<input type="hidden" name="CurrencyID" value="208" />\n'
                        +'</form>'
                        +'<a href="#" onclick="document.paymentform.submit();">Pay your Order now - Click here!</a>\n';
                break;
        }
      }
      </script>
   <?php
      // return false if there\'s no configuration
      return true;
   }
   
    function has_configuration() {
      // return false if there's no configuration
      return true;
   }
   
  /**
	* Returns the "is_writeable" status of the configuration file
	* @param void
	* @returns boolean True when the configuration file is writeable, false when not
	*/
   function configfile_writeable() {
      return is_writeable( CLASSPATH."payment/".$this->classname.".cfg.php" );
   }
   
  /**
	* Returns the "is_readable" status of the configuration file
	* @param void
	* @returns boolean True when the configuration file is writeable, false when not
	*/
   function configfile_readable() {
      return is_readable( CLASSPATH."payment/".$this->classname.".cfg.php" );
   }   
  /**
	* Writes the configuration file for this payment method
	* @param array An array of objects
	* @returns boolean True when writing was successful
	*/
   function write_configuration( &$d ) {
      global $vmLogger;
      
      $my_config_array = array("PBS_MERCHANT_ID" => $d['PBS_MERCHANT_ID'],
                                "PBS_GATEWAY" => $d['PBS_GATEWAY'],
                                "PBS_SHOP_ID" => $d['PBS_SHOP_ID'],
                                "PBS_VERIFIED_STATUS" => $d['PBS_VERIFIED_STATUS'],
                                "PBS_INVALID_STATUS" => $d['PBS_INVALID_STATUS'],
                                "PBS_TEST_MODE" => $d['PBS_TEST_MODE']
                        );
      $config = "<?php\n";
      $config .= "if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); \n\n";
      foreach( $my_config_array as $key => $value ) {
        $config .= "define ('$key', '$value');\n";
      }
      
      $config .= "?>";
  
      if ($fp = fopen(CLASSPATH ."payment/".$this->classname.".cfg.php", "w")) {
          fputs($fp, $config, strlen($config));
          fclose ($fp);
          return true;
     }
     else {
        $vmLogger->err( "Could not write to configuration file ".CLASSPATH ."payment/".$this->classname.".cfg.php" );
        return false;
     }
   }
   
  /**************************************************************************
  ** name: process_payment()
  ** created by: ryan
  ** description: process transaction for PayMeNow
  ** parameters: $order_number, the number of the order, we're processing here
  **            $order_total, the total $ of the order
  ** returns: 
  ***************************************************************************/
   function process_payment($order_number, $order_total, &$d) {
    return true;
    }
}
Back to Top