-
Notifications
You must be signed in to change notification settings - Fork 15
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 #51 from NikZh/publication-1.2.9
VIPPS-243: Publication v.1.2.9
- Loading branch information
Showing
31 changed files
with
1,154 additions
and
33 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,53 @@ | ||
<?php | ||
/** | ||
* Copyright 2018 Vipps | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
namespace Vipps\Payment\Block\PartialVoid\Order\Email; | ||
use Magento\Sales\Block\Order\Email\Items as OrderItems; | ||
use Magento\Sales\Model\Order; | ||
|
||
/** | ||
* Class Items | ||
* @package Vipps\Payment\Block\PartialVoid\Order\Email | ||
*/ | ||
class Items extends OrderItems | ||
{ | ||
/** | ||
* @var Order | ||
*/ | ||
private $order; | ||
|
||
/** | ||
* For this block we only need items that was canceled, using native template is preferred | ||
* so other items was removed from this order instance (just for template) | ||
* | ||
* @return Order | ||
*/ | ||
public function getOrder(): Order | ||
{ | ||
if (!$this->order) { | ||
$this->order = clone $this->getData('order'); | ||
$items = $this->order->getItems(); | ||
foreach ($items as $key => $item) { | ||
if (!$item->getQtyCanceled()) { | ||
unset($items[$key]); | ||
} | ||
} | ||
$this->order->setItems($items); | ||
} | ||
|
||
return $this->order; | ||
} | ||
} |
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
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
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
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,85 @@ | ||
<?php | ||
/** | ||
* Copyright 2018 Vipps | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Vipps\Payment\Gateway\Config; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Payment\Gateway\Config\ValueHandlerInterface; | ||
use Magento\Payment\Gateway\Helper\SubjectReader; | ||
use Vipps\Payment\Gateway\Command\PaymentDetailsProvider; | ||
use Vipps\Payment\Gateway\Exception\VippsException; | ||
use Vipps\Payment\Gateway\Transaction\TransactionBuilder; | ||
|
||
/** | ||
* Class CanVoidHandler | ||
* @package Vipps\Payment\Gateway\Config | ||
*/ | ||
class CanVoidHandler implements ValueHandlerInterface | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $gatewayConfig; | ||
|
||
/** | ||
* @var PaymentDetailsProvider | ||
*/ | ||
private $paymentDetailsProvider; | ||
|
||
/** | ||
* @var TransactionBuilder | ||
*/ | ||
private $transactionBuilder; | ||
|
||
/** | ||
* CanVoidHandler constructor. | ||
* | ||
* @param Config $gatewayConfig | ||
* @param PaymentDetailsProvider $paymentDetailsProvider | ||
* @param TransactionBuilder $transactionBuilder | ||
*/ | ||
public function __construct( | ||
Config $gatewayConfig, | ||
PaymentDetailsProvider $paymentDetailsProvider, | ||
TransactionBuilder $transactionBuilder | ||
) { | ||
$this->gatewayConfig = $gatewayConfig; | ||
$this->paymentDetailsProvider = $paymentDetailsProvider; | ||
$this->transactionBuilder = $transactionBuilder; | ||
} | ||
|
||
/** | ||
* Disable partial online void | ||
* | ||
* @param array $subject | ||
* @param null $storeId | ||
* | ||
* @return bool | ||
* @throws NoSuchEntityException | ||
* @throws VippsException | ||
*/ | ||
public function handle(array $subject, $storeId = null): bool | ||
{ | ||
$response = $this->paymentDetailsProvider->get($subject); | ||
$transaction = $this->transactionBuilder->setData($response)->build(); | ||
if ($transaction->getTransactionSummary()->getCapturedAmount() > 0) { | ||
return false; | ||
} | ||
|
||
return (bool)$this->gatewayConfig->getValue(SubjectReader::readField($subject), $storeId); | ||
} | ||
} |
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
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 2018 Vipps | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Vipps\Payment\Model\Config\Source\Email; | ||
|
||
use Magento\Config\Model\Config\Source\Email\Template as EmailTemplate; | ||
use Magento\Config\Model\Config\Structure\SearchInterface; | ||
use Magento\Email\Model\ResourceModel\Template\CollectionFactory; | ||
use Magento\Email\Model\Template\Config; | ||
use Magento\Framework\Registry; | ||
|
||
/** | ||
* Class Template | ||
* @package Vipps\Payment\Model\Config\Source\Email | ||
*/ | ||
class Template extends EmailTemplate | ||
{ | ||
/** | ||
* @var SearchInterface | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* Template constructor. | ||
* | ||
* @param Registry $coreRegistry | ||
* @param CollectionFactory $templatesFactory | ||
* @param Config $emailConfig | ||
* @param SearchInterface $config | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Registry $coreRegistry, | ||
CollectionFactory $templatesFactory, | ||
Config $emailConfig, | ||
SearchInterface $config, | ||
array $data = [] | ||
) { | ||
parent::__construct($coreRegistry, $templatesFactory, $emailConfig, $data); | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* Replace config path for correct rendering default template option | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray(): array | ||
{ | ||
$element = $this->config->getElement($this->getPath()); | ||
$configData = $element->getData(); | ||
$this->setPath($configData['config_path']); | ||
return parent::toOptionArray(); | ||
} | ||
} |
Oops, something went wrong.