-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Worldpay/release-v2.4.1-rc1220
Release v2.4.1 rc1220
- Loading branch information
Showing
110 changed files
with
6,833 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
<?php | ||
/** | ||
* @copyright 2017 Sapient | ||
*/ | ||
namespace Sapient\Worldpay\Block; | ||
|
||
class Addnewcard extends \Magento\Framework\View\Element\Template | ||
{ | ||
/** | ||
* @var \Sapient\Worldpay\Model\SavedTokenFactory | ||
*/ | ||
protected $_savecard; | ||
/** | ||
* @var \Magento\Customer\Model\Session | ||
*/ | ||
protected $_customerSession; | ||
/** | ||
* @var array | ||
*/ | ||
protected static $_months; | ||
/** | ||
* @var array | ||
*/ | ||
protected static $_expiryYears; | ||
/** | ||
* Constructor | ||
* | ||
* @param \Magento\Backend\Block\Template\Context $context, | ||
* @param \Sapient\Worldpay\Model\SavedTokenFactory $savecard, | ||
* @param \Magento\Customer\Model\Session $customerSession, | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
//\Sapient\Worldpay\Model\SavedTokenFactory $savecard, | ||
\Magento\Customer\Model\Session $customerSession, | ||
\Sapient\Worldpay\Helper\Data $worldpayHelper, | ||
\Magento\Customer\Helper\Session\CurrentCustomerAddress $currentCustomerAddress, | ||
\Magento\Customer\Model\Address\Config $addressConfig, | ||
\Magento\Customer\Model\Address\Mapper $addressMapper, | ||
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, | ||
\Magento\Framework\Message\ManagerInterface $messageManager, | ||
\Magento\Integration\Model\Oauth\TokenFactory $tokenModelFactory, | ||
\Magento\Store\Model\StoreManagerInterface $storeManager, | ||
array $data = [] | ||
) { | ||
//$this->_savecard = $savecard; | ||
$this->_customerSession = $customerSession; | ||
$this->worldpayHelper = $worldpayHelper; | ||
$this->currentCustomerAddress = $currentCustomerAddress; | ||
$this->_addressConfig = $addressConfig; | ||
$this->addressMapper = $addressMapper; | ||
$this->scopeConfig = $scopeConfig; | ||
$this->_messageManager = $messageManager; | ||
$this->_tokenModelFactory = $tokenModelFactory; | ||
$this->_storeManager = $storeManager; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
public function requireCvcEnabled() | ||
{ | ||
return $this->worldpayHelper->isCcRequireCVC(); | ||
} | ||
|
||
/** | ||
* Get Store code | ||
* | ||
* @return string | ||
*/ | ||
public function getStoreCode() | ||
{ | ||
return $this->_storeManager->getStore()->getCode(); | ||
} | ||
|
||
public function getSessionId() | ||
{ | ||
return $this->_customerSession->getSessionId(); | ||
} | ||
public function getCustomerToken() | ||
{ | ||
$customerId = $this->_customerSession->getCustomer()->getId(); | ||
$customerToken = $this->_tokenModelFactory->create(); | ||
return $customerToken->createCustomerToken($customerId)->getToken(); | ||
} | ||
/** | ||
* Render an address as HTML and return the result | ||
* | ||
* @param AddressInterface $address | ||
* @return string | ||
*/ | ||
public function getPrimaryBillingAddressHtml() | ||
{ | ||
/** @var \Magento\Customer\Block\Address\Renderer\RendererInterface $renderer */ | ||
$address = $this->currentCustomerAddress->getDefaultBillingAddress(); | ||
|
||
if ($address) { | ||
$renderer = $this->_addressConfig->getFormatByCode('html')->getRenderer(); | ||
return $renderer->renderArray($this->addressMapper->toFlatArray($address)); | ||
} else { | ||
return $this->escapeHtml(__('You have not set a default billing address.')); | ||
} | ||
} | ||
|
||
public function getCCtypes() | ||
{ | ||
$cctypes = $this->worldpayHelper->getCcTypes(); | ||
return $cctypes; | ||
} | ||
|
||
public function getCheckoutSpecificLabel($labelcode) | ||
{ | ||
$data = $this->worldpayHelper->getCheckoutLabelbyCode($labelcode); | ||
return $data; | ||
} | ||
|
||
/** | ||
* Helps to build year html dropdown | ||
* | ||
* @return array | ||
*/ | ||
public function getMonths() | ||
{ | ||
if (!self::$_months) { | ||
self::$_months = ['' => __($this->getCheckoutLabelbyCode('CO6') ? | ||
$this->getCheckoutLabelbyCode('CO6') : 'Month')]; | ||
for ($i = 1; $i < 13; $i++) { | ||
$month = str_pad($i, 2, '0', STR_PAD_LEFT); | ||
self::$_months[$month] = date("$i - F", mktime(0, 0, 0, $i, 1)); | ||
} | ||
} | ||
|
||
return self::$_months; | ||
} | ||
|
||
public function getAccountLabelbyCode($labelCode) | ||
{ | ||
return $this->worldpayHelper->getAccountLabelbyCode($labelCode); | ||
} | ||
|
||
public function getCheckoutLabelbyCode($labelCode) | ||
{ | ||
return $this->worldpayHelper->getCheckoutLabelbyCode($labelCode); | ||
} | ||
/** | ||
* Helps to build year html dropdown | ||
* | ||
* @return array | ||
*/ | ||
public function getExpiryYears() | ||
{ | ||
if (!self::$_expiryYears) { | ||
self::$_expiryYears = ['' => __($this->getCheckoutLabelbyCode('CO7') | ||
? $this->getCheckoutLabelbyCode('CO7') : 'Year')]; | ||
$year = date('Y'); | ||
$endYear = ($year + 20); | ||
while ($year < $endYear) { | ||
self::$_expiryYears[$year] = $year; | ||
$year++; | ||
} | ||
} | ||
return self::$_expiryYears; | ||
} | ||
|
||
public function getDisclaimerMessageEnable() | ||
{ | ||
|
||
return (bool) $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer' | ||
. '/stored_credentials_message_enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); | ||
|
||
} | ||
public function getDisclaimerText() | ||
{ | ||
|
||
return $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer/' | ||
. 'stored_credentials_disclaimer_message', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); | ||
|
||
} | ||
|
||
public function getDisclaimerMessageMandatory() | ||
{ | ||
|
||
return (bool) $this->_scopeConfig->getValue('worldpay/tokenization/configure_disclaimer/' | ||
. 'stored_credentials_flag', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); | ||
|
||
} | ||
|
||
public function getStoredCredentialsEnabledValue() | ||
{ | ||
return (bool) $this->_scopeConfig->getValue( | ||
'worldpay/tokenization/save_stored_credentials', | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE | ||
); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/** | ||
* @copyright 2020 Sapient | ||
*/ | ||
namespace Sapient\Worldpay\Block\Adminhtml\Form\Field; | ||
|
||
class KlarnaCountries extends \Sapient\Worldpay\Block\Form\Field\FieldArray\KlarnaSubscriptionArray | ||
{ | ||
/** | ||
* @var \Sapient\Worldpay\Block\Adminhtml\Form\Field\KlarnaCountriesList | ||
*/ | ||
protected $_klarnaCountriesList; | ||
|
||
/** | ||
* Get activation options. | ||
* | ||
* @return \Sapient\Worldpay\Block\Adminhtml\Form\Field\Activation | ||
*/ | ||
protected function _getKlarnaCountriesRenderer() | ||
{ | ||
if (!$this->_klarnaCountriesList) { | ||
$this->_klarnaCountriesList = $this->getLayout()->createBlock( | ||
\Sapient\Worldpay\Block\Adminhtml\Form\Field\KlarnaCountriesList::class, | ||
'', | ||
['data' => ['is_render_to_js_template' => true]] | ||
); | ||
$this->_klarnaCountriesList->setClass('required-entry'); | ||
} | ||
|
||
return $this->_klarnaCountriesList; | ||
} | ||
|
||
/** | ||
* Prepare to render. | ||
* | ||
* @return void | ||
*/ | ||
protected function _prepareToRender() | ||
{ | ||
$this->addColumn( | ||
'worldpay_klarna_subscription', | ||
[ | ||
'label' => __('Country'), | ||
'style' => 'width:200px !important', | ||
'class' => 'required-entry', | ||
'renderer' => $this->_getKlarnaCountriesRenderer() | ||
] | ||
); | ||
|
||
$this->addColumn( | ||
'subscription_days', | ||
['label' => __('Subscription Days'),'style' => 'width:100px','class' => 'required-entry'] | ||
); | ||
|
||
$this->_addAfter = false; | ||
$this->_addButtonLabel = __('Add'); | ||
} | ||
|
||
/** | ||
* Prepare existing row data object. | ||
* | ||
* @param \Magento\Framework\DataObject $row | ||
* @return void | ||
*/ | ||
protected function _prepareArrayRow(\Magento\Framework\DataObject $row) | ||
{ | ||
$options = []; | ||
$customAttribute = $row->getData('worldpay_klarna_subscription'); | ||
$key = 'option_' . $this->_getKlarnaCountriesRenderer()->calcOptionHash($customAttribute); | ||
$options[$key] = 'selected="selected"'; | ||
$row->setData('option_extra_attrs', $options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* @copyright 2020 Sapient | ||
*/ | ||
namespace Sapient\Worldpay\Block\Adminhtml\Form\Field; | ||
|
||
class KlarnaCountriesList extends \Magento\Framework\View\Element\Html\Select | ||
{ | ||
|
||
/** | ||
* Paymentmethod constructor. | ||
* | ||
* @param \Magento\Framework\View\Element\Context $context | ||
* @param \Sapient\Worldpay\Model\Config\Source\KlarnaCountries $klarnaCountries | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\View\Element\Context $context, | ||
\Sapient\Worldpay\Model\Config\Source\KlarnaCountries $klarnaCountries, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->klarnaCountries = $klarnaCountries; | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* @return Sapient\Worldpay\Block\Adminhtml\Form\Field\KlarnaCountries | ||
*/ | ||
public function setInputName($value) | ||
{ | ||
return $this->setName($value); | ||
} | ||
|
||
/** | ||
* Parse to html. | ||
* | ||
* @return mixed | ||
*/ | ||
public function _toHtml() | ||
{ | ||
|
||
$paymetType= $this->getAllPaymentType() ; | ||
|
||
foreach ($paymetType as $paymentname => $paymentTitle) { | ||
$this->addOption($paymentname, $paymentTitle); | ||
} | ||
|
||
return parent::_toHtml(); | ||
} | ||
|
||
/** | ||
* Retrive all the payment type. | ||
* | ||
* @return mixed | ||
*/ | ||
private function getAllPaymentType() | ||
{ | ||
|
||
$result= []; | ||
$result['']=__('Select'); | ||
$paymetType= $this->klarnaCountries->toOptionArray(); | ||
foreach ($paymetType as $methods) { | ||
$result[$methods['value']]= $methods['label']; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.