-
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.
- added order status management settings - fixed issue with captured transaction on Fallback - improved currency validation logic - documentation update
- Loading branch information
Showing
14 changed files
with
230 additions
and
8 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
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,67 @@ | ||
<?php | ||
/** | ||
* Copyright 2020 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\Gateway\Validator; | ||
|
||
use Magento\Payment\Gateway\Validator\AbstractValidator; | ||
use Magento\Payment\Gateway\Validator\ResultInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory; | ||
use Magento\Store\Model\Store; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
/** | ||
* Class InitiateValidator | ||
* @package Vipps\Payment\Gateway\Validator | ||
*/ | ||
class AvailabilityValidator extends AbstractValidator | ||
{ | ||
const NORWEGIAN_CURRENCY = 'NOK'; | ||
|
||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* CurrencyValidator constructor. | ||
* | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct( | ||
ResultInterfaceFactory $resultFactory, | ||
StoreManagerInterface $storeManager | ||
) { | ||
parent::__construct($resultFactory); | ||
$this->storeManager = $storeManager; | ||
} | ||
|
||
/** | ||
* @param array $validationSubject | ||
* | ||
* @return ResultInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function validate(array $validationSubject) | ||
{ | ||
/** @var Store $store */ | ||
$store = $this->storeManager->getStore(); | ||
|
||
$isValid = self::NORWEGIAN_CURRENCY == $store->getBaseCurrencyCode(); | ||
$errorMessages = $isValid ? [] : [__('Not allowed currency. Please, contact store administrator.')]; | ||
|
||
return $this->createResult($isValid, $errorMessages); | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
/** | ||
* Copyright 2020 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\Model\Adminhtml\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
|
||
/** | ||
* Class PaymentAction | ||
*/ | ||
class OrderStatus implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const STATUS_PAYMENT_REVIEW = 'payment_review'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
const STATUS_PENDING = 'pending'; | ||
|
||
/** | ||
* Possible actions on order place | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return [ | ||
[ | ||
'value' => self::STATUS_PAYMENT_REVIEW, | ||
'label' => __('Payment Review'), | ||
], | ||
[ | ||
'value' => self::STATUS_PENDING, | ||
'label' => __('Pending'), | ||
] | ||
]; | ||
} | ||
} |
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,73 @@ | ||
<?php | ||
/** | ||
* Copyright 2020 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\Observer; | ||
|
||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
use Magento\Payment\Gateway\ConfigInterface; | ||
use Magento\Sales\Model\Order; | ||
use Psr\Log\LoggerInterface; | ||
use Vipps\Payment\Model\Adminhtml\Source\OrderStatus; | ||
|
||
/** | ||
* Class OrderPaymentAfter | ||
* @package Vipps\Payment\Observer | ||
*/ | ||
class OrderPaymentAfter implements ObserverInterface | ||
{ | ||
/** | ||
* @var ConfigInterface | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* OrderPaymentAfter constructor. | ||
* | ||
* @param ConfigInterface $config | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct(ConfigInterface $config, LoggerInterface $logger) | ||
{ | ||
$this->config = $config; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @param Observer $observer | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
/** @var Order\Payment $payment */ | ||
$payment = $observer->getPayment(); | ||
$order = $payment->getOrder(); | ||
|
||
$status = $this->config->getValue('order_status'); | ||
if ($status == OrderStatus::STATUS_PAYMENT_REVIEW) { | ||
$order->setState(Order::STATE_PAYMENT_REVIEW); | ||
$order->setStatus(Order::STATE_PAYMENT_REVIEW); | ||
} | ||
|
||
return; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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