Skip to content

Commit

Permalink
Merge pull request #11 from appinlet/release/3.1.1
Browse files Browse the repository at this point in the history
2024-07-30: v3.1.1
  • Loading branch information
appinlet authored Jul 30, 2024
2 parents 6b498c9 + 159e051 commit 1035770
Show file tree
Hide file tree
Showing 14 changed files with 275 additions and 91 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# PayWeb_OpenCart
## Payfast OpenCart plugin v3.1.0 for OpenCart v4.0.2.2
## Payfast OpenCart plugin v3.1.1 for OpenCart v4.0.2.3

This is the Paygate plugin for OpenCart. Please feel free to contact the Payfast support team at support@payfast.help should you require any assistance.

## Installation
[![How To Setup Paygate for OpenCart](https://appinlet.com/wp-content/uploads/2021/01/How-To-Setup-PayGate-PayWeb-for-OpenCart.jpg)](https://www.youtube.com/watch?v=vP457DVuhGc "How To Setup Paygate for OpenCart")

Please navigate to the [releases page](https://github.com/Paygate/PayWeb_OpenCart/releases), download the latest release (v3.1.0) and unzip. You will them 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_OpenCart/releases), download the latest release (v3.1.1) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.

## Collaboration

Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
=====================================
Date : Version: Description
=====================================
2024-07-30: v3.1.1 : Add RCS, Samsung Pay and Apple Pay payment method options.
Test on OpenCart 4.0.2.3.

2023-09-22: v3.1.0 : Update for PHP 8.0.
Test on OpenCart 4.0.2.2.

Expand Down
5 changes: 4 additions & 1 deletion paygate/admin/controller/payment/paygate.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2023 Payfast (Pty) Ltd
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down Expand Up @@ -167,6 +167,9 @@ public function index()
$data['payment_paygate_momopaymethod'] = $this->checkPostValue("payment_paygate_momopaymethod");
$data['payment_paygate_geo_zone_id'] = $this->checkPostValue("payment_paygate_geo_zone_id");
$data['payment_paygate_scantopaymethod'] = $this->checkPostValue("payment_paygate_scantopaymethod");
$data['payment_paygate_rcsmethod'] = $this->checkPostValue("payment_paygate_rcsmethod");
$data['payment_paygate_applepaymethod'] = $this->checkPostValue("payment_paygate_applepaymethod");
$data['payment_paygate_samsungpaymethod'] = $this->checkPostValue("payment_paygate_samsungpaymethod");
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
Expand Down
7 changes: 5 additions & 2 deletions paygate/admin/language/en-gb/payment/paygate.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2023 Payfast (Pty) Ltd
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down Expand Up @@ -29,7 +29,7 @@
$_['entry_status'] = 'Status';
$_['entry_sort_order'] = 'Sort Order';
$_['text_paygate'] = '<a onclick="window.open(\'https://www.paygate.co.za/\');">
<img src="/extension/paygate/admin/view/image/payment/paygate.png"
<img src="/extension/paygate/admin/view/image/payment/paygate.png"
alt="Paygate" title="Paygate" style="border: 1px solid #EEEEEE;" /></a>';
$_['entry_merchant_id'] = 'Paygate ID';
$_['entry_merchant_key'] = 'Encryption Key';
Expand All @@ -46,6 +46,9 @@
$_['entry_mobicredmethod'] = 'Enable Mobicred on Checkout';
$_['entry_momopaymethod'] = 'Enable MoMoPay on Checkout';
$_['entry_scantopaymethod'] = 'Enable ScanToPay on Checkout';
$_['entry_rcsmethod'] = 'Enable RCS on Checkout';
$_['entry_applepaymethod'] = 'Enable Apple Pay on Checkout';
$_['entry_samsungpaymethod'] = 'Enable Samsung Pay on Checkout';

// Tab
$_['tab_general'] = 'General';
Expand Down
73 changes: 63 additions & 10 deletions paygate/admin/view/template/payment/paygate.twig
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{#
# Copyright (c) 2023 Payfast (Pty) Ltd
# Copyright (c) 2024 Payfast (Pty) Ltd
#
# Author: App Inlet (Pty) Ltd
#
Expand Down Expand Up @@ -38,12 +38,12 @@
<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-paygate"
class="form-horizontal">

{# <ul class="nav nav-tabs">#}
{# <li class="active"><a href="#tab-general" data-toggle="tab">{{ tab_general }}</a>#}
{# </li>#}
{# <li><a href="#tab-order-status" data-toggle="tab">{{ tab_order_status }}</a></li>#}
{# <li><a href="#tab-pay-methods" data-toggle="tab">{{ tab_pay_methods }}</a></li>#}
{# </ul>#}
{# <ul class="nav nav-tabs"> #}
{# <li class="active"><a href="#tab-general" data-toggle="tab">{{ tab_general }}</a> #}
{# </li> #}
{# <li><a href="#tab-order-status" data-toggle="tab">{{ tab_order_status }}</a></li> #}
{# <li><a href="#tab-pay-methods" data-toggle="tab">{{ tab_pay_methods }}</a></li> #}
{# </ul> #}
<div class="tab-content">

<div class="tab-pane active py-4" id="tab-general">
Expand All @@ -66,7 +66,8 @@
</div>
<hr>
<div class="my-4 row align-items-center form-group">
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label" for="input-testmode">{{ entry_testmode }}</label>
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label"
for="input-testmode">{{ entry_testmode }}</label>
<div class="col-sm-9">
<select name="payment_paygate_testmode" id="input-testmode" class="form-control">
{% if payment_paygate_testmode %}
Expand Down Expand Up @@ -99,7 +100,8 @@
</div>
<hr>
<div class="my-4 row align-items-center form-group">
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label" for="input-status">{{ entry_status }}</label>
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label"
for="input-status">{{ entry_status }}</label>
<div class="col-sm-9">
<select name="payment_paygate_status" id="input-status" class="form-control">
{% if payment_paygate_status %}
Expand All @@ -119,7 +121,7 @@
<div class="col-sm-9">
<select name="payment_paygate_notifyredirect" id="input-notifyredirect"
class="form-control">
{% if payment_paygate_notifyredirect == 'notify' %}
{% if payment_paygate_notifyredirect != 'redirect' %}
<option value="notify" selected="selected">{{ text_notify }}</option>
<option value="redirect">{{ text_redirect }}</option>
{% else %}
Expand Down Expand Up @@ -360,6 +362,57 @@
</select>
</div>
</div>
<hr>
<div class="my-4 row align-items-center form-group">
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label"
for="input-rcsmethod">{{ entry_rcsmethod }}</label>
<div class="col-sm-9">
<select name="payment_paygate_rcsmethod" id="input-rcsmethod"
class="form-control">
{% if payment_paygate_rcsmethod == 'yes' %}
<option value="yes" selected="selected">{{ text_methodyes }}</option>
<option value="no">{{ text_methodno }}</option>
{% else %}
<option value="yes">{{ text_methodyes }}</option>
<option value="no" selected="selected">{{ text_methodno }}</option>
{% endif %}
</select>
</div>
</div>
<hr>
<div class="my-4 row align-items-center form-group">
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label"
for="input-applepaymethod">{{ entry_applepaymethod }}</label>
<div class="col-sm-9">
<select name="payment_paygate_applepaymethod" id="input-applepaymethod"
class="form-control">
{% if payment_paygate_applepaymethod == 'yes' %}
<option value="yes" selected="selected">{{ text_methodyes }}</option>
<option value="no">{{ text_methodno }}</option>
{% else %}
<option value="yes">{{ text_methodyes }}</option>
<option value="no" selected="selected">{{ text_methodno }}</option>
{% endif %}
</select>
</div>
</div>
<hr>
<div class="my-4 row align-items-center form-group">
<label class="col-form-label d-flex flex-row-reverse col-sm-2 col-form-label control-label"
for="input-samsungpaymethod">{{ entry_samsungpaymethod }}</label>
<div class="col-sm-9">
<select name="payment_paygate_samsungpaymethod" id="input-samsungpaymethod"
class="form-control">
{% if payment_paygate_samsungpaymethod == 'yes' %}
<option value="yes" selected="selected">{{ text_methodyes }}</option>
<option value="no">{{ text_methodno }}</option>
{% else %}
<option value="yes">{{ text_methodyes }}</option>
<option value="no" selected="selected">{{ text_methodno }}</option>
{% endif %}
</select>
</div>
</div>
</div>
</div>
</form>
Expand Down
75 changes: 49 additions & 26 deletions paygate/catalog/controller/payment/paygate.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2023 Payfast (Pty) Ltd
* Copyright (c) 2024 Payfast (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand All @@ -16,7 +16,7 @@ class Paygate extends Controller
{
const CHECKOUT_MODEL = "checkout/order";
const INFORMATION_CONTACT = "information/contact";
const PAYGATE_CODE = 'paygate.paygate';
const PAYGATE_CODE = 'paygate.paygate';

protected $testmode;
private $tableName = DB_PREFIX . 'paygate_transaction';
Expand Down Expand Up @@ -58,6 +58,18 @@ public function getPaymentMethods()
'title' => 'ScanToPay',
'img' => $imgs . 'scan-to-pay.svg',
],
'rcsmethod' => [
'title' => 'RCS',
'img' => $imgs . 'rcs.svg',
],
'applepaymethod' => [
'title' => 'Apple Pay',
'img' => $imgs . 'apple-pay.svg',
],
'samsungpaymethod' => [
'title' => 'Samsung Pay',
'img' => $imgs . 'samsung-pay.svg',
],
];
$pms = [];
foreach ($paymethods as $key => $paymethod) {
Expand All @@ -77,7 +89,7 @@ public function getPayMethodDetails()
switch ($_POST['paygate_pay_method']) {
case 'creditcardmethod';
$PAY_METHOD = 'CC';
$PAY_METHOD_DETAIL = '';
$PAY_METHOD_DETAIL = 'pw3_credit_card';
break;
case 'banktransfermethod':
$PAY_METHOD = 'BT';
Expand All @@ -101,6 +113,17 @@ public function getPayMethodDetails()
case 'scantopaymethod':
$PAY_METHOD_DETAIL = 'MasterPass';
break;
case 'rcsmethod':
$PAY_METHOD = 'CC';
$PAY_METHOD_DETAIL = 'RCS';
break;
case 'applepaymethod':
$PAY_METHOD = 'CC';
$PAY_METHOD_DETAIL = 'Applepay';
break;
case 'samsungpaymethod':
$PAY_METHOD_DETAIL = 'Samsungpay';
break;
default:
$PAY_METHOD_DETAIL = $_POST['paygate_pay_method'];
break;
Expand Down Expand Up @@ -295,7 +318,7 @@ public function index()
]
);
}
} elseif (isset($_POST['paygate_pay_method'])) {
} elseif (isset($_POST['paygate_pay_method']) && $_POST['paygate_pay_method'] !== "") {
$pay_method_data = $this->getPayMethodDetails();
}

Expand Down Expand Up @@ -361,7 +384,7 @@ public function index()
// Save transaction data for return
$paygateData = serialize($order_info);
$paygateSession = [
'customer' => $this->customer,
'customer' => $this->customer,
'customerId' => $order_info['customer_id'],
];
$paygateSession = base64_encode(serialize($paygateSession));
Expand Down Expand Up @@ -498,13 +521,13 @@ public function paygate_return()
$checksum = htmlspecialchars($_POST['CHECKSUM']);

// Retrieve transaction record
$record = $this->db->query(
$record = $this->db->query(
"select * from {$this->tableName} where paygate_reference = '{$payRequestId}';"
);
$record = $record?->rows[0];
$orderId = $record['order_id'] ?? 0;
$ps = $record['paygate_session'];
$pas = base64_decode($ps);
$record = $record?->rows[0];
$orderId = $record['order_id'] ?? 0;
$ps = $record['paygate_session'];
$pas = base64_decode($ps);

// Verify checksum
$checkString = $this->getPaygateId() . $payRequestId . $transactionStatus . $orderId . $this->getEncryptionkey(
Expand Down Expand Up @@ -533,10 +556,10 @@ public function paygate_return()

$this->setActivityData($order, $orderId);
$payMethodDesc = '';
$respData = $this->sendCurlRequest($record);
$result = $respData['result'] ?? '';
$r = $respData['r'] ?? '';
$error = $respData['error'] ?? '';
$respData = $this->sendCurlRequest($record);
$result = $respData['result'] ?? '';
$r = $respData['r'] ?? '';
$error = $respData['error'] ?? '';

if (isset($result['PAY_METHOD_DETAIL']) && $result['PAY_METHOD_DETAIL'] != '') {
$payMethodDesc = ', using a payment method of ' . $result['PAY_METHOD_DETAIL'];
Expand Down Expand Up @@ -598,19 +621,19 @@ public function restoreCart($products, $statusDesc, $orderId)

public function sendCurlRequest($record)
{
$paygateID = $this->getPaygateId();
$paygateID = $this->getPaygateId();
$encryptionKey = $this->getEncryptionkey();
$useRedirect = $this->config->get('payment_paygate_notifyredirect') === 'redirect';
$respData = [];
$orderId = $record['order_id'];
$r = "";
$error = false;
$useRedirect = $this->config->get('payment_paygate_notifyredirect') === 'redirect';
$respData = [];
$orderId = $record['order_id'];
$r = "";
$error = false;
if ($useRedirect) {
// Query to verify response data
$payRequestId = htmlspecialchars($_POST['PAY_REQUEST_ID']);
$reference = $orderId;
$checksum = md5($paygateID . $payRequestId . $reference . $encryptionKey);
$queryData = array(
$reference = $orderId;
$checksum = md5($paygateID . $payRequestId . $reference . $encryptionKey);
$queryData = array(
'PAYGATE_ID' => $paygateID,
'PAY_REQUEST_ID' => $payRequestId,
'REFERENCE' => $reference,
Expand Down Expand Up @@ -746,14 +769,14 @@ public function notify_handler()
$notify_checksum = $postData['notify_checksum'];
$transaction_status = $postData['transaction_status'];
$order_id = $postData['order_id'];
$payMethodDesc = $postData['pay_method_desc'];
$payMethodDesc = $postData['pay_method_desc'];

if ($checkSumParams != $notify_checksum) {
$errors = true;
}

if (!$errors) {
$txnData = $this->getOrderStatusDesc($transaction_status);
$txnData = $this->getOrderStatusDesc($transaction_status);
$orderStatusId = $txnData['orderStatusId'];
$statusDesc = $txnData['statusDesc'];

Expand All @@ -773,7 +796,7 @@ public function prepareCheckSumParams()
// Check for test / live modes
$this->testmode = $this->config->get('payment_paygate_testmode') === 'test';
$paygateID = $this->getPaygateId();
$encryptionKey = $this->getEncryptionkey();
$encryptionKey = $this->getEncryptionkey();

$checkSumParams = '';

Expand Down
Loading

0 comments on commit 1035770

Please sign in to comment.