Skip to content

Commit defb5b3

Browse files
2023-11-15: v2.5.2
- Tested on Magento 2.4.6. - Refactor in keeping with Magento 2 PHP code standards. - Update composer requirements. - Add option to force Payment Type selection. - Add Apple Pay, Samsung Pay and RCS Payment Types. - Fix redirection issues to payment page (CSP whitelist).
1 parent dffa978 commit defb5b3

File tree

92 files changed

+4537
-3234
lines changed

Some content is hidden

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

92 files changed

+4537
-3234
lines changed

paygate/paygate-payweb-gateway/Api/Data/PayWebApiInterface.php renamed to Api/Data/PayWebApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2022 PayGate (Pty) Ltd
3+
* Copyright (c) 2023 Payfast (Pty) Ltd
44
*
55
* Author: App Inlet (Pty) Ltd
66
*
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2022 PayGate (Pty) Ltd
3+
* Copyright (c) 2023 Payfast (Pty) Ltd
44
*
55
* Author: App Inlet (Pty) Ltd
66
*
@@ -9,17 +9,19 @@
99

1010
namespace PayGate\PayWeb\Api;
1111

12+
use Magento\Framework\Controller\Result\Json;
13+
1214
interface PayWebApiManagementInterface
1315
{
1416
/**
15-
* get PayWeb Api data.
17+
* Get PayWeb Api data.
1618
*
1719
* @param int $id Left-hand operand.
1820
* @param int $quote_id
1921
*
20-
* @return string
22+
* @return Json
2123
* @api
2224
* @noinspection PhpUnused
2325
*/
24-
public function getApiData(int $id, int $quote_id): string;
26+
public function getApiData(int $id, int $quote_id): Json;
2527
}

paygate/paygate-payweb-gateway/Block/Customer/CardRenderer.php renamed to Block/Customer/CardRenderer.php

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
2-
/** @noinspection PhpUnused */
2+
/**
3+
* @noinspection PhpUnused
4+
*/
35

4-
/** @noinspection PhpUndefinedNamespaceInspection */
6+
/**
7+
* @noinspection PhpUndefinedNamespaceInspection
8+
*/
59

6-
/** @noinspection PhpUndefinedNamespaceInspection */
10+
/**
11+
* @noinspection PhpUndefinedNamespaceInspection
12+
*/
713

814
/*
9-
* Copyright (c) 2022 PayGate (Pty) Ltd
15+
* Copyright (c) 2023 Payfast (Pty) Ltd
1016
*
1117
* Author: App Inlet (Pty) Ltd
1218
*
@@ -23,10 +29,10 @@ class CardRenderer extends AbstractCardRenderer
2329
/**
2430
* Can render specified token
2531
*
26-
* @param PaymentTokenInterface $token
32+
* @param PaymentTokenInterface $token
2733
*
28-
* @return boolean
29-
* @since 100.1.0
34+
* @return boolean
35+
* @since 100.1.0
3036
* @noinspection PhpUnused
3137
*/
3238
public function canRender(PaymentTokenInterface $token): bool
@@ -35,54 +41,59 @@ public function canRender(PaymentTokenInterface $token): bool
3541
}
3642

3743
/**
38-
* @return string
39-
* @since 100.1.0
44+
* Returns Token Masked CC
45+
*
46+
* @return string
47+
* @since 100.1.0
4048
* @noinspection PhpUnused
41-
* @noinspection PhpUndefinedMethodInspection
4249
*/
4350
public function getNumberLast4Digits(): string
4451
{
4552
return $this->getTokenDetails()['maskedCC'];
4653
}
4754

4855
/**
49-
* @return string
50-
* @since 100.1.0
56+
* Gets Token Expiration Date
57+
*
58+
* @return string
59+
* @since 100.1.0
5160
* @noinspection PhpUnused
52-
* @noinspection PhpUndefinedMethodInspection
5361
*/
5462
public function getExpDate(): string
5563
{
5664
return $this->getTokenDetails()['expirationDate'];
5765
}
5866

5967
/**
60-
* @return string
61-
* @since 100.1.0
68+
* Gets the token icon URL
69+
*
70+
* @return string
71+
* @since 100.1.0
6272
* @noinspection PhpUnused
63-
* @noinspection PhpUndefinedMethodInspection
6473
*/
6574
public function getIconUrl(): string
6675
{
6776
return $this->getIconForType($this->getTokenDetails()['type'])['url'];
6877
}
6978

7079
/**
71-
* @return int
72-
* @since 100.1.0
80+
* Gets the token icon height
81+
*
82+
* @return int
83+
* @since 100.1.0
7384
* @noinspection PhpUnused
74-
* @noinspection PhpUndefinedMethodInspection
7585
*/
7686
public function getIconHeight(): int
7787
{
7888
return $this->getIconForType($this->getTokenDetails()['type'])['height'];
7989
}
8090

8191
/**
82-
* @return int
83-
* @since 100.1.0
92+
* Gets the token icon width
93+
*
94+
* @return int
95+
* @since 100.1.0
8496
* @noinspection PhpUnused
85-
* @noinspection PhpUndefinedMethodInspection
8697
*/
8798
public function getIconWidth(): int
8899
{

paygate/paygate-payweb-gateway/Block/Form.php renamed to Block/Form.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
2-
/** @noinspection PhpMissingFieldTypeInspection */
2+
/**
3+
* @noinspection PhpMissingFieldTypeInspection
4+
*/
35

4-
/** @noinspection PhpUndefinedNamespaceInspection */
6+
/**
7+
* @noinspection PhpUndefinedNamespaceInspection
8+
*/
59

610
/**
7-
* Copyright (c) 2022 PayGate (Pty) Ltd
11+
* Copyright (c) 2023 Payfast (Pty) Ltd
812
*
913
* Author: App Inlet (Pty) Ltd
1014
*
@@ -50,6 +54,8 @@ class Form extends \Magento\Payment\Block\Form
5054
protected ?Config $_config;
5155

5256
/**
57+
* test
58+
*
5359
* @var bool
5460
*/
5561
protected $_isScopePrivate;
@@ -64,14 +70,13 @@ class Form extends \Magento\Payment\Block\Form
6470
*/
6571
protected $_logger;
6672

67-
6873
/**
69-
* @param Context $context
70-
* @param ConfigFactory $paygateConfigFactory
74+
* @param Context $context
75+
* @param ConfigFactory $paygateConfigFactory
7176
* @param ResolverInterface $localeResolver
72-
* @param Data $paygateData
73-
* @param CurrentCustomer $currentCustomer
74-
* @param array $data
77+
* @param Data $paygateData
78+
* @param CurrentCustomer $currentCustomer
79+
* @param array $data
7580
*/
7681
public function __construct(
7782
Context $context,
@@ -110,7 +115,7 @@ public function getMethodCode(): string|Paygate
110115
/**
111116
* Set template and redirect message
112117
*
113-
* @return null
118+
* @return null
114119
* @noinspection PhpUnused
115120
*/
116121
protected function _construct()
@@ -122,5 +127,4 @@ protected function _construct()
122127

123128
return null;
124129
}
125-
126130
}

paygate/paygate-payweb-gateway/Block/Payment/Info.php renamed to Block/Payment/Info.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
2-
/** @noinspection PhpPropertyOnlyWrittenInspection */
2+
/**
3+
* @noinspection PhpPropertyOnlyWrittenInspection
4+
*/
35

4-
/** @noinspection PhpUndefinedNamespaceInspection */
6+
/**
7+
* @noinspection PhpUndefinedNamespaceInspection
8+
*/
59

610
/*
7-
* Copyright (c) 2022 PayGate (Pty) Ltd
11+
* Copyright (c) 2023 Payfast (Pty) Ltd
812
*
913
* Author: App Inlet (Pty) Ltd
1014
*
@@ -18,7 +22,7 @@
1822
use PayGate\PayWeb\Model\InfoFactory;
1923

2024
/**
21-
* PayGate common payment info block
25+
* Paygate common payment info block
2226
* Uses default templates
2327
*/
2428
class Info extends \Magento\Payment\Block\Info
@@ -27,13 +31,17 @@ class Info extends \Magento\Payment\Block\Info
2731
* @var InfoFactory
2832
*/
2933
protected InfoFactory $_PaygateInfoFactory;
34+
35+
/**
36+
* @var Config
37+
*/
3038
private Config $_paymentConfig;
3139

3240
/**
33-
* @param Context $context
34-
* @param Config $paymentConfig
41+
* @param Context $context
42+
* @param Config $paymentConfig
3543
* @param InfoFactory $PaygateInfoFactory
36-
* @param array $data
44+
* @param array $data
3745
*/
3846
public function __construct(
3947
Context $context,
@@ -45,5 +53,4 @@ public function __construct(
4553
$this->_paymentConfig = $paymentConfig;
4654
parent::__construct($context, $data);
4755
}
48-
4956
}

paygate/paygate-payweb-gateway/Block/Payment/Request.php renamed to Block/Payment/Request.php

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
2-
/** @noinspection PhpMissingFieldTypeInspection */
2+
/**
3+
* @noinspection PhpMissingFieldTypeInspection
4+
*/
35

4-
/** @noinspection PhpUnused */
6+
/**
7+
* @noinspection PhpUnused
8+
*/
59

6-
/** @noinspection PhpUndefinedNamespaceInspection */
10+
/**
11+
* @noinspection PhpUndefinedNamespaceInspection
12+
*/
713

814
/**
9-
* Copyright (c) 2022 PayGate (Pty) Ltd
15+
* Copyright (c) 2023 Payfast (Pty) Ltd
1016
*
1117
* Author: App Inlet (Pty) Ltd
1218
*
@@ -50,16 +56,20 @@ class Request extends Template
5056
* @var Reader $reader
5157
*/
5258
protected Reader $reader;
59+
60+
/**
61+
* @var true
62+
*/
5363
protected $_isScopePrivate;
5464

5565
/**
56-
* @param Context $context
66+
* @param Context $context
5767
* @param OrderFactory $orderFactory
58-
* @param Session $checkoutSession
59-
* @param ReadFactory $readFactory
60-
* @param Reader $reader
61-
* @param PayGate $paymentMethod
62-
* @param array $data
68+
* @param Session $checkoutSession
69+
* @param ReadFactory $readFactory
70+
* @param Reader $reader
71+
* @param PayGate $paymentMethod
72+
* @param array $data
6373
*
6474
* @noinspection PhpUnused
6575
*/
@@ -81,22 +91,24 @@ public function __construct(
8191
$this->_paymentMethod = $paymentMethod;
8292
}
8393

84-
/** @noinspection PhpUnused
94+
/**
95+
* Builds submit form
96+
*
97+
* @noinspection PhpUnused
8598
* @noinspection PhpUndefinedMethodInspection
8699
*/
87100
public function _prepareLayout()
88101
{
89-
$this->setMessage('Redirecting to PayGate')
90-
->setId('paygate_checkout')
91-
->setName('paygate_checkout')
92-
->setFormMethod('POST')
93-
->setFormAction('https://secure.paygate.co.za/payweb3/process.trans')
94-
->setFormData($this->_paymentMethod->getStandardCheckoutFormFields())
95-
->setSubmitForm(
96-
'<script type="text/javascript">document.getElementById( "paygate_checkout" ).submit();</script>'
97-
);
102+
$this->setMessage('Redirecting to Paygate')
103+
->setId('paygate_checkout')
104+
->setName('paygate_checkout')
105+
->setFormMethod('POST')
106+
->setFormAction('https://secure.paygate.co.za/payweb3/process.trans')
107+
->setFormData($this->_paymentMethod->getStandardCheckoutFormFields())
108+
->setSubmitForm(
109+
'<script type="text/javascript">document.getElementById( "paygate_checkout" ).submit();</script>'
110+
);
98111

99112
return parent::_prepareLayout();
100113
}
101-
102114
}

0 commit comments

Comments
 (0)