PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/Shigaru/shigaru
PHP | 211 lines | 181 code | 5 blank | 25 comment | 7 complexity | 96a64005c9fa6eeb73eba6633e457f6b MD5 | raw file
  1. <?php
  2. if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
  3. /**
  4. *
  5. * @version $Id: ps_ipayment.php 1675 2009-03-04 19:29:03Z soeren_nb $
  6. * @package VirtueMart
  7. * @subpackage payment
  8. * @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  10. * VirtueMart is free software. This version may have been modified pursuant
  11. * to the GNU General Public License, and as distributed it includes or
  12. * is derivative of works licensed under the GNU General Public License or
  13. * other free or open source software licenses.
  14. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
  15. *
  16. * http://virtuemart.net
  17. */
  18. /**
  19. * This class implements the configuration panel for paypal
  20. * If you want to change something "internal", you must modify the 'payment extra info'
  21. * in the payment method form of the PayPal payment method
  22. */
  23. class ps_ipayment {
  24. /**
  25. * Show all configuration parameters for this payment method
  26. * @returns boolean False when the Payment method has no configration
  27. */
  28. function show_configuration() {
  29. global $VM_LANG;
  30. $db = new ps_DB();
  31. /** Read current Configuration ***/
  32. include_once(CLASSPATH ."payment/".__CLASS__.".cfg.php");
  33. ?>
  34. <table class="adminform">
  35. <tr class="row0">
  36. <td><strong>Account/Händler ID</strong></td>
  37. <td>
  38. <input name="IPAYMENT_ACCOUNTID" class="inputbox" type="text" value="<?php echo IPAYMENT_ACCOUNTID ?>" />
  39. </td>
  40. <td>
  41. <?php echo vmToolTip( 'Ihre allgemeine Händler-ID (die Sie auch zum Login in den Administratorbereich bei iPayment verwenden)' ) ?>
  42. </td>
  43. </tr>
  44. <tr class="row1">
  45. <td><strong>Anwendungs-ID/ User-ID </strong></td>
  46. <td>
  47. <input type="text" name="IPAYMENT_APPID" class="inputbox" value="<?php echo IPAYMENT_APPID ?>" />
  48. </td>
  49. <td>
  50. </td>
  51. </tr>
  52. <tr class="row0">
  53. <td><strong>Anwendungs-Passwort/ Transaktionsuser-Passwort</strong></td>
  54. <td>
  55. <input type="text" name="IPAYMENT_APP_PASSWORD" class="inputbox" value="<?php echo IPAYMENT_APP_PASSWORD ?>" />
  56. </td>
  57. <td>
  58. </td>
  59. </tr>
  60. <tr class="row1">
  61. <td><strong>Aktions-Passwort</strong></td>
  62. <td>
  63. <input type="text" name="IPAYMENT_ACTION_PASSWORD" class="inputbox" value="<?php echo IPAYMENT_ACTION_PASSWORD ?>" />
  64. </td>
  65. <td>
  66. </td>
  67. </tr>
  68. <tr class="row0">
  69. <td><strong>Transaktions-Security-Key</strong></td>
  70. <td>
  71. <input type="text" name="IPAYMENT_SECRET" class="inputbox" value="<?php echo IPAYMENT_SECRET ?>" />
  72. </td>
  73. <td>
  74. </td>
  75. </tr>
  76. <tr class="row1">
  77. <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYPAL_STATUS_SUCCESS') ?></strong></td>
  78. <td>
  79. <select name="IPAYMENT_VERIFIED_STATUS" class="inputbox" >
  80. <?php
  81. $q = "SELECT order_status_name,order_status_code FROM #__{vm}_order_status ORDER BY list_order";
  82. $db->query($q);
  83. $order_status_code = Array();
  84. $order_status_name = Array();
  85. while ($db->next_record()) {
  86. $order_status_code[] = $db->f("order_status_code");
  87. $order_status_name[] = $db->f("order_status_name");
  88. }
  89. for ($i = 0; $i < sizeof($order_status_code); $i++) {
  90. echo "<option value=\"" . $order_status_code[$i];
  91. if (IPAYMENT_VERIFIED_STATUS == $order_status_code[$i])
  92. echo "\" selected=\"selected\">";
  93. else
  94. echo "\">";
  95. echo $order_status_name[$i] . "</option>\n";
  96. }?>
  97. </select>
  98. </td>
  99. <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYPAYL_STATUS_SUCCESS_EXPLAIN') ?>
  100. </td>
  101. </tr>
  102. <tr class="row0">
  103. <td><strong><?php echo $VM_LANG->_('VM_ADMIN_CFG_PAYPAL_STATUS_PENDING') ?></strong></td>
  104. <td>
  105. <select name="IPAYMENT_PENDING_STATUS" class="inputbox" >
  106. <?php
  107. for ($i = 0; $i < sizeof($order_status_code); $i++) {
  108. echo "<option value=\"" . $order_status_code[$i];
  109. if (IPAYMENT_PENDING_STATUS == $order_status_code[$i])
  110. echo "\" selected=\"selected\">";
  111. else
  112. echo "\">";
  113. echo $order_status_name[$i] . "</option>\n";
  114. } ?>
  115. </select>
  116. </td>
  117. <td><?php echo $VM_LANG->_('VM_ADMIN_CFG_PAYPAL_STATUS_PENDING_EXPLAIN') ?></td>
  118. </tr>
  119. <tr class="row1">
  120. <td><strong><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYPAL_STATUS_FAILED') ?></strong></td>
  121. <td>
  122. <select name="IPAYMENT_INVALID_STATUS" class="inputbox" >
  123. <?php
  124. for ($i = 0; $i < sizeof($order_status_code); $i++) {
  125. echo "<option value=\"" . $order_status_code[$i];
  126. if (IPAYMENT_INVALID_STATUS == $order_status_code[$i])
  127. echo "\" selected=\"selected\">";
  128. else
  129. echo "\">";
  130. echo $order_status_name[$i] . "</option>\n";
  131. } ?>
  132. </select>
  133. </td>
  134. <td><?php echo $VM_LANG->_('PHPSHOP_ADMIN_CFG_PAYPAL_STATUS_FAILED_EXPLAIN') ?>
  135. </td>
  136. </tr>
  137. </table>
  138. <?php
  139. }
  140. function has_configuration() {
  141. // return false if there's no configuration
  142. return true;
  143. }
  144. /**
  145. * Returns the "is_writeable" status of the configuration file
  146. * @param void
  147. * @returns boolean True when the configuration file is writeable, false when not
  148. */
  149. function configfile_writeable() {
  150. return is_writeable( CLASSPATH."payment/".__CLASS__.".cfg.php" );
  151. }
  152. /**
  153. * Returns the "is_readable" status of the configuration file
  154. * @param void
  155. * @returns boolean True when the configuration file is writeable, false when not
  156. */
  157. function configfile_readable() {
  158. return is_readable( CLASSPATH."payment/".__CLASS__.".cfg.php" );
  159. }
  160. /**
  161. * Writes the configuration file for this payment method
  162. * @param array An array of objects
  163. * @returns boolean True when writing was successful
  164. */
  165. function write_configuration( &$d ) {
  166. $my_config_array = array(
  167. "IPAYMENT_ACCOUNTID" => $d['IPAYMENT_ACCOUNTID'],
  168. "IPAYMENT_APPID" => $d['IPAYMENT_APPID'],
  169. "IPAYMENT_APP_PASSWORD" => $d['IPAYMENT_APP_PASSWORD'],
  170. "IPAYMENT_ACTION_PASSWORD" => $d['IPAYMENT_ACTION_PASSWORD'],
  171. "IPAYMENT_SECRET" => $d['IPAYMENT_SECRET'],
  172. "IPAYMENT_VERIFIED_STATUS" => $d['IPAYMENT_VERIFIED_STATUS'],
  173. "IPAYMENT_PENDING_STATUS" => $d['IPAYMENT_PENDING_STATUS'],
  174. "IPAYMENT_INVALID_STATUS" => $d['IPAYMENT_INVALID_STATUS']
  175. );
  176. $config = "<?php\n";
  177. $config .= "if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); \n\n";
  178. foreach( $my_config_array as $key => $value ) {
  179. $config .= "define ('$key', '$value');\n";
  180. }
  181. $config .= "?>";
  182. if ($fp = fopen(CLASSPATH ."payment/".__CLASS__.".cfg.php", "w")) {
  183. fputs($fp, $config, strlen($config));
  184. fclose ($fp);
  185. return true;
  186. }
  187. else
  188. return false;
  189. }
  190. /**************************************************************************
  191. ** name: process_payment()
  192. ** returns:
  193. ***************************************************************************/
  194. function process_payment($order_number, $order_total, &$d) {
  195. return true;
  196. }
  197. }