PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_virtuemart/html/checkout.2Checkout_result.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 100 lines | 53 code | 12 blank | 35 comment | 13 complexity | 7dee6ab1eec44fe8b30a778f28a4b8f3 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. *
  4. * 2Checkout Order Confirmation Handler
  5. *
  6. * @version $Id: checkout.2Checkout_result.php 1394 2008-05-04 19:05:15Z soeren_nb $
  7. * @package VirtueMart
  8. * @subpackage html
  9. * @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
  10. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  11. * VirtueMart is free software. This version may have been modified pursuant
  12. * to the GNU General Public License, and as distributed it includes or
  13. * is derivative of works licensed under the GNU General Public License or
  14. * other free or open source software licenses.
  15. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
  16. *
  17. * http://virtuemart.net
  18. */
  19. if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
  20. /**
  21. * Read the post from 2Checkout system
  22. * I have used $_REQUEST instead of $_POST, because
  23. * the "direct return" feature comes here using the GET method
  24. * and $_REQUEST includes $_POST as well as $_GET
  25. **/
  26. if( !isset( $_REQUEST["x_invoice_num"] ) || empty( $_REQUEST["x_invoice_num"] ))
  27. echo $VM_LANG->_('VM_CHECKOUT_ORDERIDNOTSET');
  28. else {
  29. /* Load the 2Checkout Configuration File */
  30. require_once( CLASSPATH. 'payment/ps_twocheckout.cfg.php' );
  31. /* x_invoice_num is the name of the variable that holds OUR order_number */
  32. $order_number = vmGet( $_REQUEST, "x_invoice_num" );
  33. // In Demo Mode the MD5 Hash is built using a "1"
  34. if( isset($_REQUEST['demo']) )
  35. if($_REQUEST['demo']== "Y")
  36. $_REQUEST['order_number'] = "1";
  37. /* Concat some variables for MD5 Hashing (like 2Checkout does online)
  38. * order_number is the 2Checkout Order Number, not our one!
  39. */
  40. $compare_string = TWOCO_SECRETWORD . TWOCO_LOGIN . $_REQUEST['order_number'] . $_REQUEST['x_amount'];
  41. // make it md5
  42. $compare_hash1 = strtoupper(md5($compare_string));
  43. $compare_hash2 = $_REQUEST['x_MD5_Hash'];
  44. /* If both hashes are the same, the post should come from 2Checkout */
  45. if ($compare_hash1 != $compare_hash2) {
  46. ?>
  47. <img src="<?php echo VM_THEMEURL ?>images/button_cancel.png" align="middle" alt="<?php echo $VM_LANG->_('VM_CHECKOUT_FAILURE'); ?>" border="0" />
  48. <span class="message"><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_ERROR') ?></span><?php
  49. }
  50. else {
  51. $qv = "SELECT order_id, order_number FROM #__{vm}_orders ";
  52. $qv .= "WHERE order_number='".$order_number."'";
  53. $dbbt = new ps_DB;
  54. $dbbt->query($qv);
  55. $dbbt->next_record();
  56. $d['order_id'] = $dbbt->f("order_id");
  57. if ($_REQUEST['x_response_code'] == '1') {
  58. // UPDATE THE ORDER STATUS to 'VALID'
  59. $d['order_status'] = TWOCO_VERIFIED_STATUS;
  60. require_once ( CLASSPATH . 'ps_order.php' );
  61. $ps_order= new ps_order;
  62. $ps_order->order_status_update($d);
  63. ?>
  64. <img src="<?php echo VM_THEMEURL ?>images/button_ok.png" align="middle" alt="<?php echo $VM_LANG->_('VM_CHECKOUT_SUCCESS'); ?>" border="0" />
  65. <h2><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_TRANSACTION_SUCCESS') ?></h2>
  66. <?php
  67. }
  68. else {
  69. // the Payment wasn't successful. Maybe the Payment couldn't
  70. // be verified and is pending
  71. // UPDATE THE ORDER STATUS to 'INVALID'
  72. $d['order_status'] = TWOCO_INVALID_STATUS;
  73. require_once ( CLASSPATH . 'ps_order.php' );
  74. $ps_order= new ps_order;
  75. $ps_order->order_status_update($d);
  76. ?>
  77. <img src="<?php echo VM_THEMEURL ?>images/button_cancel.png" align="middle" alt="<?php echo $VM_LANG->_('VM_CHECKOUT_FAILURE'); ?>" border="0" />
  78. <h2><?php echo $VM_LANG->_('PHPSHOP_PAYMENT_ERROR') ?></h2>
  79. <?php
  80. }
  81. }
  82. ?>
  83. <br />
  84. <p><a href="<?php @$sess->purl( SECUREURL."index.php?option=com_virtuemart&page=account.order_details&order_id=".$d['order_id'] ) ?>">
  85. <?php echo $VM_LANG->_('PHPSHOP_ORDER_LINK') ?></a>
  86. </p>
  87. <?php
  88. }