-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from appinlet/release/1.0.4
2022-06-02 1.0.4
- Loading branch information
Showing
10 changed files
with
995 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Date Version Comment | ||
**** ******* ******* | ||
|
||
2022-06-02 1.0.4 Code quality fixes and improvements. | ||
Patch for ZenCart 1.5.7. | ||
|
||
2018-08-24 1.0.3 New release of legacy plugin. |
17 changes: 17 additions & 0 deletions
17
includes/auto_loaders/overrides/config.paygatepaywebv3.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2022 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
|
||
if ( ! defined('IS_ADMIN_FLAG')) { | ||
die('Illegal Access'); | ||
} | ||
|
||
$autoLoadConfig[0][] = array( | ||
'autoType' => 'require', | ||
'loadFile' => DIR_WS_INCLUDES . '/modules/pages/paygatepaywebv3_process/header_php.php' | ||
); |
41 changes: 27 additions & 14 deletions
41
includes/languages/english/modules/payment/paygatepaywebv3.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
<?php | ||
/* | ||
* Copyright (c) 2018 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
define( 'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_TITLE', 'Secure payment using PayGate' ); | ||
define( 'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_DESCRIPTION', '<b>PayWebv3</b><br><br>Credit Card Test Info:<br><br>CC#: 4000000000000002<br>Expiry: 06/2020' ); | ||
define( 'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_ERROR_MESSAGE', 'There has been an error processing your payment. Please try again.' ); | ||
define( 'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_DATA_ERROR', 'There has been an error verifying the merchant data. Please try again.' ); | ||
define( 'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_DECLINED_MESSAGE', 'Your payment could not be authorised for the following reason: ' ); | ||
define( 'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_ERROR', 'Payment Error!' ); | ||
<?php | ||
/** | ||
* Copyright (c) 2022 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
|
||
define('MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_TITLE', 'PayGate'); | ||
define( | ||
'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_DESCRIPTION', | ||
'<b>PayWebv3</b><br><br>Credit Card Test Info:<br><br>CC#: 4000000000000002<br>Expiry: 06/2020' | ||
); | ||
define( | ||
'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_ERROR_MESSAGE', | ||
'There has been an error processing your payment. Please try again.' | ||
); | ||
define( | ||
'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_DATA_ERROR', | ||
'There has been an error verifying the merchant data. Please try again.' | ||
); | ||
define( | ||
'MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_DECLINED_MESSAGE', | ||
'Your payment could not be authorised for the following reason: ' | ||
); | ||
define('MODULE_PAYMENT_PAYGATEPAYWEB3_TEXT_ERROR', 'Payment Error!'); |
35 changes: 18 additions & 17 deletions
35
includes/modules/pages/declined_transaction/header_php.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
<?php | ||
/* | ||
* Copyright (c) 2018 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
$error = empty( $_GET['error'] ) ? '' : filter_var( $_GET['error'], FILTER_SANITIZE_STRING ); | ||
$status = empty( $_GET['status'] ) ? '' : filter_var( $_GET['status'], FILTER_SANITIZE_NUMBER_INT ); | ||
if ( $status == '2' ) { | ||
$breadcrumb->add( '<Strong>Your transaction has been declined</Strong>' ); | ||
} else if ( $status == '10' ) { | ||
$breadcrumb->add( '<Strong>Your transaction has been declined, error: ' . $error . '</Strong>' ); | ||
} else { | ||
$breadcrumb->add( '<Strong>Your transaction has been declined, unknown error</Strong>' ); | ||
} | ||
<?php | ||
/** | ||
* Copyright (c) 2022 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
|
||
$error = empty($_GET['error']) ? '' : filter_var($_GET['error'], FILTER_SANITIZE_STRING); | ||
$status = empty($_GET['status']) ? '' : filter_var($_GET['status'], FILTER_SANITIZE_NUMBER_INT); | ||
if ($status == '2') { | ||
$breadcrumb->add('<Strong>Your transaction has been declined</Strong>'); | ||
} elseif ($status == '10') { | ||
$breadcrumb->add('<Strong>Your transaction has been declined, error: ' . $error . '</Strong>'); | ||
} else { | ||
$breadcrumb->add('<Strong>Your transaction has been declined, unknown error</Strong>'); | ||
} |
44 changes: 44 additions & 0 deletions
44
includes/modules/pages/paygatepaywebv3_checkout_process/header_php.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Checkout Process Page | ||
* | ||
* Modified for PayGate PayWeb3 session issues | ||
* | ||
* Copyright (c) 2022 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
|
||
// This should be first line of the script: | ||
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_PROCESS'); | ||
|
||
require DIR_WS_MODULES . zen_get_module_directory('paygatepaywebv3_checkout_process.php'); | ||
|
||
// load the after_process function from the payment modules | ||
$payment_modules->after_process(); | ||
|
||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEFORE_CART_RESET', $insert_id); | ||
$_SESSION['cart']->reset(true); | ||
|
||
// unregister session variables used during checkout | ||
unset($_SESSION['sendto']); | ||
unset($_SESSION['billto']); | ||
unset($_SESSION['shipping']); | ||
unset($_SESSION['payment']); | ||
unset($_SESSION['comments']); | ||
$order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM | ||
|
||
// This should be before the zen_redirect: | ||
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_PROCESS'); | ||
|
||
zen_redirect( | ||
zen_href_link( | ||
FILENAME_CHECKOUT_SUCCESS, | ||
(isset($_GET['action']) && $_GET['action'] == 'confirm' ? 'action=confirm' : ''), | ||
'SSL' | ||
) | ||
); | ||
|
||
require DIR_WS_INCLUDES . 'application_bottom.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
/** | ||
* Module to process a completed checkout | ||
* | ||
* Copyright (c) 2022 PayGate (Pty) Ltd | ||
* | ||
* Author: App Inlet (Pty) Ltd | ||
* | ||
* Released under the GNU General Public License | ||
*/ | ||
|
||
if ( ! defined('IS_ADMIN_FLAG')) { | ||
// phpcs:disable | ||
die('Illegal Access'); | ||
// phpcs:enable | ||
} | ||
global $zco_notifier; | ||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEGIN'); | ||
|
||
require DIR_WS_MODULES . zen_get_module_directory('require_languages.php'); | ||
|
||
global $db, $currencies; | ||
|
||
if ( ! defined('TABLE_PAYGATEPAYWEBV3')) { | ||
// phpcs:disable | ||
define('TABLE_PAYGATEPAYWEBV3', DB_PREFIX . 'paygatepaywebv3'); | ||
// phpcs:enable | ||
} | ||
|
||
if (isset($_POST) && isset($_POST['PAY_REQUEST_ID'])) { | ||
// Restore session from database | ||
$sql = "select session_data from " . TABLE_PAYGATEPAYWEBV3; | ||
$sql .= " where pay_request_id = :pay_request_id "; | ||
$sql = $db->bindVars($sql, ':pay_request_id', $_POST['PAY_REQUEST_ID'], 'string'); | ||
|
||
$result = $db->Execute($sql); | ||
$session = $result->fields['session_data']; | ||
$_SESSION = unserialize($session); | ||
|
||
// load selected payment module | ||
include DIR_WS_CLASSES . 'payment.php'; | ||
$payment_modules = new payment($_SESSION['payment']); | ||
|
||
include DIR_WS_CLASSES . 'order.php'; | ||
$order = new order; | ||
|
||
// load the selected shipping module | ||
include DIR_WS_CLASSES . 'shipping.php'; | ||
$shipping_modules = new shipping($_SESSION['shipping']); | ||
|
||
// prevent 0-entry orders from being generated/spoofed | ||
if (sizeof($order->products) < 1) { | ||
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART)); | ||
} | ||
|
||
// Check if this payrequest id has already been processed | ||
$sql = "select * from " . TABLE_PAYGATEPAYWEBV3; | ||
$sql .= " where pay_request_id = :pay_request_id"; | ||
$sql = $db->bindVars($sql, ':pay_request_id', $_POST['PAY_REQUEST_ID'], 'string'); | ||
$requests = $db->Execute($sql); | ||
$request = []; | ||
foreach ($requests as $req) { | ||
$request[] = $req; | ||
} | ||
|
||
if ((int)$request[0]['orders_id'] !== 0) { | ||
// Order already exists - check status | ||
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SUCCESS)); | ||
} else { | ||
include DIR_WS_CLASSES . 'order_total.php'; | ||
$order_total_modules = new order_total; | ||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PROCESS'); | ||
$order_totals = $order_total_modules->process(); | ||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_TOTALS_PROCESS'); | ||
|
||
|
||
$pw3 = new PaygatePaywebV3(); | ||
|
||
$processThisOrder = false; | ||
|
||
$validRedirectMethod = ! $pw3->getUseipn(); | ||
$validNotifyMethod = ! isset($_GET['uuid']) && $pw3->getUseipn(); | ||
|
||
if ($validRedirectMethod || $validNotifyMethod) { | ||
$processThisOrder = true; | ||
} | ||
|
||
if ($processThisOrder) { | ||
// Now process order based on response | ||
$pw3->before_process(); | ||
$order_status = $pw3->getOrderStatus(); | ||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_BEFOREPROCESS'); | ||
|
||
// create the order record | ||
$insert_id = $order->create($order_totals, 2); | ||
|
||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE'); | ||
|
||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_AFTER_ORDER_CREATE'); | ||
// store the product info to the order | ||
$order->create_add_products($insert_id); | ||
$_SESSION['order_number_created'] = $insert_id; | ||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS'); | ||
//send email notifications | ||
$order->send_order_email($insert_id, 2); | ||
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL'); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.