/administrator/components/com_virtuemart/classes/payment/ps_cashondel.php

https://github.com/shafiqissani/Jewelery-Ecommerce- · PHP · 180 lines · 116 code · 17 blank · 47 comment · 5 complexity · c736db5c37d300852f5fb5ecb2c30ac2 MD5 · raw file

  1. <?php
  2. if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
  3. /**
  4. * @version $Id: ps_cashondelpay.php,v 1.4 2005/05/27 19:33:57 ei
  5. *
  6. * a special type of 'cash on delivey':
  7. * its fee depend on total sum
  8. *
  9. * @version $Id: ps_cashondel.php 1095 2007-12-19 20:19:16Z soeren_nb $
  10. * @package VirtueMart
  11. * @subpackage payment
  12. * @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
  13. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  14. * VirtueMart is free software. This version may have been modified pursuant
  15. * to the GNU General Public License, and as distributed it includes or
  16. * is derivative of works licensed under the GNU General Public License or
  17. * other free or open source software licenses.
  18. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
  19. *
  20. * http://virtuemart.net
  21. */
  22. class ps_cashondel {
  23. var $classname = "ps_cashondel";
  24. var $payment_code = "PU";
  25. /**
  26. * Show all configuration parameters for this payment method
  27. * @returns boolean False when the Payment method has no configration
  28. */
  29. function show_configuration() {
  30. global $VM_LANG;
  31. /** Read current Configuration ***/
  32. require_once(CLASSPATH ."payment/".$this->classname.".cfg.php");
  33. echo $VM_LANG->_('PHPSHOP_SPEC_CASH_ON_DELIVER_RATES');
  34. ?>
  35. <table>
  36. <tr>
  37. <td align="center"><b><?=$VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL')?></b></td>
  38. <td align="center"><b><?=$VM_LANG->_('PHPSHOP_PAYMENT_METHOD_LIST_FEE')?></b></td>
  39. </tr>
  40. <tr>
  41. <td><strong>5000</strong> =></td>
  42. <td>
  43. <input type="text" name="CASH_ON_DEL_5000" class="inputbox" value="<? echo CASH_ON_DEL_5000 ?>" />
  44. </td>
  45. </tr>
  46. <tr>
  47. <td><strong>10000</strong> =></td>
  48. <td>
  49. <input type="text" name="CASH_ON_DEL_10000" class="inputbox" value="<? echo CASH_ON_DEL_10000 ?>" />
  50. </td>
  51. </tr>
  52. <tr>
  53. <td><strong>20000</strong> =></td>
  54. <td>
  55. <input type="text" name="CASH_ON_DEL_20000" class="inputbox" value="<? echo CASH_ON_DEL_20000 ?>" />
  56. </td>
  57. </tr>
  58. <tr>
  59. <td><strong>30000</strong> =></td>
  60. <td>
  61. <input type="text" name="CASH_ON_DEL_30000" class="inputbox" value="<? echo CASH_ON_DEL_30000 ?>" />
  62. </td>
  63. </tr>
  64. <tr>
  65. <td><strong>40000</strong> =></td>
  66. <td>
  67. <input type="text" name="CASH_ON_DEL_40000" class="inputbox" value="<? echo CASH_ON_DEL_40000 ?>" />
  68. </td>
  69. </tr>
  70. <tr>
  71. <td><strong>50000</strong> =></td>
  72. <td>
  73. <input type="text" name="CASH_ON_DEL_50000" class="inputbox" value="<? echo CASH_ON_DEL_50000 ?>" />
  74. </td>
  75. </tr>
  76. <tr>
  77. <td><strong>100000</strong> =></td>
  78. <td>
  79. <input type="text" name="CASH_ON_DEL_100000" class="inputbox" value="<? echo CASH_ON_DEL_100000 ?>" />
  80. </td>
  81. </tr>
  82. </table>
  83. <?php
  84. }
  85. function has_configuration() {
  86. // return false if there's no configuration
  87. return true;
  88. }
  89. /**
  90. * Returns the "is_writeable" status of the configuration file
  91. * @param void
  92. * @returns boolean True when the configuration file is writeable, false when not
  93. */
  94. function configfile_writeable() {
  95. return is_writeable( CLASSPATH."payment/".$this->classname.".cfg.php" );
  96. }
  97. /**
  98. * Returns the "is_readable" status of the configuration file
  99. * @param void
  100. * @returns boolean True when the configuration file is writeable, false when not
  101. */
  102. function configfile_readable() {
  103. return is_readable( CLASSPATH."payment/".$this->classname.".cfg.php" );
  104. }
  105. /**
  106. * Writes the configuration file for this payment method
  107. * @param array An array of objects
  108. * @returns boolean True when writing was successful
  109. */
  110. function write_configuration( &$d ) {
  111. $my_config_array = array("CASH_ON_DEL_5000" => $d['CASH_ON_DEL_5000'],
  112. "CASH_ON_DEL_10000" => $d['CASH_ON_DEL_10000'],
  113. "CASH_ON_DEL_20000" => $d['CASH_ON_DEL_20000'],
  114. "CASH_ON_DEL_30000" => $d['CASH_ON_DEL_30000'],
  115. "CASH_ON_DEL_40000" => $d['CASH_ON_DEL_40000'],
  116. "CASH_ON_DEL_50000" => $d['CASH_ON_DEL_50000'],
  117. "CASH_ON_DEL_100000" => $d['CASH_ON_DEL_100000'],
  118. );
  119. $config = "<?php\n";
  120. $config .= "if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); \n\n";
  121. foreach( $my_config_array as $key => $value ) {
  122. $config .= "define ('$key', '$value');\n";
  123. }
  124. $config .= "?>";
  125. if ($fp = fopen(CLASSPATH ."payment/".$this->classname.".cfg.php", "w")) {
  126. fputs($fp, $config, strlen($config));
  127. fclose ($fp);
  128. return true;
  129. }
  130. else
  131. return false;
  132. }
  133. function get_payment_rate($sum)
  134. {
  135. /*** Get the Configuration File ***/
  136. require_once(CLASSPATH ."payment/".$this->classname.".cfg.php");
  137. if ($sum < 5000)
  138. return -(CASH_ON_DEL_5000);
  139. elseif ($sum < 10000)
  140. return -(CASH_ON_DEL_10000);
  141. elseif ($sum < 20000)
  142. return -(CASH_ON_DEL_20000);
  143. elseif ($sum < 30000)
  144. return -(CASH_ON_DEL_30000);
  145. elseif ($sum < 40000)
  146. return -(CASH_ON_DEL_40000);
  147. elseif ($sum < 50000)
  148. return -(CASH_ON_DEL_50000);
  149. elseif ($sum < 100000)
  150. return -(CASH_ON_DEL_100000);
  151. else
  152. return -(CASH_ON_DEL_100000);
  153. // return -($sum * 0.10);
  154. }
  155. /**************************************************************************
  156. ** name: process_payment()
  157. ** returns:
  158. ***************************************************************************/
  159. function process_payment($order_number, $order_total, &$d) {
  160. //echo "process_payment $order_number $order_total ";
  161. return true;
  162. }
  163. }