Skip to content

Commit

Permalink
Merge pull request #16 from vippsas/publication-1.0.11
Browse files Browse the repository at this point in the history
VIPPS-167: Publication v.1.0.11
  • Loading branch information
voleye authored Nov 13, 2018
2 parents 5a9d00c + d0eb38b commit 2c24162
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gateway/Command/CaptureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function execute(array $commandSubject)
return true;
}

// try to capture based on capture servise itself
// try to capture based on capture service itself
if ($transaction->getTransactionSummary()->getRemainingAmountToCapture() < $amount) {
throw new LocalizedException(__('Captured amount is higher then remaining amount to capture'));
}
Expand Down
4 changes: 2 additions & 2 deletions Gateway/Command/RefundCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function execute(array $commandSubject)
return true;
}

// try to refund based on capture servise itself
// try to refund based on refund service itself
if ($transaction->getTransactionSummary()->getRemainingAmountToRefund() < $amount) {
throw new LocalizedException(__('Refund amount is higher then remaining amount to refund'));
}
Expand Down Expand Up @@ -236,7 +236,7 @@ private function refundBasedOnPaymentDetails($commandSubject, Transaction $trans
// It can happened if previous operation was successful in vipps
// but for some reason Magento didn't get response

// Check that we are trying to refund the same amount as has been already captured in Vipps
// Check that we are trying to refund the same amount as has been already refunded in Vipps
// otherwise - show an error about desync
if ((int)$amount === (int)$deltaTotalRefunded) {
//prepare refund response based on data from getPaymentDetails service
Expand Down
66 changes: 66 additions & 0 deletions Gateway/Config/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?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\Gateway\Config;

use Magento\Payment\Gateway\Config\Config as OriginConfig;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Class Config
* @package Vipps\Payment\Gateway\Config
*/
class Config extends OriginConfig
{
/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param string $methodCode
* @param string $pathPattern
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
$methodCode = 'vipps',
$pathPattern = OriginConfig::DEFAULT_PATH_PATTERN
) {
parent::__construct($scopeConfig, $methodCode, $pathPattern);
$this->storeManager = $storeManager;
}

/**
* @param string $field
* @param null $storeId
*
* @return mixed
* @throws NoSuchEntityException
*/
public function getValue($field, $storeId = null)
{
if (null === $storeId) {
$storeId = $this->storeManager->getStore()->getId();
}
return OriginConfig::getValue($field, $storeId);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "magento2-module",
"description": "Vipps Payment Method",
"license": "proprietary",
"version": "1.0.10",
"version": "1.0.11",
"require": {
"magento/framework": "101.0.*",
"magento/module-sales": "101.0.*",
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<type name="Vipps\Payment\Plugin\Config\Model\Config">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
<argument name="logger" xsi:type="object">Vipps\Payment\Model\Logger</argument>
</arguments>
</type>
Expand Down
20 changes: 7 additions & 13 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@

<type name="Vipps\Payment\Model\TokenProvider">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
<argument name="logger" xsi:type="object">Vipps\Payment\Model\Logger</argument>
</arguments>
</type>

<type name="Vipps\Payment\Model\UrlResolver">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>

<type name="Vipps\Payment\Gateway\Http\Client\Curl">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
<argument name="logger" xsi:type="object">Vipps\Payment\Model\Logger</argument>
</arguments>
</type>

<type name="Vipps\Payment\Gateway\Request\MerchantDataBuilder">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>
<type name="Vipps\Payment\Gateway\Request\Initiate\MerchantDataBuilder">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>

Expand Down Expand Up @@ -96,13 +96,7 @@

<virtualType name="VippsConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
<arguments>
<argument name="configInterface" xsi:type="object">VippsGatewayConfig</argument>
</arguments>
</virtualType>

<virtualType name="VippsGatewayConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="string">vipps</argument>
<argument name="configInterface" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</virtualType>

Expand Down Expand Up @@ -358,7 +352,7 @@
<!-- Passing Vipps Config to log data when debug mode is enabled -->
<type name="Vipps\Payment\Model\Logger\Handler\Debug">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>

Expand Down
8 changes: 4 additions & 4 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<arguments>
<argument name="session" xsi:type="object">Magento\Checkout\Model\Session\Proxy</argument>
<argument name="logger" xsi:type="object">Vipps\Payment\Model\Logger</argument>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>

Expand All @@ -48,7 +48,7 @@

<type name="Vipps\Payment\Controller\Payment\Callback">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
<argument name="logger" xsi:type="object">Vipps\Payment\Model\Logger</argument>
</arguments>
</type>
Expand All @@ -62,13 +62,13 @@

<type name="Vipps\Payment\Block\Express\Button">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>

<type name="Vipps\Payment\Observer\AddVippsShortcutsObserver">
<arguments>
<argument name="config" xsi:type="object">VippsGatewayConfig</argument>
<argument name="config" xsi:type="object">Vipps\Payment\Gateway\Config\Config</argument>
</arguments>
</type>
</config>

0 comments on commit 2c24162

Please sign in to comment.