Skip to content

Commit 2d8d918

Browse files
Merge pull request #2 from appinlet/release/1.0.2
2021-09-27: v1.0.2
2 parents 1f4f428 + db1fb99 commit 2d8d918

File tree

15 files changed

+367
-113
lines changed

15 files changed

+367
-113
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# PayWeb_CSCart
2-
## PayGate CS-Cart plugin v1.0.1 for CS-Cart 4.7.4
2+
## PayGate CS-Cart plugin v1.0.2 for CS-Cart 4.13.2
33

44
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.
55

66
## Installation
77
[![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")
88

9-
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.
9+
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.
1010

1111
## Collaboration
1212

changelog.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=====================================
2+
Date : Version: Description
3+
=====================================
4+
5+
2021-09-27: v1.0.2 : Add payment types.
6+
Tested with 4.13.2.
7+
8+
2021-01-03: v1.0.1 : Big fixes and improvements.
9+
10+
2017-12-14: v1.0.0 : Initial commit.
11+
12+
13+
14+
15+
16+

paygate/app/addons/paygate/addon.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
<?xml version="1.0"?>
2+
<!--
3+
/*
4+
* Copyright (c) 2021 PayGate (Pty) Ltd
5+
*
6+
* Author: App Inlet (Pty) Ltd
7+
*
8+
* Released under the GNU General Public License
9+
*/
10+
-->
211
<addon scheme="3.0" edition_type="ROOT,ULT:VENDOR">
312
<id>paygate</id>
4-
<name>PayGate Payment Gateway</name>
5-
<description>PayGate Payment Gateway</description>
6-
<version>1.0.1</version>
13+
<name>PayGate Payment Gateway</name>
14+
<description>PayGate Payment Gateway</description>
15+
<version>1.0.2</version>
716
<default_language>en</default_language>
817
<priority>1000</priority>
918
<status>active</status>

paygate/app/addons/paygate/func.php

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,63 @@
11
<?php
22
/*
3-
* Copyright (c) 2018 PayGate (Pty) Ltd
3+
* Copyright (c) 2021 PayGate (Pty) Ltd
44
*
55
* Author: App Inlet (Pty) Ltd
6-
*
6+
*
77
* Released under the GNU General Public License
88
*/
99

10-
if ( !defined( 'BOOTSTRAP' ) ) {
11-
die( 'Access denied' );
10+
if ( ! defined('BOOTSTRAP')) {
11+
die('Access denied');
1212
}
1313

1414
function fn_paygate_install()
1515
{
16-
db_query( "DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php" );
17-
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')" );
16+
db_query("DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php");
17+
db_query(
18+
"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')"
19+
);
1820
}
1921

2022
function fn_paygate_uninstall()
2123
{
22-
db_query( "DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php" );
24+
db_query("DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php");
2325
}
2426

25-
function fn_process_paygate_ipn( $order_id, $data )
27+
function fn_process_paygate_ipn($order_id, $data)
2628
{
27-
$order_info = fn_get_order_info( $order_id, true );
28-
$status_completed = isset( $order_info['payment_method']['processor_params']['status']['completed'] ) ? $order_info['payment_method']['processor_params']['status']['completed'] : 'P';
29-
$status_failed = isset( $order_info['payment_method']['processor_params']['status']['failed'] ) ? $order_info['payment_method']['processor_params']['status']['failed'] : 'F';
30-
$wcRefNo = trim( @$data['TM_RefNo'] );
31-
$wcPrice = trim( @$data['TM_DebitAmt'] ) * 1.00;
32-
$wcCurrency = trim( $data['TM_Currency'] );
33-
$wcStatus = strtoupper( trim( $data['TM_Status'] ) );
34-
$wcCode = trim( $data['TM_ApprovalCode'] );
35-
$wcError = trim( trim( trim( $data['TM_Error'] ) . " - " . trim( $data['TM_ErrorMsg'] ) ), '-' );
36-
$order_prefix = trim( $order_info['payment_method']['processor_params']['order_prefix'] );
37-
$wcTotal = fn_format_price( $order_info['total'], $wcCurrency ) * 1.00;
38-
if ( $wcRefNo == trim( $order_prefix . @$order_info['order_id'] ) && $wcTotal == $wcPrice && $wcStatus != '' ) {
29+
$order_info = fn_get_order_info($order_id, true);
30+
$status_completed = isset($order_info['payment_method']['processor_params']['status']['completed']) ? $order_info['payment_method']['processor_params']['status']['completed'] : 'P';
31+
$status_failed = isset($order_info['payment_method']['processor_params']['status']['failed']) ? $order_info['payment_method']['processor_params']['status']['failed'] : 'F';
32+
$wcRefNo = trim(@$data['TM_RefNo']);
33+
$wcPrice = trim(@$data['TM_DebitAmt']) * 1.00;
34+
$wcCurrency = trim($data['TM_Currency']);
35+
$wcStatus = strtoupper(trim($data['TM_Status']));
36+
$wcCode = trim($data['TM_ApprovalCode']);
37+
$wcError = trim(trim(trim($data['TM_Error']) . " - " . trim($data['TM_ErrorMsg'])), '-');
38+
$order_prefix = trim($order_info['payment_method']['processor_params']['order_prefix']);
39+
$wcTotal = fn_format_price($order_info['total'], $wcCurrency) * 1.00;
40+
if ($wcRefNo == trim($order_prefix . @$order_info['order_id']) && $wcTotal == $wcPrice && $wcStatus != '') {
3941
$orderStatus = $wcStatus == 'YES' ? $status_completed : $status_failed;
40-
} else { $orderStatus = $status_failed;}
41-
$data['payment_status'] = ( $wcStatus == 'YES' ) ? 'Completed' : 'Failed';
42-
fn_clear_cart( $cart, true );
43-
$customer_auth = fn_fill_auth( array(), array(), false, 'C' );
44-
fn_form_cart( $order_id, $cart, $customer_auth );
42+
} else {
43+
$orderStatus = $status_failed;
44+
}
45+
$data['payment_status'] = ($wcStatus == 'YES') ? 'Completed' : 'Failed';
46+
fn_clear_cart($cart, true);
47+
$customer_auth = fn_fill_auth(array(), array(), false, 'C');
48+
fn_form_cart($order_id, $cart, $customer_auth);
4549
$cart['payment_info'] = $order_info['payment_info'];
4650
$cart['payment_id'] = $order_info['payment_id'];
47-
if ( $wcStatus == 'YES' ) {
51+
if ($wcStatus == 'YES') {
4852
$cart['payment_info']['txn_id'] = $wcCode;
4953
}
50-
if ( trim( $wcError ) != '' ) {
54+
if (trim($wcError) != '') {
5155
$cart['payment_info']['reason_text'] = $wcError;
5256
}
53-
fn_calculate_cart_content( $cart, $customer_auth );
54-
list( $order_id ) = fn_update_order( $cart, $order_id );
55-
if ( $order_id ) {
56-
fn_change_order_status( $order_id, $orderStatus );
57+
fn_calculate_cart_content($cart, $customer_auth);
58+
list($order_id) = fn_update_order($cart, $order_id);
59+
if ($order_id) {
60+
fn_change_order_status($order_id, $orderStatus);
5761
}
5862
echo 'DONE';
5963
}

0 commit comments

Comments
 (0)