Skip to content

Commit

Permalink
Version 2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
prestamodule committed Feb 21, 2023
1 parent dd1962c commit 957153e
Show file tree
Hide file tree
Showing 32 changed files with 106 additions and 115 deletions.
10 changes: 10 additions & 0 deletions Block/Checkout/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public function getCreditCards()
{
$result = [];
$cards = $this->getMethod()->getCards();

if ($this->getMethod()->getConfigData('cctypes') == null) {
return $result;
}

$selected = explode(',', $this->getMethod()->getConfigData('cctypes'));
foreach ($cards as $code => $card) {
if (in_array($code, $selected)) {
Expand All @@ -59,6 +64,11 @@ public function getCards()
{
$result = [];
$cards = $this->getMethod()->getCards();

if ($this->getMethod()->getConfigData('cctypes') == null) {
return $result;
}

$selected = explode(',', $this->getMethod()->getConfigData('cctypes'));
foreach ($cards as $code => $card) {
if (in_array($code, $selected)) {
Expand Down
15 changes: 13 additions & 2 deletions Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public function getCreditCards()
{
$result = [];
$cards = $this->getMethod()->getCards();

if ($this->getMethod()->getConfigData('cctypes') == null) {
return $result;
}

$selected = explode(',', $this->getMethod()->getConfigData('cctypes'));
foreach ($cards as $code => $card) {
if (in_array($code, $selected)) {
Expand All @@ -78,6 +83,11 @@ public function getCreditCards()

public function getPayboxData()
{

if (empty($this->getInfo()->getPbxepAuthorization())) {
return [];
}

return unserialize($this->getInfo()->getPbxepAuthorization());
}

Expand All @@ -94,7 +104,6 @@ public function getPayboxConfig()
public function getCardImageUrl()
{
$data = $this->getPayboxData();
$cards = $this->getCreditCards();
if (!isset($data['cardType'])) {
return null;
}
Expand All @@ -107,13 +116,15 @@ public function getCardImageUrl()
public function getCardImageLabel()
{
$data = $this->getPayboxData();
$cards = $this->getCreditCards();
if (!isset($data['cardType'])) {
return null;
}

$cards = $this->getCreditCards();
if (!isset($cards[$data['cardType']])) {
return null;
}

$card = $cards[$data['cardType']];
return $card['label'];
}
Expand Down
4 changes: 2 additions & 2 deletions Block/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Redirect extends \Magento\Framework\View\Element\Template

public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [],
\Paybox\Epayment\Helper\Data $helper
\Paybox\Epayment\Helper\Data $helper,
array $data = []
) {
parent::__construct($context, $data);

Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Change Log
## [2.0.5] 2022-07-12
- Order button on wait
- various minor bugfixes
## [2.0.6] 2023-02-08
- Add 3DS exemption
- Update 3DSv2 fields
- HMAC auth
- Fix Magento 2.4.5 & PHP 8 compatibility
- Set CB mode to simple mode instead of multi
- Fix possible invalid value for CountryCode

## [2.0.4] 2021-03-16
- fixing name of model Creditagricole
Expand Down
5 changes: 5 additions & 0 deletions Gateway/Request/AuthorizationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public function build(array $buildSubject)
$values['PBX_SHOPPINGCART'] = $payment->getXmlShoppingCartInformation($order);
$values['PBX_BILLING'] = $payment->getXmlBillingInformation($order);

// Check for 3DS exemption
if ($payment->getConfigData('exemption_3ds_max_amount') && $orderAmount <= $payment->getConfigData('exemption_3ds_max_amount')) {
$values['PBX_SOUHAITAUTHENT'] = '02';
}

// Sort parameters for simpler debug
ksort($values);

Expand Down
5 changes: 5 additions & 0 deletions Model/Paybox.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ public function buildSystemParams(Order $order, AbstractPayment $payment)
$values['PBX_SHOPPINGCART'] = $payment->getXmlShoppingCartInformation($order);
$values['PBX_BILLING'] = $payment->getXmlBillingInformation($order);

// Check for 3DS exemption
if ($payment->getConfigData('exemption_3ds_max_amount') && $orderAmount <= $payment->getConfigData('exemption_3ds_max_amount')) {
$values['PBX_SOUHAITAUTHENT'] = '02';
}

// Sort parameters for simpler debug
ksort($values);

Expand Down
20 changes: 15 additions & 5 deletions Model/Payment/AbstractPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,12 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)

if ($this->getHasCctypes()) {
$cctypes = $this->getConfigData('cctypes', ($quote ? $quote->getStoreId() : null));
$cctypes = preg_replace('/NONE,?/', '', $cctypes);
if (!is_null($cctypes)) {
$cctypes = preg_replace('/NONE,?/', '', $cctypes);
}
return !empty($cctypes);
}

return true;
}
return false;
Expand Down Expand Up @@ -602,6 +605,7 @@ protected function formatTextValue($value, $type, $maxLength = null)
$value = preg_replace('/[^-. a-zA-Z0-9]/', '', $value);
break;
case 'ANS':
$value = $this->_objectManager->get('Magento\Framework\Filter\RemoveAccents')->filter($value);
break;
case 'N':
$value = preg_replace('/[^0-9.]/', '', $value);
Expand All @@ -625,7 +629,7 @@ protected function formatTextValue($value, $type, $maxLength = null)
}
}

return $value;
return trim($value);
}

/**
Expand Down Expand Up @@ -661,17 +665,23 @@ public function getXmlBillingInformation(Order $order)
// Retrieve billing address from order
$address = $order->getBillingAddress();

$firstName = $this->formatTextValue($address->getFirstName(), 'ANP', 22);
$lastName = $this->formatTextValue($address->getLastName(), 'ANP', 22);
$firstName = $this->formatTextValue($address->getFirstName(), 'ANS', 22);
$lastName = $this->formatTextValue($address->getLastName(), 'ANS', 22);
$addressLine1 = $this->formatTextValue($address->getStreetLine(1), 'ANS', 50);
$addressLine2 = $this->formatTextValue($address->getStreetLine(2), 'ANS', 50);
$zipCode = $this->formatTextValue($address->getPostcode(), 'ANS', 10);
$city = $this->formatTextValue($address->getCity(), 'ANS', 50);
$countryMapper = $this->_objectManager->get('Paybox\Epayment\Model\Iso3166Country');
$countryCode = (int)$countryMapper->getNumericCode($address->getCountryId());
$countryCodeFormat = '%03d';
if (empty($countryCode)) {
// Send empty string to CountryCode instead of 000
$countryCodeFormat = '%s';
$countryCode = '';
}

$xml = sprintf(
'<?xml version="1.0" encoding="utf-8"?><Billing><Address><FirstName>%s</FirstName><LastName>%s</LastName><Address1>%s</Address1><Address2>%s</Address2><ZipCode>%s</ZipCode><City>%s</City><CountryCode>%03d</CountryCode></Address></Billing>',
'<?xml version="1.0" encoding="utf-8"?><Billing><Address><FirstName>%s</FirstName><LastName>%s</LastName><Address1>%s</Address1><Address2>%s</Address2><ZipCode>%s</ZipCode><City>%s</City><CountryCode>' . $countryCodeFormat . '</CountryCode></Address></Billing>',
$firstName,
$lastName,
$addressLine1,
Expand Down
8 changes: 0 additions & 8 deletions Model/Payment/Cb.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,12 @@
class Cb extends AbstractPayment
{
const CODE = 'pbxep_cb';
const XML_PATH = 'payment/pbxep_cb/cctypes';

protected $_code = self::CODE;
protected $_hasCctypes = true;
protected $_allowManualDebit = true;
protected $_allowDeferredDebit = true;
protected $_allowRefund = true;

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->_scopeConfig->getValue(self::XML_PATH, $storeScope);
}

public function toOptionArray()
{
$result = [];
Expand Down
6 changes: 0 additions & 6 deletions Model/Payment/Financial.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ class Financial extends AbstractPayment
protected $_allowDeferredDebit = true;
protected $_allowRefund = true;

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->_scopeConfig->getValue(self::XML_PATH, $storeScope);
}

public function toOptionArray()
{
$result = [];
Expand Down
7 changes: 0 additions & 7 deletions Model/Payment/Paybuttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@
class Paybuttons extends AbstractPayment
{
const CODE = 'pbxep_paybuttons';
const XML_PATH = 'payment/pbxep_paybuttons/cctypes';

protected $_code = self::CODE;
protected $_hasCctypes = true;
protected $_allowManualDebit = true;
protected $_allowDeferredDebit = true;
protected $_allowRefund = true;

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->_scopeConfig->getValue(self::XML_PATH, $storeScope);
}

public function toOptionArray()
{
$result = [];
Expand Down
7 changes: 0 additions & 7 deletions Model/Payment/Prepaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@
class Prepaid extends AbstractPayment
{
const CODE = 'pbxep_prepaid';
const XML_PATH = 'payment/pbxep_prepaid/cctypes';

protected $_code = self::CODE;
protected $_hasCctypes = true;
protected $_allowManualDebit = true;
protected $_allowDeferredDebit = true;
protected $_allowRefund = true;

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->_scopeConfig->getValue(self::XML_PATH, $storeScope);
}

public function toOptionArray()
{
$result = [];
Expand Down
7 changes: 0 additions & 7 deletions Model/Payment/PrivateCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@
class PrivateCard extends AbstractPayment
{
const CODE = 'pbxep_private';
const XML_PATH = 'payment/pbxep_private/cctypes';

protected $_code = self::CODE;
protected $_hasCctypes = true;
protected $_allowManualDebit = true;
protected $_allowDeferredDebit = true;
protected $_allowRefund = true;

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->_scopeConfig->getValue(self::XML_PATH, $storeScope);
}

public function toOptionArray()
{
$result = [];
Expand Down
8 changes: 0 additions & 8 deletions Model/Payment/Threetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,12 @@
class Threetime extends AbstractPayment
{
const CODE = 'pbxep_threetime';
const XML_PATH = 'payment/pbxep_threetime/cctypes';

protected $_code = self::CODE;
protected $_hasCctypes = true;
protected $_allowManualDebit = true;
protected $_allowDeferredDebit = true;
protected $_allowRefund = true;

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->_scopeConfig->getValue(self::XML_PATH, $storeScope);
}

public function toOptionArray()
{
$result = [];
Expand Down
6 changes: 0 additions & 6 deletions Model/Ui/PbxepcbConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $
$this->scopeConfig = $scopeConfig;
}

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->scopeConfig->getValue(self::PAYMENT_METHOD_PBXEPCB_XML_PATH, $storeScope);
}

/**
* @return string
*/
Expand Down
5 changes: 5 additions & 0 deletions Model/Ui/PbxepcbConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public function getCards()

$cards = [];
$types = $pbxepcbConfig->getCards();

if (is_null($types)) {
return $cards;
}

if (!is_array($types)) {
$types = explode(',', $types);
}
Expand Down
6 changes: 0 additions & 6 deletions Model/Ui/PbxepfinancialConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $
$this->scopeConfig = $scopeConfig;
}

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->scopeConfig->getValue(self::PAYMENT_METHOD_PBXEPFINANCIAL_XML_PATH, $storeScope);
}

/**
* @return string
*/
Expand Down
5 changes: 5 additions & 0 deletions Model/Ui/PbxepfinancialConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function getCards()

$cards = [];
$types = $pbxepfinancialConfig->getCards();

if (is_null($types)) {
return $cards;
}

if (!is_array($types)) {
$types = explode(',', $types);
}
Expand Down
6 changes: 0 additions & 6 deletions Model/Ui/PbxeppaybuttonsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $
$this->scopeConfig = $scopeConfig;
}

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->scopeConfig->getValue(self::PAYMENT_METHOD_PBXEPPAYBUTTONS_XML_PATH, $storeScope);
}

/**
* @return string
*/
Expand Down
5 changes: 5 additions & 0 deletions Model/Ui/PbxeppaybuttonsConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function getCards()

$cards = [];
$types = $pbxeppaybuttonsConfig->getCards();

if (is_null($types)) {
return $cards;
}

if (!is_array($types)) {
$types = explode(',', $types);
}
Expand Down
6 changes: 0 additions & 6 deletions Model/Ui/PbxepprepaidConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $
$this->scopeConfig = $scopeConfig;
}

public function getReceipentEmail()
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
return $this->scopeConfig->getValue(self::PAYMENT_METHOD_PBXEPPREPAID_XML_PATH, $storeScope);
}

/**
* @return string
*/
Expand Down
5 changes: 5 additions & 0 deletions Model/Ui/PbxepprepaidConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function getCards()

$cards = [];
$types = $pbxepprepaidConfig->getCards();

if (is_null($types)) {
return $cards;
}

if (!is_array($types)) {
$types = explode(',', $types);
}
Expand Down
Loading

0 comments on commit 957153e

Please sign in to comment.