Permalink
Browse files

Update WorldPay Hosted Payment Pages payment module

  • Loading branch information...
1 parent bea6a73 commit 900ca2ebca972a75f8020dc64db6979f2778e2f2 @haraldpdl haraldpdl committed May 28, 2013
@@ -5,95 +5,105 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2010 osCommerce
+ Copyright (c) 2014 osCommerce
Released under the GNU General Public License
*/
- if (isset($HTTP_POST_VARS['M_sid']) && !empty($HTTP_POST_VARS['M_sid'])) {
- chdir('../../../../');
- require ('includes/application_top.php');
+ chdir('../../../../');
+ require ('includes/application_top.php');
- if ($HTTP_POST_VARS['transStatus'] == 'Y') {
- $pass = false;
+ if ( !defined('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_STATUS') || (MODULE_PAYMENT_RBSWORLDPAY_HOSTED_STATUS != 'True') ) {
+ exit;
+ }
+
+ include('includes/languages/' . basename($HTTP_POST_VARS['M_lang']) . '/modules/payment/rbsworldpay_hosted.php');
+ include('includes/modules/payment/rbsworldpay_hosted.php');
+
+ $rbsworldpay_hosted = new rbsworldpay_hosted();
+
+ $error = false;
+
+ if ( !isset($HTTP_GET_VARS['installation']) || ($HTTP_GET_VARS['installation'] != MODULE_PAYMENT_RBSWORLDPAY_HOSTED_INSTALLATION_ID) ) {
+ $error = true;
+ } elseif ( !isset($HTTP_POST_VARS['installation']) || ($HTTP_POST_VARS['installation'] != MODULE_PAYMENT_RBSWORLDPAY_HOSTED_INSTALLATION_ID) ) {
+ $error = true;
+ } elseif ( tep_not_null(MODULE_PAYMENT_RBSWORLDPAY_HOSTED_CALLBACK_PASSWORD) && (!isset($HTTP_POST_VARS['callbackPW']) || ($HTTP_POST_VARS['callbackPW'] != MODULE_PAYMENT_RBSWORLDPAY_HOSTED_CALLBACK_PASSWORD)) ) {
+ $error = true;
+ } elseif ( !isset($HTTP_POST_VARS['transStatus']) || ($HTTP_POST_VARS['transStatus'] != 'Y') ) {
+ $error = true;
+ } elseif ( !isset($HTTP_POST_VARS['M_hash']) || !isset($HTTP_POST_VARS['M_sid']) || !isset($HTTP_POST_VARS['M_cid']) || !isset($HTTP_POST_VARS['cartId']) || !isset($HTTP_POST_VARS['M_lang']) || !isset($HTTP_POST_VARS['amount']) || ($HTTP_POST_VARS['M_hash'] != md5($HTTP_POST_VARS['M_sid'] . $HTTP_POST_VARS['M_cid'] . $HTTP_POST_VARS['cartId'] . $HTTP_POST_VARS['M_lang'] . number_format($HTTP_POST_VARS['amount'], 2) . MODULE_PAYMENT_RBSWORLDPAY_HOSTED_MD5_PASSWORD)) ) {
+ $error = true;
+ }
+
+ if ( $error == false ) {
+ $order_query = tep_db_query("select orders_id, orders_status, currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_POST_VARS['cartId'] . "' and customers_id = '" . (int)$HTTP_POST_VARS['M_cid'] . "'");
+
+ if (!tep_db_num_rows($order_query)) {
+ $error = true;
+ }
+ }
- if (isset($HTTP_POST_VARS['M_hash']) && !empty($HTTP_POST_VARS['M_hash']) && ($HTTP_POST_VARS['M_hash'] == md5($HTTP_POST_VARS['M_sid'] . $HTTP_POST_VARS['M_cid'] . $HTTP_POST_VARS['cartId'] . $HTTP_POST_VARS['M_lang'] . number_format($HTTP_POST_VARS['amount'], 2) . MODULE_PAYMENT_RBSWORLDPAY_HOSTED_MD5_PASSWORD))) {
- $pass = true;
- }
+ if ( $error == true ) {
+ $rbsworldpay_hosted->sendDebugEmail();
- if (isset($HTTP_POST_VARS['callbackPW']) && ($HTTP_POST_VARS['callbackPW'] != MODULE_PAYMENT_RBSWORLDPAY_HOSTED_CALLBACK_PASSWORD)) {
- $pass = false;
- }
+ exit;
+ }
- if (tep_not_null(MODULE_PAYMENT_RBSWORLDPAY_HOSTED_CALLBACK_PASSWORD) && !isset($HTTP_POST_VARS['callbackPW'])) {
- $pass = false;
- }
+ $order = tep_db_fetch_array($order_query);
- if ($pass == true) {
- include('includes/languages/' . basename($HTTP_POST_VARS['M_lang']) . '/modules/payment/rbsworldpay_hosted.php');
+ if ($order['orders_status'] == MODULE_PAYMENT_RBSWORLDPAY_HOSTED_PREPARE_ORDER_STATUS_ID) {
+ $order_status_id = (MODULE_PAYMENT_RBSWORLDPAY_HOSTED_ORDER_STATUS_ID > 0 ? (int)MODULE_PAYMENT_RBSWORLDPAY_HOSTED_ORDER_STATUS_ID : (int)DEFAULT_ORDERS_STATUS_ID);
- $order_query = tep_db_query("select orders_status, currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_POST_VARS['cartId'] . "' and customers_id = '" . (int)$HTTP_POST_VARS['M_cid'] . "'");
- if (tep_db_num_rows($order_query) > 0) {
- $order = tep_db_fetch_array($order_query);
+ tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . $order_status_id . "', last_modified = now() where orders_id = '" . (int)$order['orders_id'] . "'");
- if ($order['orders_status'] == MODULE_PAYMENT_RBSWORLDPAY_HOSTED_PREPARE_ORDER_STATUS_ID) {
- $order_status_id = (MODULE_PAYMENT_RBSWORLDPAY_HOSTED_ORDER_STATUS_ID > 0 ? (int)MODULE_PAYMENT_RBSWORLDPAY_HOSTED_ORDER_STATUS_ID : (int)DEFAULT_ORDERS_STATUS_ID);
+ $sql_data_array = array('orders_id' => $order['orders_id'],
+ 'orders_status_id' => $order_status_id,
+ 'date_added' => 'now()',
+ 'customer_notified' => '0',
+ 'comments' => '');
- tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . $order_status_id . "', last_modified = now() where orders_id = '" . (int)$HTTP_POST_VARS['cartId'] . "'");
+ tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
+ }
- $sql_data_array = array('orders_id' => $HTTP_POST_VARS['cartId'],
- 'orders_status_id' => $order_status_id,
- 'date_added' => 'now()',
- 'customer_notified' => '0',
- 'comments' => 'WorldPay: Transaction Verified');
+ $trans_result = 'WorldPay: Transaction Verified (Callback)' . "\n" .
+ 'Transaction ID: ' . $HTTP_POST_VARS['transId'];
- tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
+ if (MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TESTMODE == 'True') {
+ $trans_result .= "\n" . MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_WARNING_DEMO_MODE;
+ }
- if (MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TESTMODE == 'True') {
- $sql_data_array = array('orders_id' => $HTTP_POST_VARS['cartId'],
- 'orders_status_id' => $order_status_id,
- 'date_added' => 'now()',
- 'customer_notified' => '0',
- 'comments' => MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_WARNING_DEMO_MODE);
+ $sql_data_array = array('orders_id' => $order['orders_id'],
+ 'orders_status_id' => MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TRANSACTIONS_ORDER_STATUS_ID,
+ 'date_added' => 'now()',
+ 'customer_notified' => '0',
+ 'comments' => $trans_result);
- tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
- }
+ tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
?>
-<html>
+<!DOCTYPE html>
+<html <?php echo HTML_PARAMS; ?>>
<head>
-<title><wpdisplay msg=result.success></title>
-<style>
-.pageHeading {
- font-family: Verdana, Arial, sans-serif;
- font-size: 20px;
- font-weight: bold;
- color: #9a9a9a;
-}
-
-.main {
- font-family: Verdana, Arial, sans-serif;
- font-size: 11px;
- line-height: 1.5;
-}
-</style>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" />
+<title><?php echo tep_output_string_protected($oscTemplate->getTitle()); ?></title>
+<meta http-equiv="refresh" content="3; URL=<?php echo tep_href_link(FILENAME_CHECKOUT_PROCESS, tep_session_name() . '=' . $HTTP_POST_VARS['M_sid'] . '&hash=' . $HTTP_POST_VARS['M_hash'], 'SSL', false); ?>">
</head>
<body>
-<p class="pageHeading"><?php echo STORE_NAME; ?></p>
+<h1><?php echo STORE_NAME; ?></h1>
-<p class="main" align="center"><?php echo MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_SUCCESSFUL_TRANSACTION; ?></p>
+<p><?php echo MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_SUCCESSFUL_TRANSACTION; ?></p>
-<form action="<?php echo tep_href_link(FILENAME_CHECKOUT_PROCESS, tep_session_name() . '=' . $HTTP_POST_VARS['M_sid'] . '&hash=' . $HTTP_POST_VARS['hash'], 'SSL', false); ?>" method="post"><p align="center"><input type="submit" value="<?php echo sprintf(MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_CONTINUE_BUTTON, addslashes(STORE_NAME)); ?>" /></p></form>
+<form action="<?php echo tep_href_link(FILENAME_CHECKOUT_PROCESS, tep_session_name() . '=' . $HTTP_POST_VARS['M_sid'] . '&hash=' . $HTTP_POST_VARS['M_hash'], 'SSL', false); ?>" method="post" target="_top">
+ <p><input type="submit" value="<?php echo sprintf(MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_CONTINUE_BUTTON, addslashes(STORE_NAME)); ?>" /></p>
+</form>
<p>&nbsp;</p>
<WPDISPLAY ITEM=banner>
</body>
</html>
+
<?php
- }
- }
- }
- }
- }
+ tep_session_destroy();
?>
@@ -5,15 +5,19 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2010 osCommerce
+ Copyright (c) 2014 osCommerce
Released under the GNU General Public License
*/
- define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_TITLE', 'RBS WorldPay Hosted');
+ define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_TITLE', 'WorldPay Hosted Payment Pages');
define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_PUBLIC_TITLE', 'Credit Card');
- define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_DESCRIPTION', '<img src="images/icon_popup.gif" border="0">&nbsp;<a href="http://www.rbsworldpay.com" target="_blank" style="text-decoration: underline; font-weight: bold;">Visit RBS WorldPay Website</a>');
- define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_WARNING_DEMO_MODE', 'In Review: Transaction performed in demo mode.');
- define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_SUCCESSFUL_TRANSACTION', 'The payment transaction has been successfully performed!');
- define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_CONTINUE_BUTTON', 'Click here to continue to %s');
+ define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_DESCRIPTION', '<img src="images/icon_info.gif" border="0" />&nbsp;<a href="http://library.oscommerce.com/Package&en&worldpay&oscom23&hosted" target="_blank" style="text-decoration: underline; font-weight: bold;">View Online Documentation</a><br /><br /><img src="images/icon_popup.gif" border="0">&nbsp;<a href="http://www.worldpay.com" target="_blank" style="text-decoration: underline; font-weight: bold;">Visit WorldPay Website</a>');
+
+ define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_ERROR_ADMIN_CONFIGURATION', 'This module will not load until the Installation ID parameter has been configured. Please edit and configure the settings of this module.');
+
+ define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_WARNING_DEMO_MODE', 'Transaction performed in test mode.');
+
+ define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_SUCCESSFUL_TRANSACTION', 'The payment has been successfully performed! You will be automatically redirected back to our website in 3 seconds.');
+ define('MODULE_PAYMENT_RBSWORLDPAY_HOSTED_TEXT_CONTINUE_BUTTON', 'Continue to %s');
?>
Oops, something went wrong.

0 comments on commit 900ca2e

Please sign in to comment.