Skip to content

Commit

Permalink
Merge pull request #2 from appinlet/release/1.0.4
Browse files Browse the repository at this point in the history
2022-06-02 1.0.4
  • Loading branch information
appinlet authored Jun 3, 2022
2 parents f911744 + 5d99371 commit 9558b2b
Show file tree
Hide file tree
Showing 10 changed files with 995 additions and 300 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PayWeb_Zen_Cart
## PayGate Zen Cart plugin v1.0.3 for Zen Cart v1.5.5
## PayGate Zen Cart plugin v1.0.4 for Zen Cart v1.5.7

This is the PayGate PayWeb3 plugin for Zen Cart. Please feel free to contact the PayGate support team at support@paygate.co.za should you require any assistance.

## Installation
[![How To Setup PayGate PayWeb for ZenCart](https://appinlet.com/wp-content/uploads/2021/01/How-To-Setup-PayGate-PayWeb-for-ZenCart.jpg)](http://www.youtube.com/watch?v=AUGkcxVzeFo "How To Setup PayGate PayWeb for ZenCart")

Please navigate to the [releases page](https://github.com/PayGate/PayWeb_Zen_Cart/releases), download the latest release (v1.0.3) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.
Please navigate to the [releases page](https://github.com/PayGate/PayWeb_Zen_Cart/releases), download the latest release (v1.0.4) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Expand Down
7 changes: 7 additions & 0 deletions changelog.txt
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 includes/auto_loaders/overrides/config.paygatepaywebv3.php
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 includes/languages/english/modules/payment/paygatepaywebv3.php
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 includes/modules/pages/declined_transaction/header_php.php
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>');
}
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';
110 changes: 110 additions & 0 deletions includes/modules/paygatepaywebv3_checkout_process.php
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');
}
}
}

Loading

0 comments on commit 9558b2b

Please sign in to comment.