Skip to content

Commit 7dcbc4a

Browse files
Merge pull request #5 from appinlet/release/1.0.4
Release/1.0.4
2 parents b458979 + fba5ff0 commit 7dcbc4a

File tree

10 files changed

+242
-92
lines changed

10 files changed

+242
-92
lines changed

README.md

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# PayWeb_CSCart
2-
## PayGate CS-Cart plugin v1.0.3 for CS-Cart 4.13.2
32

4-
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.
3+
## Paygate CS-Cart plugin v1.0.4 for CS-Cart 4.18.1
4+
5+
This is the Paygate plugin for CS-Cart. Please feel free to contact the Payfast support team at support@payfast.help
6+
should you require any assistance.
57

68
## Installation
7-
[![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")
89

9-
Please navigate to the [releases page](https://github.com/PayGate/PayWeb_CSCart/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.
10+
[![How To Setup Paygate 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 for CS-Cart")
11+
12+
Please navigate to the [releases page](https://github.com/Paygate/PayWeb_CSCart/releases), download the latest release (
13+
v1.0.4) and unzip. You will then be able to follow the integration guide PDF which is included in the zip.
1014

1115
## Collaboration
1216

1317
Please submit pull requests with any tweaks, features or fixes you would like to share.
14-
15-
## About PayWeb
16-
17-
[PayWeb](https://www.paygate.co.za/paygate-products/payweb/) is an easy and secure way to accept payments online. The Customer makes payments using [PayGate’s](https://www.paygate.co.za/) secure hosted payment page. PayWeb is mobile-friendly making it compatible across all mobile devices. By selecting PayWeb, the Merchant gets immediate access to an array of Payment Methods, making it easier to get paid.

changelog.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Date : Version: Description
33
=====================================
44

5+
2024-08-27: v1.0.4 : Add RCS, Samsung Pay and Apple Pay payment method options.
6+
Test on CS-Cart 4.18.1.
7+
Bug fixes and improvements.
8+
59
2022-01-05: v1.0.3 : Fix cart lost on failed payments.
610
Change Masterpass to Scan to Pay.
711

@@ -11,9 +15,3 @@ Date : Version: Description
1115
2021-01-03: v1.0.1 : Big fixes and improvements.
1216

1317
2017-12-14: v1.0.0 : Initial commit.
14-
15-
16-
17-
18-
19-

paygate/app/addons/paygate/addon.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<!--
33
/*
4-
* Copyright (c) 2022 PayGate (Pty) Ltd
4+
* Copyright (c) 2024 Payfast (Pty) Ltd
55
*
66
* Author: App Inlet (Pty) Ltd
77
*
@@ -10,9 +10,9 @@
1010
-->
1111
<addon scheme="3.0" edition_type="ROOT,ULT:VENDOR">
1212
<id>paygate</id>
13-
<name>PayGate Payment Gateway</name>
14-
<description>PayGate Payment Gateway</description>
15-
<version>1.0.3</version>
13+
<name>Paygate Payment Gateway</name>
14+
<description>Paygate Payment Gateway</description>
15+
<version>1.0.4</version>
1616
<default_language>en</default_language>
1717
<priority>1000</priority>
1818
<status>active</status>

paygate/app/addons/paygate/func.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?php
22
/*
3-
* Copyright (c) 2022 PayGate (Pty) Ltd
3+
* Copyright (c) 2024 Payfast (Pty) Ltd
44
*
55
* Author: App Inlet (Pty) Ltd
66
*
77
* Released under the GNU General Public License
88
*/
99

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

1414
function fn_paygate_install()
1515
{
1616
db_query("DELETE FROM ?:payment_processors WHERE processor_script = ?s", "paygate.php");
1717
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')"
18+
"INSERT INTO ?:payment_processors (`processor`, `processor_script`, `processor_template`, `admin_template`, `callback`, `type`, `addon`) VALUES ('Paygate', 'paygate.php', 'views/orders/components/payments/paygate.tpl', 'paygate.tpl', 'Y', 'P', 'paygate')"
1919
);
2020
}
2121

@@ -26,17 +26,17 @@ function fn_paygate_uninstall()
2626

2727
function fn_process_paygate_ipn($order_id, $data)
2828
{
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;
29+
$order_info = fn_get_order_info($order_id, true);
30+
$status_completed = $order_info['payment_method']['processor_params']['status']['completed'] ?? 'P';
31+
$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;
4040
if ($wcRefNo == trim($order_prefix . @$order_info['order_id']) && $wcTotal == $wcPrice && $wcStatus != '') {
4141
$orderStatus = $wcStatus == 'YES' ? $status_completed : $status_failed;
4242
} else {

paygate/app/addons/paygate/payments/paygate.php

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?php
22
/*
3-
* Copyright (c) 2022 PayGate (Pty) Ltd
3+
* Copyright (c) 2024 Payfast (Pty) Ltd
44
*
55
* Author: App Inlet (Pty) Ltd
66
*
77
* Released under the GNU General Public License
88
*/
99

10-
if ( ! defined('AREA')) {
10+
if (!defined('AREA')) {
1111
die('Direct Access Denied');
1212
}
1313

1414
const PAYGATE_SCRIPT = 'paygate.php';
1515

16-
if ( ! defined('PAYMENT_NOTIFICATION')) {
16+
if (!defined('PAYMENT_NOTIFICATION')) {
1717
$user_id = $_SESSION['auth']['user_id'];
1818

1919
$pw3_paymethod = 'pw3_cc';
2020
$set_paymethod = false;
2121
if (isset($_POST['pw3_paymethods'])) {
22-
$pw3_paymethod = filter_var($_POST['pw3_paymethods'], FILTER_SANITIZE_STRING);
22+
$pw3_paymethod = filter_var($_POST['pw3_paymethods'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
2323
$set_paymethod = true;
2424
}
2525
$current_url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
@@ -37,9 +37,11 @@
3737
$form['date'] = date('d-m-Y H:i');
3838
$form['email'] = $order_info['email'];
3939
$country_code3 = db_get_field('SELECT code_A3 FROM ?:countries WHERE code=?s', $order_info['b_country']);
40-
$return_url = fn_url( "payment_notification.return?payment=paygate&order_id=$order_id&s=$user_id" );
41-
$notify_url = fn_url( "payment_notification.notify&payment=paygate&order_id=$order_id&s=$user_id" );
42-
$p_order_id = trim( $wc_data['order_prefix'] ) . ( ( $order_info['repaid'] ) ? ( $order_id . '_' . $order_info['repaid'] ) : $order_id );
40+
$return_url = fn_url("payment_notification.return?payment=paygate&order_id=$order_id&s=$user_id");
41+
$notify_url = fn_url("payment_notification.notify&payment=paygate&order_id=$order_id&s=$user_id");
42+
$p_order_id = trim(
43+
$processor_data['processor_params']['order_prefix']
44+
) . (($order_info['repaid']) ? ($order_id . '_' . $order_info['repaid']) : $order_id);
4345
$initiateFields = array(
4446
'PAYGATE_ID' => $form['id'],
4547
'REFERENCE' => $form['reference'],
@@ -76,7 +78,7 @@
7678
break;
7779
case 'pw3_scantopay':
7880
$initiateFields['PAY_METHOD'] = 'EW';
79-
$initiateFields['PAY_METHOD_DETAIL'] = 'ScanToPay';
81+
$initiateFields['PAY_METHOD_DETAIL'] = 'MasterPass';
8082
break;
8183
case 'pw3_snapscan':
8284
$initiateFields['PAY_METHOD'] = 'EW';
@@ -86,6 +88,18 @@
8688
$initiateFields['PAY_METHOD'] = 'EW';
8789
$initiateFields['PAY_METHOD_DETAIL'] = 'PayPal';
8890
break;
91+
case 'pw3_rcs':
92+
$initiateFields['PAY_METHOD'] = 'CC';
93+
$initiateFields['PAY_METHOD_DETAIL'] = 'RCS';
94+
break;
95+
case 'pw3_applepay':
96+
$initiateFields['PAY_METHOD'] = 'CC';
97+
$initiateFields['PAY_METHOD_DETAIL'] = 'Applepay';
98+
break;
99+
case 'pw3_samsungpay':
100+
$initiateFields['PAY_METHOD'] = 'EW';
101+
$initiateFields['PAY_METHOD_DETAIL'] = 'Samsungpay';
102+
break;
89103
default:
90104
break;
91105
}
@@ -106,7 +120,7 @@
106120
curl_close($curl);
107121
parse_str($response, $responseFields);
108122
echo <<<HTML
109-
<p>Kindly wait while you're redirected to PayGate ...</p>
123+
<p>Kindly wait while you're redirected to Paygate ...</p>
110124
<form action="https://secure.paygate.co.za/payweb3/process.trans" method="post" name="redirect">
111125
<input name="PAY_REQUEST_ID" type="hidden" value="{$responseFields['PAY_REQUEST_ID']}" />
112126
<input name="CHECKSUM" type="hidden" value="{$responseFields['CHECKSUM']}" />
@@ -125,17 +139,17 @@
125139
$status = $_POST['TRANSACTION_STATUS'];
126140
if ($status == 1 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) {
127141
$pp_response['order_status'] = 'P';
128-
$pp_response['reason_text'] = 'PayGate Redirect Response: The User Completed Payment with PayGate';
142+
$pp_response['reason_text'] = 'Paygate Redirect Response: The User Completed Payment with Paygate';
129143
$pp_response['transaction_id'] = '';
130144
} elseif ($status == 2 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) {
131145
$pp_response['order_status'] = 'D';
132-
$pp_response['reason_text'] = 'PayGate Redirect Response: Transaction was declined by the payment processor';
146+
$pp_response['reason_text'] = 'Paygate Redirect Response: Transaction was declined by the payment processor';
133147
} elseif ($status == 4 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) {
134148
$pp_response['order_status'] = 'I';
135-
$pp_response['reason_text'] = 'PayGate Redirect Response: User has cancelled payment';
149+
$pp_response['reason_text'] = 'Paygate Redirect Response: User has cancelled payment';
136150
} else {
137151
$pp_response['order_status'] = 'F';
138-
$pp_response['reason_text'] = 'PayGate Redirect Response: Your Payment has failed';
152+
$pp_response['reason_text'] = 'Paygate Redirect Response: Your Payment has failed';
139153
}
140154
fn_finish_payment($order_id, $pp_response, false);
141155
fn_order_placement_routines('route', $order_id);
@@ -155,7 +169,7 @@
155169
$paygate_data = array();
156170
$notify_data = array();
157171
// Get notify data
158-
if ( ! $errors) {
172+
if (!$errors) {
159173
$nData = $_POST;
160174

161175
// Strip any slashes in data
@@ -176,7 +190,7 @@
176190

177191
// Verify security signature
178192
$checkSumParams = '';
179-
if ( ! $errors) {
193+
if (!$errors) {
180194
foreach ($paygate_data as $key => $val) {
181195
$notify_data[$key] = stripslashes($val);
182196

@@ -195,7 +209,7 @@
195209
}
196210

197211
// Verify security signature
198-
if ( ! $errors) {
212+
if (!$errors) {
199213
$checkSumParams = md5($checkSumParams);
200214
if ($checkSumParams != $paygate_data['CHECKSUM']) {
201215
$errors = true;
@@ -206,22 +220,22 @@
206220
}
207221
}
208222
$status = $_POST['TRANSACTION_STATUS'];
209-
if ( ! $errors) {
223+
if (!$errors) {
210224
if ($status == 1) {
211225
$pp_response['order_status'] = 'P';
212-
$pp_response['reason_text'] = 'PayGate Notify Response: The User Completed Payment with PayGate';
226+
$pp_response['reason_text'] = 'Paygate Notify Response: The User Completed Payment with Paygate';
213227
$pp_response['transaction_id'] = '';
214228
} elseif ($status == 2) {
215229
$pp_response['order_status'] = 'D';
216-
$pp_response['reason_text'] = 'PayGate Notify Response: Transaction was declined by the payment processor';
230+
$pp_response['reason_text'] = 'Paygate Notify Response: Transaction was declined by the payment processor';
217231
} elseif ($status == 4) {
218232
$pp_response['order_status'] = 'I';
219-
$pp_response["reason_text"] = 'PayGate Notify Response: ' . fn_get_lang_var(
233+
$pp_response["reason_text"] = 'Paygate Notify Response: ' . fn_get_lang_var(
220234
'text_transaction_cancelled'
221235
);
222236
} else {
223237
$pp_response['order_status'] = 'F';
224-
$pp_response['reason_text'] = 'PayGate Notify Response: Your Payment has failed';
238+
$pp_response['reason_text'] = 'Paygate Notify Response: Your Payment has failed';
225239
}
226240
}
227241
fn_finish_payment($order_id, $pp_response, false);

0 commit comments

Comments
 (0)