Skip to content

Commit 2d0344a

Browse files
Merge pull request #7 from appinlet/master
Migrate 2.4.0 from old repository
2 parents ce9ff4b + 4cbbff0 commit 2d0344a

Some content is hidden

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

45 files changed

+2251
-1049
lines changed

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
# mod-magento_2
22

3-
PayFast Magento Module v1.1.1 for Magento v2.0 - 2.1.3
3+
PayFast Magento Module v2.4.0 for Magento 2.4.4+ on PHP 8.1
44
-----------------------------------------------------------------------------
5-
Copyright (c) 2008 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.
5+
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.
77
Except as expressly indicated in this licence, you may not use, copy, modify or distribute this plugin / code or part thereof in any way.
88

9-
******************************************************************************
10-
11-
Please see the URL below for all information concerning this module:
12-
13-
https://www.payfast.co.za/shopping-carts/magento/
14-
******************************************************************************
15-
16-
In order to use PayFast with Magento 2.*.3 you will need a working Magento 2.*.3 installation. To install PayFast follow the below instructions:
9+
In order to use Payfast with Magento 2, you will need a working Magento installation. To install Payfast follow the below instructions:
1710

1811
1. Setup ZAR on your Magento site.
1912
In the admin panel navigate to 'Stores', and add ZAR under currency Symbols and Rates.
2013
2. Copy the PayFast app folder to your root Magento folder.
2114
This will not override any files on your system.
2215
3. You will now need to run the following commands in the given order:
23-
php ./bin/magento module:enable PayFast_Payfast
24-
php ./bin/magento setup:di:compile
25-
php ./bin/magento setup:static-content:deploy
26-
php ./bin/magento cache:clean
16+
17+
3.1 php ./bin/magento module:enable PayFast_Payfast
18+
19+
3.2 php ./bin/magento setup:di:compile
20+
21+
3.3 php ./bin/magento setup:static-content:deploy
22+
23+
3.4 php ./bin/magento cache:clean
24+
2725
4. Log into the admin panel and navigate to 'Stores'>'Configuration'>'Sales'>'Payment Method' and click on Payfast
2826
5. Enable the module, as well as debugging. To test in sandbox insert 'test' in the 'server' field and use the following credentials:
27+
2928
Merchant ID: 10000100
29+
3030
Merchant Key: 46f0cd694581a
31-
Leave the passphrase blank and setup the other options as required.
31+
32+
Leave the passphrase blank and setup the other options as required.
33+
34+
##NB: configure sending of emails by default magento source code does not allow sending of emails when a payment module does a redirect.
35+
3236
6. Click 'Save Config', you are now ready to test in sandbox, click 'Save Config'.
33-
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.
34-
8. Click 'Save Config', you are now ready to process live transactions via PayFast.
37+
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.
39+
8. Click 'Save Config', you are now ready to process live transactions via Payfast.
40+
41+
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: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,78 @@
44
* 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-
namespace Payfast\Payfast\Block\Payfast;
7+
namespace Payfast\Payfast\Block;
88

99
use Magento\Customer\Helper\Session\CurrentCustomer;
1010
use Magento\Framework\Locale\ResolverInterface;
11-
use Magento\Framework\View\Element\Template;
1211
use Magento\Framework\View\Element\Template\Context;
12+
use Payfast\Payfast\Helper\Data;
1313
use Payfast\Payfast\Model\Config;
14-
use Payfast\Payfast\Model\Payfast\Checkout;
14+
use Payfast\Payfast\Model\PayfastConfigProvider;
1515

1616
class Form extends \Magento\Payment\Block\Form
1717
{
18-
/** @var string Payment method code */
18+
/**
19+
* @var string Payment method code
20+
*/
1921
protected $_methodCode = Config::METHOD_CODE;
2022

21-
/** @var \Payfast\Payfast\Helper\Data */
23+
/**
24+
* @var Data
25+
*/
2226
protected $_payfastData;
2327

24-
/** @var \Payfast\Payfast\Model\ConfigFactory */
28+
/**
29+
* @var \Payfast\Payfast\Model\ConfigFactory
30+
*/
2531
protected $payfastConfigFactory;
2632

27-
/** @var ResolverInterface */
33+
/**
34+
* @var ResolverInterface
35+
*/
2836
protected $_localeResolver;
2937

30-
/** @var \Payfast\Payfast\Model\Config */
38+
/**
39+
* @var \Payfast\Payfast\Model\Config
40+
*/
3141
protected $_config;
3242

33-
/** @var bool */
43+
/**
44+
* @var bool
45+
*/
3446
protected $_isScopePrivate;
3547

36-
/** @var CurrentCustomer */
48+
/**
49+
* @var CurrentCustomer
50+
*/
3751
protected $currentCustomer;
3852

3953
/**
40-
* @param Context $context
54+
* @param Context $context
4155
* @param \Payfast\Payfast\Model\ConfigFactory $payfastConfigFactory
42-
* @param ResolverInterface $localeResolver
43-
* @param \Payfast\Payfast\Helper\Data $payfastData
44-
* @param CurrentCustomer $currentCustomer
45-
* @param array $data
56+
* @param ResolverInterface $localeResolver
57+
* @param Data $payfastData
58+
* @param CurrentCustomer $currentCustomer
59+
* @param array $data
4660
*/
4761
public function __construct(
4862
Context $context,
49-
\Payfast\Payfast\Model\ConfigFactory $payfastConfigFactory,
63+
PayfastConfigProvider $payfastConfigFactory,
5064
ResolverInterface $localeResolver,
51-
\Payfast\Payfast\Helper\Data $payfastData,
65+
Data $payfastData,
5266
CurrentCustomer $currentCustomer,
5367
array $data = []
5468
) {
5569
$pre = __METHOD__ . " : ";
56-
$this->_logger->debug( $pre . 'bof' );
5770
$this->_payfastData = $payfastData;
5871
$this->payfastConfigFactory = $payfastConfigFactory;
72+
parent::__construct($context, $data);
73+
$this->_logger->debug($pre . 'bof');
5974
$this->_localeResolver = $localeResolver;
60-
$this->_config = null;
75+
6176
$this->_isScopePrivate = true;
6277
$this->currentCustomer = $currentCustomer;
63-
parent::__construct($context, $data);
64-
$this->_logger->debug( $pre . "eof" );
78+
$this->_logger->debug($pre . "eof");
6579
}
6680

6781
/**
@@ -72,9 +86,8 @@ public function __construct(
7286
protected function _construct()
7387
{
7488
$pre = __METHOD__ . " : ";
75-
$this->_logger->debug( $pre . 'bof' );
76-
$this->_config = $this->payfastConfigFactory->create()->setMethod( $this->getMethodCode() );
77-
parent::_construct();
89+
$this->_logger->debug($pre . 'bof');
90+
$this->_config = $this->payfastConfigFactory->create()->setMethod($this->getMethodCode());
7891
}
7992

8093
/**
@@ -85,12 +98,8 @@ protected function _construct()
8598
public function getMethodCode()
8699
{
87100
$pre = __METHOD__ . " : ";
88-
$this->_logger->debug( $pre . 'bof' );
101+
$this->_logger->debug($pre . 'bof');
89102

90103
return $this->_methodCode;
91104
}
92-
93-
94-
95-
96105
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace Payfast\Payfast\Block;
2+
3+
use Magento\Framework\Phrase;
4+
use Magento\Payment\Block\ConfigurableInfo;
5+
6+
class Info extends ConfigurableInfo
7+
{
8+
/**
9+
* Returns label
10+
*
11+
* @param string $field
12+
* @return Phrase
13+
*/
14+
protected function getLabel($field): Phrase
15+
{
16+
return __($field);
17+
}
18+
}

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@
66
*/
77
namespace Payfast\Payfast\Block\Payment;
88

9+
use Magento\Framework\View\Element\Template\Context;
10+
use Payfast\Payfast\Model\InfoFactory;
11+
912
/**
1013
* PayFast common payment info block
1114
* Uses default templates
1215
*/
1316
class Info extends \Magento\Payment\Block\Info
1417
{
1518
/**
16-
* @var \Payfast\Payfast\Model\InfoFactory
19+
* @var InfoFactory
1720
*/
1821
protected $_payfastInfoFactory;
1922

2023
/**
21-
* @param \Magento\Framework\View\Element\Template\Context $context
22-
* @param \Magento\Payment\Model\Config $paymentConfig
23-
* @param \Payfast\Payfast\Model\InfoFactory $payfastInfoFactory
24-
* @param array $data
24+
* @param Context $context
25+
* @param InfoFactory $payfastInfoFactory
26+
* @param array $data
2527
*/
2628
public function __construct(
27-
\Magento\Framework\View\Element\Template\Context $context,
28-
\Magento\Payment\Model\Config $paymentConfig,
29-
\Payfast\Payfast\Model\InfoFactory $payfastInfoFactory,
29+
Context $context,
30+
InfoFactory $payfastInfoFactory,
3031
array $data = []
3132
) {
3233
$this->_payfastInfoFactory = $payfastInfoFactory;

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

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,61 @@
77

88
namespace Payfast\Payfast\Block\Payment;
99

10+
use Magento\Checkout\Model\Session;
11+
use Magento\Framework\Filesystem\Directory\ReadFactory;
12+
use Magento\Framework\Module\Dir\Reader;
13+
use Magento\Framework\View\Element\Template;
14+
use Magento\Framework\View\Element\Template\Context;
15+
use Magento\Sales\Model\OrderFactory;
16+
use Payfast\Payfast\Helper\Data;
17+
use Payfast\Payfast\Model\Payfast;
1018

11-
class Request extends \Magento\Framework\View\Element\Template
19+
class Request extends Template
1220
{
1321

14-
/** @var \Payfast\Payfast\Model\Payfast $_paymentMethod*/
22+
/**
23+
* @var Payfast $_paymentMethod
24+
*/
1525
protected $_paymentMethod;
1626

1727
/**
18-
* @var \Magento\Sales\Model\OrderFactory
28+
* @var OrderFactory
1929
*/
2030
protected $_orderFactory;
2131

2232
/**
23-
* @var \Magento\Checkout\Model\Session
33+
* @var Session
2434
*/
2535
protected $_checkoutSession;
2636

27-
/** @var \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory*/
37+
/**
38+
* @var ReadFactory $readFactory
39+
*/
2840
protected $readFactory;
2941

30-
/** @var \Magento\Framework\Module\Dir\Reader $reader */
42+
/**
43+
* @var Reader $reader
44+
*/
3145
protected $reader;
3246

3347
/**
34-
* @param \Magento\Framework\View\Element\Template\Context $context
35-
* @param \Magento\Sales\Model\OrderFactory $orderFactory
36-
* @param \Magento\Checkout\Model\Session $checkoutSession
37-
* @param \Payfast\Payfast\Helper\Data $pfHelper
38-
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
39-
* @param \Magento\Framework\Module\Dir\Reader $reader
40-
* @param \Payfast\Payfast\Model\Payfast $paymentMethod
41-
* @param array $data
48+
* @param Context $context
49+
* @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
4256
*/
4357
public function __construct(
44-
\Magento\Framework\View\Element\Template\Context $context,
45-
\Magento\Sales\Model\OrderFactory $orderFactory,
46-
\Magento\Checkout\Model\Session $checkoutSession,
47-
\Payfast\Payfast\Helper\Data $pfHelper,
48-
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
49-
\Magento\Framework\Module\Dir\Reader $reader,
50-
\Payfast\Payfast\Model\Payfast $paymentMethod,
58+
Context $context,
59+
OrderFactory $orderFactory,
60+
Session $checkoutSession,
61+
Data $pfHelper,
62+
ReadFactory $readFactory,
63+
Reader $reader,
64+
Payfast $paymentMethod,
5165
array $data = []
5266
) {
5367
$this->_hssHelper = $pfHelper;
@@ -63,14 +77,13 @@ public function __construct(
6377
public function _prepareLayout()
6478
{
6579
$this->setMessage('Redirecting to Payfast')
66-
->setId( 'payfast_checkout' )
67-
->setName( 'payfast_checkout' )
68-
->setFormMethod( 'POST' )
80+
->setId('payfast_checkout')
81+
->setName('payfast_checkout')
82+
->setFormMethod('POST')
6983
->setFormAction($this->_paymentMethod->getPayFastUrl())
7084
->setFormData($this->_paymentMethod->getStandardCheckoutFormFields())
7185
->setSubmitForm('<script type="text/javascript">document.getElementById( "payfast_checkout" ).submit();</script>');
7286

7387
return parent::_prepareLayout(); // TODO: Change the autogenerated stub
7488
}
75-
7689
}

0 commit comments

Comments
 (0)