Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# Changelog

## [[2.6.0]](https://github.com/Payfast/mod-magento_2/releases/tag/v2.6.0)
## [[2.7.0]](https://github.com/Payfast/magento-aggregation/releases/tag/v2.7.0)

### Added

- Added support for Magento 2.4.8+ and PHP 8.4.
- Updated Common Library to version 1.4.0.
- Updated branding to use the Payfast by Network logo.
- Revised configuration branding to Payfast Aggregation.

## [[2.6.0]](https://github.com/Payfast/magento-aggregation/releases/tag/v2.6.0)

### Added

- Update for Magento 2.4.7+ and PHP 8.2.

## [[2.5.1]](https://github.com/Payfast/mod-magento_2/releases/tag/v2.5.1)
## [[2.5.1]](https://github.com/Payfast/magento-aggregation/releases/tag/v2.5.1)

### Fixed

- Dynamic creation of properties error (php 8.2+).

## [[2.5.0]](https://github.com/Payfast/mod-magento_2/releases/tag/v2.5.0)
## [[2.5.0]](https://github.com/Payfast/magento-aggregation/releases/tag/v2.5.0)

### Added

Expand All @@ -23,7 +32,7 @@

- Bug fixes and code quality improvements.

## [[2.4.1]](https://github.com/Payfast/mod-magento_2/releases/tag/v2.4.1)
## [[2.4.1]](https://github.com/Payfast/magento-aggregation/releases/tag/v2.4.1)

### Added

Expand All @@ -43,7 +52,7 @@

- Update branding.

## [[2.4.0]](https://github.com/Payfast/mod-magento_2/releases/tag/v2.4.0)
## [[2.4.0]](https://github.com/Payfast/magento-aggregation/releases/tag/v2.4.0)

### Added

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# mod-magento_2
# magento-aggregation

## Payfast module v2.6.0 for Magento v2.4.7
## Payfast Aggregation module v2.7.0 for Magento v2.4.8

This is the Payfast module for Magento 2. Please feel free
This is the Payfast Aggregation module for Magento 2. Please feel free
to [contact the Payfast support team](https://payfast.io/contact/) should you require any assistance.

## Installation
Expand All @@ -14,7 +14,7 @@ to [contact the Payfast support team](https://payfast.io/contact/) should you re
3. You will now need to run the following commands in the given order:

```
composer require payfast/payfast-common:v1.1.0
composer require payfast/payfast-common:v1.4.0
php ./bin/magento module:enable Payfast_Payfast
php ./bin/magento setup:di:compile
php ./bin/magento setup:static-content:deploy
Expand Down
5 changes: 1 addition & 4 deletions app/code/Payfast/Payfast/Block/Form.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Block;
Expand All @@ -13,9 +13,6 @@
use Payfast\Payfast\Model\ConfigFactory;
use Payfast\Payfast\Model\PayfastConfigProvider;

/**
* Form class
*/
class Form extends \Magento\Payment\Block\Form
{
/**
Expand Down
3 changes: 0 additions & 3 deletions app/code/Payfast/Payfast/Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
use Magento\Framework\Phrase;
use Magento\Payment\Block\ConfigurableInfo;

/**
* Info class
*/
class Info extends ConfigurableInfo
{
/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Payfast/Payfast/Block/Payment/Info.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Block\Payment;
Expand Down
11 changes: 4 additions & 7 deletions app/code/Payfast/Payfast/Block/Payment/Request.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Block\Payment;
Expand All @@ -14,9 +14,6 @@
use Payfast\Payfast\Helper\Data;
use Payfast\Payfast\Model\Payfast;

/**
* Request class
*/
class Request extends Template
{

Expand Down Expand Up @@ -71,9 +68,9 @@ public function __construct(
$this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data);
$this->readFactory = $readFactory;
$this->reader = $reader;
$this->_paymentMethod = $paymentMethod;
$this->readFactory = $readFactory;
$this->reader = $reader;
$this->_paymentMethod = $paymentMethod;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Payfast/Payfast/Controller/AbstractPayfast.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Controller;
Expand Down
62 changes: 25 additions & 37 deletions app/code/Payfast/Payfast/Controller/Notify/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

namespace Payfast\Payfast\Controller\Notify;

/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* You (being anyone who is not Payfast (Pty) Ltd) may download and use this plugin / code in your own website
* in conjunction with a registered and active Payfast account. If your Payfast account is terminated for any reason,
* you may not use this plugin / code or part thereof.
* Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or
* part thereof in any way.
*/

use Exception;
use LogicException;
use Magento\Framework\App\Action\HttpPostActionInterface;
Expand All @@ -27,11 +18,8 @@
use Payfast\Payfast\Model\Config as PayfastConfig;
use Payfast\Payfast\Model\Info;
use Magento\Framework\Controller\ResultFactory;
use Payfast\PayfastCommon\PayfastCommon;
use Payfast\PayfastCommon\Aggregator\Request\PaymentRequest;

/**
* Index class
*/
class Index extends AbstractPayfast implements CsrfAwareActionInterface, HttpPostActionInterface
{

Expand All @@ -42,14 +30,14 @@ class Index extends AbstractPayfast implements CsrfAwareActionInterface, HttpPos
*/
public function execute(): ResultInterface
{
$debugMode = $this->getConfigData('debug');
$payfastCommon = new PayfastCommon((bool)$debugMode);
$debugMode = $this->getConfigData('debug');
$paymentRequest = new PaymentRequest((bool)$debugMode);

$moduleInfo = [
'pfSoftwareName' => 'Magento',
'pfSoftwareVer' => '2.4.7',
'pfSoftwareName' => 'Magento',
'pfSoftwareVer' => '2.4.7',
'pfSoftwareModuleName' => 'Payfast-Magento',
'pfModuleVer' => '2.6.0'
'pfModuleVer' => '2.7.0'
];

$this->_logger->debug('Notify: ' . json_encode($this->request->getPostValue()));
Expand All @@ -65,9 +53,9 @@ public function execute(): ResultInterface

$pfHost = $this->paymentMethod->getPayfastHost($serverMode);

$payfastCommon->pflog(' Payfast ITN call received');
$paymentRequest->pflog(' Payfast ITN call received');

$payfastCommon->pflog('Server = ' . $pfHost);
$paymentRequest->pflog('Server = ' . $pfHost);

//// Notify Payfast that information has been received
$resultRaw = $this->resultFactory->create(ResultFactory::TYPE_RAW);
Expand All @@ -87,58 +75,58 @@ public function execute(): ResultInterface

//// Get data sent by Payfast
// Posted variables from ITN
$pfData = PayfastCommon::pfGetData();
$pfData = $paymentRequest->pfGetData();

if (empty($pfData)) {
$pfError = true;
$pfErrMsg = PayfastCommon::PF_ERR_BAD_ACCESS;
$pfErrMsg = $paymentRequest::PF_ERR_BAD_ACCESS;
}

//// Verify security signature
if (!$pfError) {
$payfastCommon->pflog('Verify security signature');
$paymentRequest->pflog('Verify security signature');

// If signature different, log for debugging
if (!$payfastCommon->pfValidSignature(
if (!$paymentRequest->pfValidSignature(
$pfData,
$pfParamString,
$passPhrase
)) {
$pfError = true;
$pfErrMsg = PayfastCommon::PF_ERR_INVALID_SIGNATURE;
$pfErrMsg = $paymentRequest::PF_ERR_INVALID_SIGNATURE;
}
}

//// Get internal order and verify it hasn't already been processed
if (!$pfError) {
$payfastCommon->pflog("Check order hasn't been processed");
$paymentRequest->pflog("Check order hasn't been processed");

// Load order
$orderId = $pfData[Info::M_PAYMENT_ID];

$this->_order = $this->orderFactory->create()->loadByIncrementId($orderId);

$payfastCommon->pflog('order status is : ' . $this->_order->getStatus());
$paymentRequest->pflog('order status is : ' . $this->_order->getStatus());

// Check order is in "pending payment" state
if ($this->_order->getState() !== Order::STATE_PENDING_PAYMENT) {
$pfErrMsg = PayfastCommon::PF_ERR_ORDER_PROCESSED;
$pfErrMsg = $paymentRequest::PF_ERR_ORDER_PROCESSED;
}
}

//// Verify data received
if (!$pfError) {
$payfastCommon->pflog('Verify data received');
$paymentRequest->pflog('Verify data received');

if (!$payfastCommon->pfValidData($moduleInfo, $pfHost, $pfParamString)) {
if (!$paymentRequest->pfValidData($moduleInfo, $pfHost, $pfParamString)) {
$pfError = true;
$pfErrMsg = PayfastCommon::PF_ERR_BAD_ACCESS;
$pfErrMsg = $paymentRequest::PF_ERR_BAD_ACCESS;
}
}

//// Check status and update order
if (!$pfError) {
$payfastCommon->pflog('Check status and update order');
$paymentRequest->pflog('Check status and update order');

// Successful
if ($pfData[Info::PAYMENT_STATUS] === 'COMPLETE') {
Expand All @@ -155,7 +143,7 @@ public function execute(): ResultInterface

// If an error occurred
if ($pfError) {
$payfastCommon->pflog('Error occurred: ' . $pfErrMsg);
$paymentRequest->pflog('Error occurred: ' . $pfErrMsg);
$this->_logger->critical($pre . 'Error occured : ' . $pfErrMsg);

return $this->rawResult
Expand Down Expand Up @@ -278,11 +266,11 @@ protected function saveInvoice(): void
*/
private function setPaymentAdditionalInformation(array $pfData): void
{
$debugMode = $this->getConfigData('debug');
$payfastCommon = new PayfastCommon((bool)$debugMode);
$debugMode = $this->getConfigData('debug');
$paymentRequest = new PaymentRequest((bool)$debugMode);

$payfastCommon->pflog(__METHOD__ . ' : bof');
$payfastCommon->pflog('Order complete');
$paymentRequest->pflog(__METHOD__ . ' : bof');
$paymentRequest->pflog('Order complete');

try {
// Update order additional payment information
Expand Down
2 changes: 1 addition & 1 deletion app/code/Payfast/Payfast/Controller/Redirect/Cancel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Controller\Redirect;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Payfast/Payfast/Controller/Redirect/Index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Controller\Redirect;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Payfast/Payfast/Controller/Redirect/Success.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

namespace Payfast\Payfast\Controller\Redirect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
namespace Payfast\Payfast\Gateway\Config;

/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

use Magento\Payment\Gateway\Config\ValueHandlerInterface;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Sales\Model\Order\Payment;

/**
* CanAuthorizeHandler class
*/
class CanAuthorizeHandler implements ValueHandlerInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
namespace Payfast\Payfast\Gateway\Config;

/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

use Magento\Payment\Gateway\Config\ValueHandlerInterface;
use Magento\Payment\Gateway\Helper\SubjectReader;
use Magento\Sales\Model\Order\Payment;

/**
* CanCaptureHandler class
*/
class CanCaptureHandler implements ValueHandlerInterface
{
/**
Expand Down
5 changes: 1 addition & 4 deletions app/code/Payfast/Payfast/Gateway/Http/Client/ClientMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
namespace Payfast\Payfast\Gateway\Http\Client;

/**
* Copyright (c) 2024 Payfast (Pty) Ltd
* Copyright (c) 2025 Payfast (Pty) Ltd
*/

use Magento\Payment\Gateway\Http\ClientInterface;
use Magento\Payment\Gateway\Http\TransferInterface;
use Magento\Payment\Model\Method\Logger;

/**
* ClientMock class
*/
class ClientMock implements ClientInterface
{
public const SUCCESS = 1;
Expand Down
3 changes: 0 additions & 3 deletions app/code/Payfast/Payfast/Gateway/Http/TransferFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
use Magento\Payment\Gateway\Http\TransferFactoryInterface;
use Magento\Payment\Gateway\Http\TransferInterface;

/**
* TransferFactory class
*/
class TransferFactory implements TransferFactoryInterface
{

Expand Down
Loading