Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tig-mvonk committed Dec 19, 2022
2 parents 7198ade + bc04ced commit 191c0d0
Show file tree
Hide file tree
Showing 37 changed files with 1,470 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Config/Support/SupportTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

class SupportTab extends Template implements RendererInterface
{
const POSTNL_VERSION = '1.12.5';
const POSTNL_VERSION = '1.12.6';

const XPATH_SUPPORTED_MAGENTO_VERSION = 'tig_postnl/supported_magento_version';

Expand Down
118 changes: 118 additions & 0 deletions Block/Adminhtml/Config/Validate/InternationalAddressValidation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
namespace TIG\PostNL\Block\Adminhtml\Config\Validate;

use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

class InternationalAddressValidation extends Field
{
/** @var string */
//@codingStandardsIgnoreLine
protected $_template = 'TIG_PostNL::config/validate/internationalAddressValidation.phtml';

/**
* @param Context $context
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
Context $context,
array $data = [],
?SecureHtmlRenderer $secureRenderer = null
) {
parent::__construct($context, $data, $secureRenderer);
}

/**
* Remove scope label
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$element->unsScope();
$element->unsCanUseWebsiteValue();
$element->unsCanUseDefaultValue();

return parent::render($element);
}

/**
* Return element html
*
* @param AbstractElement $element
* @return string
*/
//@codingStandardsIgnoreLine
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}

/**
* Return ajax url for collect button
*
* @return string
*/
public function getAjaxUrl()
{
return $this->getUrl('postnl/config_validate/internationalAddressValidation');
}

/**
* Generate collect button html
*
* @return string
*
* @throws LocalizedException
*/
public function getButtonHtml()
{
$layout = $this->getLayout();
$buttonBlock = $layout->createBlock(Button::class);
$buttonBlock->setData(
[
'id' => 'validate_international_address_check',
//@codingStandardsIgnoreLine
'label' => __('Validate International Address Check'),
]
);

return $buttonBlock->toHtml();
}
}
61 changes: 61 additions & 0 deletions Config/CheckoutConfiguration/IsInternationalAddressActive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
namespace TIG\PostNL\Config\CheckoutConfiguration;

use TIG\PostNL\Config\Provider\Webshop;

class IsInternationalAddressActive implements CheckoutConfigurationInterface
{
/**
* @var Webshop
*/
private $webshopConfig;

/**
* IsInternationalAddressActive constructor
*
* @param Webshop $webshop
*/
public function __construct(
Webshop $webshop
) {
$this->webshopConfig = $webshop;
}

/**
* @return bool
*/
public function getValue()
{
return (bool) $this->webshopConfig->getIsInternationalAddressEnabled() && $this->webshopConfig->getIsAddressCheckEnabled();
}
}
3 changes: 2 additions & 1 deletion Config/CheckoutConfiguration/Urls.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public function getValue()
'deliveryoptions_locations' => $this->getUrl('postnl/deliveryoptions/locations'),
'deliveryoptions_save' => $this->getUrl('postnl/deliveryoptions/save'),
'pakjegemak_address' => $this->getUrl('postnl/pakjegemak/address'),
'address_postcode' => $this->getUrl('postnl/address/postcode')
'address_postcode' => $this->getUrl('postnl/address/postcode'),
'international_address' => $this->getUrl('postnl/international/address')
];
}

Expand Down
38 changes: 36 additions & 2 deletions Config/Provider/DefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@

class DefaultConfiguration extends AbstractConfigProvider
{
const XPATH_ENDPOINTS_API_BASE_URL = 'tig_postnl/endpoints/api_base_url';
//Base API URLs are used for SOAP calls that are used for most PostNL API calls
const XPATH_ENDPOINTS_API_BASE_URL = 'tig_postnl/endpoints/api_base_url';
const XPATH_ENDPOINTS_TEST_API_BASE_URL = 'tig_postnl/endpoints/test_api_base_url';

const XPATH_ENDPOINTS_API_ADDRESS_URL = 'tig_postnl/endpoints/address_api_url';
//Address API URLs are used for postcode check REST calls
const XPATH_ENDPOINTS_API_ADDRESS_URL = 'tig_postnl/endpoints/address_api_url';
const XPATH_ENDPOINTS_TEST_API_ADDRESS_URL = 'tig_postnl/endpoints/address_test_api_url';

//API URLs are used for other REST calls, such as the International Address Check
const XPATH_ENDPOINTS_API_URL = 'tig_postnl/endpoints/api_url';
const XPATH_ENDPOINTS_TEST_API_URL = 'tig_postnl/endpoints/test_api_url';

const XPATH_BARCODE_GLOBAL_TYPE = 'postnl/barcode/global_type';
const XPATH_BARCODE_GLOBAL_RANGE = 'postnl/barcode/global_range';

Expand Down Expand Up @@ -141,4 +147,32 @@ public function getBarcodeGlobalRange()
{
return $this->getConfigFromXpath(static::XPATH_BARCODE_GLOBAL_RANGE);
}

/**
* @return string
*/
public function getModusApiUrl()
{
if ($this->accountConfiguration->isModusLive()) {
return $this->getApiUrl();
}

return $this->getTestApiUrl();
}

/**
* @return string
*/
public function getApiUrl()
{
return $this->getConfigFromXpath(static::XPATH_ENDPOINTS_API_URL);
}

/**
* @return string
*/
public function getTestApiUrl()
{
return $this->getConfigFromXpath(static::XPATH_ENDPOINTS_TEST_API_URL);
}
}
10 changes: 10 additions & 0 deletions Config/Provider/Webshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,18 @@ class Webshop extends AbstractConfigProvider
const XPATH_ADDRESS_CHECK_ENABLED = 'tig_postnl/addresscheck/enable_postcodecheck';
const XPATH_ADDRESS_CHECK_COMPATIBLE = 'tig_postnl/addresscheck/checkout_compatible';

const XPATH_INTERNATIONAL_ADDRESS_ENABLED = 'tig_postnl/internationaladdressoptions/enable';

const XPATH_POSTCODE_ADDRESS_CHECK_ENABLED = 'tig_postcode/configuration/modus';

/**
* @return bool
*/
public function getIsInternationalAddressEnabled()
{
return $this->getConfigFromXpath(self::XPATH_INTERNATIONAL_ADDRESS_ENABLED);
}

/**
* @return bool
*/
Expand Down
1 change: 1 addition & 0 deletions Controller/Address/Postcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function execute()

$this->postcodeService->updateRequestData($params);
$result = $this->postcodeService->call();
$result = $this->handler->convertResponse($result);

if ($result === false) {
return $this->returnJson($this->getErrorResponse(false, __('Zipcode/housenumber combination not found')));
Expand Down
Loading

0 comments on commit 191c0d0

Please sign in to comment.