Skip to content

Commit

Permalink
Merge pull request #2 from appinlet/release/1.0.2
Browse files Browse the repository at this point in the history
2021-09-27: v1.0.2
  • Loading branch information
appinlet authored Sep 27, 2021
2 parents 1f4f428 + db1fb99 commit 2d8d918
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 113 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PayWeb_CSCart
## PayGate CS-Cart plugin v1.0.1 for CS-Cart 4.7.4
## PayGate CS-Cart plugin v1.0.2 for CS-Cart 4.13.2

This is the PayGate PayWeb3 plugin for CS-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 CS-Cart](https://appinlet.com/wp-content/uploads/2021/01/How-To-Setup-PayGate-PayWeb-for-CS-Cart.jpg)](https://www.youtube.com/watch?v=9Lhvc26WKjs "How To Setup PayGate PayWeb for CS-Cart")

Please navigate to the [releases page](https://github.com/PayGate/PayWeb_CSCart/releases), download the latest release (v1.0.1) 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_CSCart/releases), download the latest release (v1.0.2) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Expand Down
16 changes: 16 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=====================================
Date : Version: Description
=====================================

2021-09-27: v1.0.2 : Add payment types.
Tested with 4.13.2.

2021-01-03: v1.0.1 : Big fixes and improvements.

2017-12-14: v1.0.0 : Initial commit.






15 changes: 12 additions & 3 deletions paygate/app/addons/paygate/addon.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<?xml version="1.0"?>
<!--
/*
* Copyright (c) 2021 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
* Released under the GNU General Public License
*/
-->
<addon scheme="3.0" edition_type="ROOT,ULT:VENDOR">
<id>paygate</id>
<name>PayGate Payment Gateway</name>
<description>PayGate Payment Gateway</description>
<version>1.0.1</version>
<name>PayGate Payment Gateway</name>
<description>PayGate Payment Gateway</description>
<version>1.0.2</version>
<default_language>en</default_language>
<priority>1000</priority>
<status>active</status>
Expand Down
66 changes: 35 additions & 31 deletions paygate/app/addons/paygate/func.php
Original file line number Diff line number Diff line change
@@ -1,59 +1,63 @@
<?php
/*
* Copyright (c) 2018 PayGate (Pty) Ltd
* Copyright (c) 2021 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
*
* Released under the GNU General Public License
*/

if ( !defined( 'BOOTSTRAP' ) ) {
die( 'Access denied' );
if ( ! defined('BOOTSTRAP')) {
die('Access denied');
}

function fn_paygate_install()
{
db_query( "DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php" );
db_query( "INSERT INTO ?:payment_processors (`processor`, `processor_script`, `processor_template`, `admin_template`, `callback`, `type`, `addon`) VALUES ('PayGate (Web)', 'paygate.php', 'views/orders/components/payments/cc_outside.tpl', 'paygate.tpl', 'Y', 'P', 'paygate')" );
db_query("DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php");
db_query(
"INSERT INTO ?:payment_processors (`processor`, `processor_script`, `processor_template`, `admin_template`, `callback`, `type`, `addon`) VALUES ('PayGate (Web)', 'paygate.php', 'views/orders/components/payments/paygate.tpl', 'paygate.tpl', 'Y', 'P', 'paygate')"
);
}

function fn_paygate_uninstall()
{
db_query( "DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php" );
db_query("DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php");
}

function fn_process_paygate_ipn( $order_id, $data )
function fn_process_paygate_ipn($order_id, $data)
{
$order_info = fn_get_order_info( $order_id, true );
$status_completed = isset( $order_info['payment_method']['processor_params']['status']['completed'] ) ? $order_info['payment_method']['processor_params']['status']['completed'] : 'P';
$status_failed = isset( $order_info['payment_method']['processor_params']['status']['failed'] ) ? $order_info['payment_method']['processor_params']['status']['failed'] : 'F';
$wcRefNo = trim( @$data['TM_RefNo'] );
$wcPrice = trim( @$data['TM_DebitAmt'] ) * 1.00;
$wcCurrency = trim( $data['TM_Currency'] );
$wcStatus = strtoupper( trim( $data['TM_Status'] ) );
$wcCode = trim( $data['TM_ApprovalCode'] );
$wcError = trim( trim( trim( $data['TM_Error'] ) . " - " . trim( $data['TM_ErrorMsg'] ) ), '-' );
$order_prefix = trim( $order_info['payment_method']['processor_params']['order_prefix'] );
$wcTotal = fn_format_price( $order_info['total'], $wcCurrency ) * 1.00;
if ( $wcRefNo == trim( $order_prefix . @$order_info['order_id'] ) && $wcTotal == $wcPrice && $wcStatus != '' ) {
$order_info = fn_get_order_info($order_id, true);
$status_completed = isset($order_info['payment_method']['processor_params']['status']['completed']) ? $order_info['payment_method']['processor_params']['status']['completed'] : 'P';
$status_failed = isset($order_info['payment_method']['processor_params']['status']['failed']) ? $order_info['payment_method']['processor_params']['status']['failed'] : 'F';
$wcRefNo = trim(@$data['TM_RefNo']);
$wcPrice = trim(@$data['TM_DebitAmt']) * 1.00;
$wcCurrency = trim($data['TM_Currency']);
$wcStatus = strtoupper(trim($data['TM_Status']));
$wcCode = trim($data['TM_ApprovalCode']);
$wcError = trim(trim(trim($data['TM_Error']) . " - " . trim($data['TM_ErrorMsg'])), '-');
$order_prefix = trim($order_info['payment_method']['processor_params']['order_prefix']);
$wcTotal = fn_format_price($order_info['total'], $wcCurrency) * 1.00;
if ($wcRefNo == trim($order_prefix . @$order_info['order_id']) && $wcTotal == $wcPrice && $wcStatus != '') {
$orderStatus = $wcStatus == 'YES' ? $status_completed : $status_failed;
} else { $orderStatus = $status_failed;}
$data['payment_status'] = ( $wcStatus == 'YES' ) ? 'Completed' : 'Failed';
fn_clear_cart( $cart, true );
$customer_auth = fn_fill_auth( array(), array(), false, 'C' );
fn_form_cart( $order_id, $cart, $customer_auth );
} else {
$orderStatus = $status_failed;
}
$data['payment_status'] = ($wcStatus == 'YES') ? 'Completed' : 'Failed';
fn_clear_cart($cart, true);
$customer_auth = fn_fill_auth(array(), array(), false, 'C');
fn_form_cart($order_id, $cart, $customer_auth);
$cart['payment_info'] = $order_info['payment_info'];
$cart['payment_id'] = $order_info['payment_id'];
if ( $wcStatus == 'YES' ) {
if ($wcStatus == 'YES') {
$cart['payment_info']['txn_id'] = $wcCode;
}
if ( trim( $wcError ) != '' ) {
if (trim($wcError) != '') {
$cart['payment_info']['reason_text'] = $wcError;
}
fn_calculate_cart_content( $cart, $customer_auth );
list( $order_id ) = fn_update_order( $cart, $order_id );
if ( $order_id ) {
fn_change_order_status( $order_id, $orderStatus );
fn_calculate_cart_content($cart, $customer_auth);
list($order_id) = fn_update_order($cart, $order_id);
if ($order_id) {
fn_change_order_status($order_id, $orderStatus);
}
echo 'DONE';
}
Loading

0 comments on commit 2d8d918

Please sign in to comment.