|
1 | 1 | <?php
|
2 | 2 | /*
|
3 |
| - * Copyright (c) 2022 PayGate (Pty) Ltd |
| 3 | + * Copyright (c) 2024 Payfast (Pty) Ltd |
4 | 4 | *
|
5 | 5 | * Author: App Inlet (Pty) Ltd
|
6 | 6 | *
|
7 | 7 | * Released under the GNU General Public License
|
8 | 8 | */
|
9 | 9 |
|
10 |
| -if ( ! defined('AREA')) { |
| 10 | +if (!defined('AREA')) { |
11 | 11 | die('Direct Access Denied');
|
12 | 12 | }
|
13 | 13 |
|
14 | 14 | const PAYGATE_SCRIPT = 'paygate.php';
|
15 | 15 |
|
16 |
| -if ( ! defined('PAYMENT_NOTIFICATION')) { |
| 16 | +if (!defined('PAYMENT_NOTIFICATION')) { |
17 | 17 | $user_id = $_SESSION['auth']['user_id'];
|
18 | 18 |
|
19 | 19 | $pw3_paymethod = 'pw3_cc';
|
20 | 20 | $set_paymethod = false;
|
21 | 21 | 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); |
23 | 23 | $set_paymethod = true;
|
24 | 24 | }
|
25 | 25 | $current_url = isset($_SERVER['HTTPS']) ? 'https://' : 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
|
37 | 37 | $form['date'] = date('d-m-Y H:i');
|
38 | 38 | $form['email'] = $order_info['email'];
|
39 | 39 | $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); |
43 | 45 | $initiateFields = array(
|
44 | 46 | 'PAYGATE_ID' => $form['id'],
|
45 | 47 | 'REFERENCE' => $form['reference'],
|
|
76 | 78 | break;
|
77 | 79 | case 'pw3_scantopay':
|
78 | 80 | $initiateFields['PAY_METHOD'] = 'EW';
|
79 |
| - $initiateFields['PAY_METHOD_DETAIL'] = 'ScanToPay'; |
| 81 | + $initiateFields['PAY_METHOD_DETAIL'] = 'MasterPass'; |
80 | 82 | break;
|
81 | 83 | case 'pw3_snapscan':
|
82 | 84 | $initiateFields['PAY_METHOD'] = 'EW';
|
|
86 | 88 | $initiateFields['PAY_METHOD'] = 'EW';
|
87 | 89 | $initiateFields['PAY_METHOD_DETAIL'] = 'PayPal';
|
88 | 90 | 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; |
89 | 103 | default:
|
90 | 104 | break;
|
91 | 105 | }
|
|
106 | 120 | curl_close($curl);
|
107 | 121 | parse_str($response, $responseFields);
|
108 | 122 | echo <<<HTML
|
109 |
| -<p>Kindly wait while you're redirected to PayGate ...</p> |
| 123 | +<p>Kindly wait while you're redirected to Paygate ...</p> |
110 | 124 | <form action="https://secure.paygate.co.za/payweb3/process.trans" method="post" name="redirect">
|
111 | 125 | <input name="PAY_REQUEST_ID" type="hidden" value="{$responseFields['PAY_REQUEST_ID']}" />
|
112 | 126 | <input name="CHECKSUM" type="hidden" value="{$responseFields['CHECKSUM']}" />
|
|
125 | 139 | $status = $_POST['TRANSACTION_STATUS'];
|
126 | 140 | if ($status == 1 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) {
|
127 | 141 | $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'; |
129 | 143 | $pp_response['transaction_id'] = '';
|
130 | 144 | } elseif ($status == 2 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) {
|
131 | 145 | $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'; |
133 | 147 | } elseif ($status == 4 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) {
|
134 | 148 | $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'; |
136 | 150 | } else {
|
137 | 151 | $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'; |
139 | 153 | }
|
140 | 154 | fn_finish_payment($order_id, $pp_response, false);
|
141 | 155 | fn_order_placement_routines('route', $order_id);
|
|
155 | 169 | $paygate_data = array();
|
156 | 170 | $notify_data = array();
|
157 | 171 | // Get notify data
|
158 |
| - if ( ! $errors) { |
| 172 | + if (!$errors) { |
159 | 173 | $nData = $_POST;
|
160 | 174 |
|
161 | 175 | // Strip any slashes in data
|
|
176 | 190 |
|
177 | 191 | // Verify security signature
|
178 | 192 | $checkSumParams = '';
|
179 |
| - if ( ! $errors) { |
| 193 | + if (!$errors) { |
180 | 194 | foreach ($paygate_data as $key => $val) {
|
181 | 195 | $notify_data[$key] = stripslashes($val);
|
182 | 196 |
|
|
195 | 209 | }
|
196 | 210 |
|
197 | 211 | // Verify security signature
|
198 |
| - if ( ! $errors) { |
| 212 | + if (!$errors) { |
199 | 213 | $checkSumParams = md5($checkSumParams);
|
200 | 214 | if ($checkSumParams != $paygate_data['CHECKSUM']) {
|
201 | 215 | $errors = true;
|
|
206 | 220 | }
|
207 | 221 | }
|
208 | 222 | $status = $_POST['TRANSACTION_STATUS'];
|
209 |
| - if ( ! $errors) { |
| 223 | + if (!$errors) { |
210 | 224 | if ($status == 1) {
|
211 | 225 | $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'; |
213 | 227 | $pp_response['transaction_id'] = '';
|
214 | 228 | } elseif ($status == 2) {
|
215 | 229 | $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'; |
217 | 231 | } elseif ($status == 4) {
|
218 | 232 | $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( |
220 | 234 | 'text_transaction_cancelled'
|
221 | 235 | );
|
222 | 236 | } else {
|
223 | 237 | $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'; |
225 | 239 | }
|
226 | 240 | }
|
227 | 241 | fn_finish_payment($order_id, $pp_response, false);
|
|
0 commit comments