Skip to content

Commit adf4631

Browse files
2.4.1
- Update for Magento 2.4.4+ and PHP 8.1. - Fix CSP errors. - Fix Checksum Issues. - Add configurable order state and status. - Fix invalid command type. - Update branding.
1 parent d8ef5bd commit adf4631

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1146
-1249
lines changed

README.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
# mod-magento_2
22

3-
PayFast Magento Module v2.4.0 for Magento 2.4.4+ on PHP 8.1
3+
Payfast Magento Module v2.4.0 for Magento 2.4.4+ on PHP 8.1
44
-----------------------------------------------------------------------------
55
Copyright (c) 2023 Payfast (Pty) Ltd
6-
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.
7-
Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or part thereof in any way.
6+
You (being anyone who is not Payfast (Pty) Ltd) may download and use this plugin / code in your own website in
7+
conjunction with a registered and active Payfast account. If your Payfast account is terminated for any reason, you may
8+
not use this plugin / code or part thereof.
9+
Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or part
10+
thereof in any way.
811

9-
In order to use Payfast with Magento 2, you will need a working Magento installation. To install Payfast follow the below instructions:
12+
In order to use Payfast with Magento 2, you will need a working Magento installation. To install Payfast follow the
13+
below instructions:
1014

1115
1. Setup ZAR on your Magento site.
12-
In the admin panel navigate to 'Stores', and add ZAR under currency Symbols and Rates.
13-
2. Copy the PayFast app folder to your root Magento folder.
14-
This will not override any files on your system.
16+
In the admin panel navigate to 'Stores', and add ZAR under currency Symbols and Rates.
17+
2. Copy the Payfast app folder to your root Magento folder.
18+
This will not override any files on your system.
1519
3. You will now need to run the following commands in the given order:
1620

17-
3.1 php ./bin/magento module:enable PayFast_Payfast
21+
3.1 php ./bin/magento module:enable Payfast_Payfast
1822

19-
3.2 php ./bin/magento setup:di:compile
23+
3.2 php ./bin/magento setup:di:compile
2024

21-
3.3 php ./bin/magento setup:static-content:deploy
25+
3.3 php ./bin/magento setup:static-content:deploy
2226

23-
3.4 php ./bin/magento cache:clean
27+
3.4 php ./bin/magento cache:clean
2428

2529
4. Log into the admin panel and navigate to 'Stores'>'Configuration'>'Sales'>'Payment Method' and click on Payfast
26-
5. Enable the module, as well as debugging. To test in sandbox insert 'test' in the 'server' field and use the following credentials:
30+
5. Enable the module, as well as debugging. To test in sandbox insert 'test' in the 'server' field and use the following
31+
credentials:
2732

28-
Merchant ID: 10000100
33+
Merchant ID: 10000100
2934

30-
Merchant Key: 46f0cd694581a
35+
Merchant Key: 46f0cd694581a
3136

32-
Leave the passphrase blank and setup the other options as required.
37+
Leave the passphrase blank and setup the other options as required.
3338

34-
##NB: configure sending of emails by default magento source code does not allow sending of emails when a payment module does a redirect.
39+
##NB: configure sending of emails by default magento source code does not allow sending of emails when a payment
40+
module does a redirect.
3541

3642
6. Click 'Save Config', you are now ready to test in sandbox, click 'Save Config'.
3743

38-
7. Once you are ready to go live, insert 'live' into the 'server' field and input your Payfast credentials. Set debug log to 'No', and the other options as required.
44+
7. Once you are ready to go live, insert 'live' into the 'server' field and input your Payfast credentials. Set debug
45+
log to 'No', and the other options as required.
3946
8. Click 'Save Config', you are now ready to process live transactions via Payfast.
4047

4148
Please [click here](https://payfast.io/integration/shopping-carts/magento/) for more information concerning this module.

app/code/Payfast/Payfast/Block/Form.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
/**
3-
* Copyright (c) 2008 PayFast (Pty) Ltd
4-
* 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.
3+
* Copyright (c) 2023 Payfast (Pty) Ltd
4+
* 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.
55
* Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or part thereof in any way.
66
*/
7+
78
namespace Payfast\Payfast\Block;
89

910
use Magento\Customer\Helper\Session\CurrentCustomer;
@@ -51,12 +52,12 @@ class Form extends \Magento\Payment\Block\Form
5152
protected $currentCustomer;
5253

5354
/**
54-
* @param Context $context
55+
* @param Context $context
5556
* @param \Payfast\Payfast\Model\ConfigFactory $payfastConfigFactory
56-
* @param ResolverInterface $localeResolver
57-
* @param Data $payfastData
58-
* @param CurrentCustomer $currentCustomer
59-
* @param array $data
57+
* @param ResolverInterface $localeResolver
58+
* @param Data $payfastData
59+
* @param CurrentCustomer $currentCustomer
60+
* @param array $data
6061
*/
6162
public function __construct(
6263
Context $context,
@@ -66,8 +67,8 @@ public function __construct(
6667
CurrentCustomer $currentCustomer,
6768
array $data = []
6869
) {
69-
$pre = __METHOD__ . " : ";
70-
$this->_payfastData = $payfastData;
70+
$pre = __METHOD__ . " : ";
71+
$this->_payfastData = $payfastData;
7172
$this->payfastConfigFactory = $payfastConfigFactory;
7273
parent::__construct($context, $data);
7374
$this->_logger->debug($pre . 'bof');
@@ -79,27 +80,27 @@ public function __construct(
7980
}
8081

8182
/**
82-
* Set template and redirect message
83+
* Payment method code getter
8384
*
84-
* @return void
85+
* @return string 'payfast'
8586
*/
86-
protected function _construct()
87+
public function getMethodCode()
8788
{
8889
$pre = __METHOD__ . " : ";
8990
$this->_logger->debug($pre . 'bof');
90-
$this->_config = $this->payfastConfigFactory->create()->setMethod($this->getMethodCode());
91+
92+
return $this->_methodCode;
9193
}
9294

9395
/**
94-
* Payment method code getter
96+
* Set template and redirect message
9597
*
96-
* @return string 'payfast'
98+
* @return void
9799
*/
98-
public function getMethodCode()
100+
protected function _construct()
99101
{
100102
$pre = __METHOD__ . " : ";
101103
$this->_logger->debug($pre . 'bof');
102-
103-
return $this->_methodCode;
104+
$this->_config = $this->payfastConfigFactory->create()->setMethod($this->getMethodCode());
104105
}
105106
}

app/code/Payfast/Payfast/Block/Info.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php namespace Payfast\Payfast\Block;
1+
<?php
2+
namespace Payfast\Payfast\Block;
23

34
use Magento\Framework\Phrase;
45
use Magento\Payment\Block\ConfigurableInfo;
@@ -8,7 +9,8 @@ class Info extends ConfigurableInfo
89
/**
910
* Returns label
1011
*
11-
* @param string $field
12+
* @param string $field
13+
*
1214
* @return Phrase
1315
*/
1416
protected function getLabel($field): Phrase

app/code/Payfast/Payfast/Block/Payment/Info.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
22
/**
3-
* Copyright (c) 2008 PayFast (Pty) Ltd
4-
* 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.
3+
* Copyright (c) 2023 Payfast (Pty) Ltd
4+
* 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.
55
* Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or part thereof in any way.
66
*/
7+
78
namespace Payfast\Payfast\Block\Payment;
89

910
use Magento\Framework\View\Element\Template\Context;
1011
use Payfast\Payfast\Model\InfoFactory;
1112

1213
/**
13-
* PayFast common payment info block
14+
* Payfast common payment info block
1415
* Uses default templates
1516
*/
1617
class Info extends \Magento\Payment\Block\Info
@@ -21,9 +22,9 @@ class Info extends \Magento\Payment\Block\Info
2122
protected $_payfastInfoFactory;
2223

2324
/**
24-
* @param Context $context
25+
* @param Context $context
2526
* @param InfoFactory $payfastInfoFactory
26-
* @param array $data
27+
* @param array $data
2728
*/
2829
public function __construct(
2930
Context $context,

app/code/Payfast/Payfast/Block/Payment/Request.php

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright (c) 2008 PayFast (Pty) Ltd
4-
* 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.
3+
* Copyright (c) 2023 Payfast (Pty) Ltd
4+
* 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.
55
* Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or part thereof in any way.
66
*/
77

@@ -35,7 +35,7 @@ class Request extends Template
3535
protected $_checkoutSession;
3636

3737
/**
38-
* @var ReadFactory $readFactory
38+
* @var ReadFactory $readFactory
3939
*/
4040
protected $readFactory;
4141

@@ -45,14 +45,14 @@ class Request extends Template
4545
protected $reader;
4646

4747
/**
48-
* @param Context $context
48+
* @param Context $context
4949
* @param OrderFactory $orderFactory
50-
* @param Session $checkoutSession
51-
* @param Data $pfHelper
52-
* @param ReadFactory $readFactory
53-
* @param Reader $reader
54-
* @param Payfast $paymentMethod
55-
* @param array $data
50+
* @param Session $checkoutSession
51+
* @param Data $pfHelper
52+
* @param ReadFactory $readFactory
53+
* @param Reader $reader
54+
* @param Payfast $paymentMethod
55+
* @param array $data
5656
*/
5757
public function __construct(
5858
Context $context,
@@ -64,25 +64,27 @@ public function __construct(
6464
Payfast $paymentMethod,
6565
array $data = []
6666
) {
67-
$this->_hssHelper = $pfHelper;
68-
$this->_orderFactory = $orderFactory;
67+
$this->_hssHelper = $pfHelper;
68+
$this->_orderFactory = $orderFactory;
6969
$this->_checkoutSession = $checkoutSession;
7070
parent::__construct($context, $data);
7171
$this->_isScopePrivate = true;
72-
$this->readFactory = $readFactory;
73-
$this->reader = $reader;
74-
$this->_paymentMethod = $paymentMethod;
72+
$this->readFactory = $readFactory;
73+
$this->reader = $reader;
74+
$this->_paymentMethod = $paymentMethod;
7575
}
7676

7777
public function _prepareLayout()
7878
{
7979
$this->setMessage('Redirecting to Payfast')
80-
->setId('payfast_checkout')
81-
->setName('payfast_checkout')
82-
->setFormMethod('POST')
83-
->setFormAction($this->_paymentMethod->getPayFastUrl())
84-
->setFormData($this->_paymentMethod->getStandardCheckoutFormFields())
85-
->setSubmitForm('<script type="text/javascript">document.getElementById( "payfast_checkout" ).submit();</script>');
80+
->setId('payfast_checkout')
81+
->setName('payfast_checkout')
82+
->setFormMethod('POST')
83+
->setFormAction($this->_paymentMethod->getPayfastUrl())
84+
->setFormData($this->_paymentMethod->getStandardCheckoutFormFields())
85+
->setSubmitForm(
86+
'<script type="text/javascript">document.getElementById( "payfast_checkout" ).submit();</script>'
87+
);
8688

8789
return parent::_prepareLayout(); // TODO: Change the autogenerated stub
8890
}

0 commit comments

Comments
 (0)