From db1fb99b5234b62ebca0a0bd7f90cd9952a24bbf Mon Sep 17 00:00:00 2001 From: Bruce Atkinson Date: Mon, 27 Sep 2021 07:16:22 +0200 Subject: [PATCH] 2021-09-27: v1.0.2 - Add payment types. - Tested with 4.13.2. --- README.md | 4 +- changelog.txt | 16 ++ paygate/app/addons/paygate/addon.xml | 15 +- paygate/app/addons/paygate/func.php | 66 +++--- .../app/addons/paygate/payments/paygate.php | 196 +++++++++++------- .../components/cc_processors/paygate.tpl | 100 ++++++++- .../orders/components/payments/paygate.tpl | 75 +++++++ paygate/images/paygate/mastercard-visa.svg | 1 + paygate/images/paygate/masterpass.svg | 1 + paygate/images/paygate/mobicred.svg | 1 + paygate/images/paygate/momopay.svg | 1 + paygate/images/paygate/paypal.svg | 1 + paygate/images/paygate/sid.svg | 1 + paygate/images/paygate/snapscan.svg | 1 + paygate/images/paygate/zapper.svg | 1 + 15 files changed, 367 insertions(+), 113 deletions(-) create mode 100755 changelog.txt create mode 100644 paygate/design/themes/responsive/templates/views/orders/components/payments/paygate.tpl create mode 100644 paygate/images/paygate/mastercard-visa.svg create mode 100644 paygate/images/paygate/masterpass.svg create mode 100644 paygate/images/paygate/mobicred.svg create mode 100644 paygate/images/paygate/momopay.svg create mode 100644 paygate/images/paygate/paypal.svg create mode 100644 paygate/images/paygate/sid.svg create mode 100644 paygate/images/paygate/snapscan.svg create mode 100644 paygate/images/paygate/zapper.svg diff --git a/README.md b/README.md index f016bd9..462173e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/changelog.txt b/changelog.txt new file mode 100755 index 0000000..3028117 --- /dev/null +++ b/changelog.txt @@ -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. + + + + + + diff --git a/paygate/app/addons/paygate/addon.xml b/paygate/app/addons/paygate/addon.xml index bdc6b31..c184c53 100755 --- a/paygate/app/addons/paygate/addon.xml +++ b/paygate/app/addons/paygate/addon.xml @@ -1,9 +1,18 @@ + paygate - PayGate Payment Gateway - PayGate Payment Gateway - 1.0.1 + PayGate Payment Gateway + PayGate Payment Gateway + 1.0.2 en 1000 active diff --git a/paygate/app/addons/paygate/func.php b/paygate/app/addons/paygate/func.php index cd85729..4987130 100755 --- a/paygate/app/addons/paygate/func.php +++ b/paygate/app/addons/paygate/func.php @@ -1,59 +1,63 @@ $form['id'], 'REFERENCE' => $form['reference'], 'AMOUNT' => $form['amount'], 'CURRENCY' => $form['currency'], 'RETURN_URL' => $return_url, - 'TRANSACTION_DATE' => $form[date], + 'TRANSACTION_DATE' => $form['date'], 'LOCALE' => 'en-za', 'COUNTRY' => $country_code3, 'EMAIL' => $form['email'], - 'NOTIFY_URL' => $notify_url, - 'USER3' => 'cscart4', ); - $initiateFields['CHECKSUM'] = md5( implode( '', $initiateFields ) . $form['key'] ); - $curl = curl_init( 'https://secure.paygate.co.za/payweb3/initiate.trans' ); - curl_setopt( $curl, CURLOPT_POST, count( $initiateFields ) ); - curl_setopt( $curl, CURLOPT_POSTFIELDS, $initiateFields ); - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); - curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 ); - curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 ); - $response = curl_exec( $curl ); - curl_close( $curl ); - parse_str( $response, $responseFields ); + if ($set_paymethod) { + switch ($pw3_paymethod) { + case 'pw3_cc': + $initiateFields['PAY_METHOD'] = 'CC'; + $initiateFields['PAY_METHOD_DETAIL'] = 'Card'; + break; + case 'pw3_bt': + $initiateFields['PAY_METHOD'] = 'BT'; + $initiateFields['PAY_METHOD_DETAIL'] = 'SID'; + break; + case 'pw3_zapper': + $initiateFields['PAY_METHOD'] = 'EW'; + $initiateFields['PAY_METHOD_DETAIL'] = 'Zapper'; + break; + case 'pw3_mobicred': + $initiateFields['PAY_METHOD'] = 'EW'; + $initiateFields['PAY_METHOD_DETAIL'] = 'Mobicred'; + break; + case 'pw3_momopay': + $initiateFields['PAY_METHOD'] = 'EW'; + $initiateFields['PAY_METHOD_DETAIL'] = 'Momopay'; + break; + case 'pw3_masterpass': + $initiateFields['PAY_METHOD'] = 'EW'; + $initiateFields['PAY_METHOD_DETAIL'] = 'MasterPass'; + break; + case 'pw3_snapscan': + $initiateFields['PAY_METHOD'] = 'EW'; + $initiateFields['PAY_METHOD_DETAIL'] = 'SnapScan'; + break; + case 'pw3_paypal': + $initiateFields['PAY_METHOD'] = 'EW'; + $initiateFields['PAY_METHOD_DETAIL'] = 'PayPal'; + break; + default: + break; + } + } + + $initiateFields['NOTIFY_URL'] = $notify_url; + $initiateFields['USER3'] = 'cscart-v102'; + + + $initiateFields['CHECKSUM'] = md5(implode('', $initiateFields) . $form['key']); + $curl = curl_init('https://secure.paygate.co.za/payweb3/initiate.trans'); + curl_setopt($curl, CURLOPT_POST, count($initiateFields)); + curl_setopt($curl, CURLOPT_POSTFIELDS, $initiateFields); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); + $response = curl_exec($curl); + curl_close($curl); + parse_str($response, $responseFields); echo <<Kindly wait while you're redirected to PayGate ...

@@ -63,62 +114,59 @@ HTML; die; -} else if ( defined( 'PAYMENT_NOTIFICATION' ) ) { - if ( $mode == 'return' ) { +} elseif (defined('PAYMENT_NOTIFICATION')) { + if ($mode == 'return') { $order_id = $_REQUEST['order_id']; - $order_info = fn_get_order_info( $order_id ); - $payment_id = db_get_field( "SELECT payment_id FROM ?:orders WHERE order_id = ?i", $order_id ); - $processor_data = fn_get_payment_method_data( $payment_id ); + $order_info = fn_get_order_info($order_id); + $payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id = ?i", $order_id); + $processor_data = fn_get_payment_method_data($payment_id); $status = $_POST['TRANSACTION_STATUS']; - if ( $status == 1 && fn_check_payment_script( 'paygate.php', $order_id ) ) { + if ($status == 1 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) { $pp_response['order_status'] = 'P'; $pp_response['reason_text'] = 'PayGate Redirect Response: The User Completed Payment with PayGate'; $pp_response['transaction_id'] = ''; - } else if ( $status == 2 && fn_check_payment_script( 'paygate.php', $order_id ) ) { + } elseif ($status == 2 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) { $pp_response['order_status'] = 'D'; $pp_response['reason_text'] = 'PayGate Redirect Response: Transaction was declined by the payment processor'; - - } else if ( $status == 4 && fn_check_payment_script( 'paygate.php', $order_id ) ) { + } elseif ($status == 4 && fn_check_payment_script(PAYGATE_SCRIPT, $order_id)) { $pp_response['order_status'] = 'I'; $pp_response['reason_text'] = 'PayGate Redirect Response: User has cancelled payment'; } else { $pp_response['order_status'] = 'F'; $pp_response['reason_text'] = 'PayGate Redirect Response: Your Payment has failed'; } - fn_finish_payment( $order_id, $pp_response, false ); - fn_order_placement_routines( 'route', $order_id ); - - } else if ( $mode == 'notify' ) { - + fn_finish_payment($order_id, $pp_response, false); + fn_order_placement_routines('route', $order_id); + } elseif ($mode == 'notify') { $order_id = $_REQUEST['order_id']; - fn_check_payment_script( 'paygate.php', $order_id, $processor_data ); - $payment_id = db_get_field( "SELECT payment_id FROM ?:orders WHERE order_id = ?i", $_POST['REFERENCE'] ); - $processor_data = fn_get_payment_method_data( $payment_id ); + fn_check_payment_script(PAYGATE_SCRIPT, $order_id, $processor_data); + $payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id = ?i", $_POST['REFERENCE']); + $processor_data = fn_get_payment_method_data($payment_id); $pp_response = array(); - $order_info = fn_get_order_info( $order_id ); + $order_info = fn_get_order_info($order_id); - if ( empty( $processor_data ) ) { - $processor_data = fn_get_processor_data( $order_info['payment_id'] ); + if (empty($processor_data)) { + $processor_data = fn_get_processor_data($order_info['payment_id']); } $errors = false; $paygate_data = array(); $notify_data = array(); // Get notify data - if ( !$errors ) { + if ( ! $errors) { $nData = $_POST; // Strip any slashes in data - foreach ( $nData as $key => $val ) { - $paygate_data[$key] = stripslashes( $val ); + foreach ($nData as $key => $val) { + $paygate_data[$key] = stripslashes($val); } - if ( $paygate_data === false ) { + if ($paygate_data === false) { $errors = true; } } $encryption_key = ''; $mode = $processor_data['params']['mode']; - if ( $mode ) { + if ($mode) { $encryption_key = $processor_data['params']['key']; } else { $encryption_key = 'secret'; @@ -126,18 +174,18 @@ // Verify security signature $checkSumParams = ''; - if ( !$errors ) { - foreach ( $paygate_data as $key => $val ) { - $notify_data[$key] = stripslashes( $val ); + if ( ! $errors) { + foreach ($paygate_data as $key => $val) { + $notify_data[$key] = stripslashes($val); - if ( $key == 'PAYGATE_ID' ) { + if ($key == 'PAYGATE_ID') { $checkSumParams .= $val; } - if ( $key != 'CHECKSUM' && $key != 'PAYGATE_ID' ) { + if ($key != 'CHECKSUM' && $key != 'PAYGATE_ID') { $checkSumParams .= $val; } - if ( sizeof( $notify_data ) == 0 ) { + if (empty($notify_data)) { $errors = true; } } @@ -145,34 +193,36 @@ } // Verify security signature - if ( !$errors ) { - $checkSumParams = md5( $checkSumParams ); - if ( $checkSumParams != $paygate_data['CHECKSUM'] ) { + if ( ! $errors) { + $checkSumParams = md5($checkSumParams); + if ($checkSumParams != $paygate_data['CHECKSUM']) { $errors = true; $pp_response['order_status'] = 'F'; $pp_response['reason_text'] = 'Security Error: Checksum mismatch. Illegal access detected'; - fn_finish_payment( $order_id, $pp_response, false ); - fn_order_placement_routines( 'route', $order_id ); + fn_finish_payment($order_id, $pp_response, false); + fn_order_placement_routines('route', $order_id); } } $status = $_POST['TRANSACTION_STATUS']; - if ( !$errors ) { - if ( $status == 1 ) { + if ( ! $errors) { + if ($status == 1) { $pp_response['order_status'] = 'P'; $pp_response['reason_text'] = 'PayGate Notify Response: The User Completed Payment with PayGate'; $pp_response['transaction_id'] = ''; - } else if ( $status == 2 ) { + } elseif ($status == 2) { $pp_response['order_status'] = 'D'; $pp_response['reason_text'] = 'PayGate Notify Response: Transaction was declined by the payment processor'; - } else if ( $status == 4 ) { + } elseif ($status == 4) { $pp_response['order_status'] = 'I'; - $pp_response["reason_text"] = 'PayGate Notify Response: ' . fn_get_lang_var( 'text_transaction_cancelled' ); + $pp_response["reason_text"] = 'PayGate Notify Response: ' . fn_get_lang_var( + 'text_transaction_cancelled' + ); } else { $pp_response['order_status'] = 'F'; $pp_response['reason_text'] = 'PayGate Notify Response: Your Payment has failed'; } } - fn_finish_payment( $order_id, $pp_response, false ); - fn_order_placement_routines( 'route', $order_id ); + fn_finish_payment($order_id, $pp_response, false); + fn_order_placement_routines('route', $order_id); } } diff --git a/paygate/design/backend/templates/addons/paygate/views/payments/components/cc_processors/paygate.tpl b/paygate/design/backend/templates/addons/paygate/views/payments/components/cc_processors/paygate.tpl index a2d752f..8c9074d 100755 --- a/paygate/design/backend/templates/addons/paygate/views/payments/components/cc_processors/paygate.tpl +++ b/paygate/design/backend/templates/addons/paygate/views/payments/components/cc_processors/paygate.tpl @@ -1,13 +1,20 @@ +{* + * Copyright (c) 2021 PayGate (Pty) Ltd + * + * Author: App Inlet (Pty) Ltd + * + * Released under the GNU General Public License + *}
- +
- +
@@ -19,9 +26,94 @@
+
+ +
+

+ + credit-card +

+ +

+ + bank-transfer +

+ +

+ + zapper +

+ +

+ + mobicred +

+ +

+ + momopay +

+ +

+ + masterpass +

+ +

+ + snapscan +

+ +

+ + paypal +

+
+
- +
-
\ No newline at end of file + diff --git a/paygate/design/themes/responsive/templates/views/orders/components/payments/paygate.tpl b/paygate/design/themes/responsive/templates/views/orders/components/payments/paygate.tpl new file mode 100644 index 0000000..51288b3 --- /dev/null +++ b/paygate/design/themes/responsive/templates/views/orders/components/payments/paygate.tpl @@ -0,0 +1,75 @@ +{* + * Copyright (c) 2021 PayGate (Pty) Ltd + * + * Author: App Inlet (Pty) Ltd + * + * Released under the GNU General Public License + *} +
+
+
+ {if $payment_method} +

Choose your payment method

+ {foreach $payment_method['processor_params'] as $parameter} + {if $parameter == 'pw3_cc'} +

+ + credit-card

+ {/if} + {if $parameter == 'pw3_bt'} +

+ + bank-transfer

+ {/if} + {if $parameter == 'pw3_zapper'} +

+ + zapper

+ {/if} + {if $parameter == 'pw3_mobicred'} +

+ + zapper

+ {/if} + {if $parameter == 'pw3_momopay'} +

+ + zapper

+ {/if} + {if $parameter == 'pw3_masterpass'} +

+ + zapper

+ {/if} + {if $parameter == 'pw3_snapscan'} +

+ + snapscan

+ {/if} + {if $parameter == 'pw3_paypal'} +

+ + paypal

+ {/if} + {/foreach} + {/if} +
+
+
+ diff --git a/paygate/images/paygate/mastercard-visa.svg b/paygate/images/paygate/mastercard-visa.svg new file mode 100644 index 0000000..ccd49a7 --- /dev/null +++ b/paygate/images/paygate/mastercard-visa.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/masterpass.svg b/paygate/images/paygate/masterpass.svg new file mode 100644 index 0000000..b12d5ab --- /dev/null +++ b/paygate/images/paygate/masterpass.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/mobicred.svg b/paygate/images/paygate/mobicred.svg new file mode 100644 index 0000000..be10134 --- /dev/null +++ b/paygate/images/paygate/mobicred.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/momopay.svg b/paygate/images/paygate/momopay.svg new file mode 100644 index 0000000..7ba27c0 --- /dev/null +++ b/paygate/images/paygate/momopay.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/paypal.svg b/paygate/images/paygate/paypal.svg new file mode 100644 index 0000000..7a21ba8 --- /dev/null +++ b/paygate/images/paygate/paypal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/sid.svg b/paygate/images/paygate/sid.svg new file mode 100644 index 0000000..fe0f721 --- /dev/null +++ b/paygate/images/paygate/sid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/snapscan.svg b/paygate/images/paygate/snapscan.svg new file mode 100644 index 0000000..6c72916 --- /dev/null +++ b/paygate/images/paygate/snapscan.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/paygate/images/paygate/zapper.svg b/paygate/images/paygate/zapper.svg new file mode 100644 index 0000000..a67401a --- /dev/null +++ b/paygate/images/paygate/zapper.svg @@ -0,0 +1 @@ + \ No newline at end of file