-
Notifications
You must be signed in to change notification settings - Fork 76
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 #1185 from BearGroup/release/5.15.0
Release/5.15.0
- Loading branch information
Showing
35 changed files
with
1,296 additions
and
125 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,59 @@ | ||
<?php | ||
/** | ||
* Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
* | ||
*/ | ||
|
||
namespace Amazon\Pay\Api; | ||
|
||
/** | ||
* @api | ||
*/ | ||
interface KeyUpgradeInterface | ||
{ | ||
/** | ||
* Obtain a new Public Key ID for use with V2 of the Amazon Pay API | ||
* | ||
* @param string $scopeType | ||
* @param integer $scopeCode | ||
* @param string $accessKey | ||
* @return mixed | ||
*/ | ||
public function getPublicKeyId( | ||
string $scopeType, | ||
int $scopeCode, | ||
string $accessKey | ||
); | ||
|
||
/** | ||
* Get public/private keys for module configuration | ||
* | ||
* @return array | ||
*/ | ||
public function getKeyPair(); | ||
|
||
/** | ||
* Persist keys in configuration | ||
* | ||
* @param string $publicKeyId | ||
* @param string $scopeType | ||
* @param int $scopeId | ||
* @return void | ||
*/ | ||
public function updateKeysInConfig( | ||
$publicKeyId, | ||
$scopeType, | ||
$scopeId | ||
); | ||
} |
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,103 @@ | ||
<?php | ||
/** | ||
* Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
namespace Amazon\Pay\Controller\Adminhtml\Pay; | ||
|
||
use Magento\Backend\App\Action\Context; | ||
use Magento\Backend\Controller\Adminhtml\System; | ||
use Magento\Framework\App\Cache\Manager; | ||
use Magento\Framework\App\Cache\Type\Config as CacheTypeConfig; | ||
use Magento\Framework\App\Config\ConfigResource\ConfigInterface; | ||
use Magento\Framework\Controller\Result\JsonFactory; | ||
use Amazon\Pay\Model\Config\KeyUpgrade; | ||
|
||
/** | ||
* Manually hits the Key Upgrade endpoint to retrieve a CV2 Public Key ID | ||
*/ | ||
class ManualKeyUpgrade extends System | ||
{ | ||
/** | ||
* @var ConfigInterface | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var Manager | ||
*/ | ||
private $cacheManager; | ||
|
||
/** | ||
* @var JsonFactory | ||
*/ | ||
private $jsonResultFactory; | ||
|
||
/** | ||
* @var KeyUpgrade | ||
*/ | ||
private $keyUpgrade; | ||
|
||
/** | ||
* @param Context $context | ||
* @param ConfigInterface $config | ||
* @param JsonFactory $jsonResultFactory | ||
* @param Manager $cacheManager | ||
* @param KeyUpgrade $keyUpgrade | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
ConfigInterface $config, | ||
JsonFactory $jsonResultFactory, | ||
Manager $cacheManager, | ||
KeyUpgrade $keyUpgrade | ||
) { | ||
parent::__construct($context); | ||
$this->config = $config; | ||
$this->jsonResultFactory = $jsonResultFactory; | ||
$this->cacheManager = $cacheManager; | ||
$this->keyUpgrade = $keyUpgrade; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$scopeType = $this->_request->getParam('scope'); | ||
$scopeCode = (int) $this->_request->getParam('scopeCode'); | ||
|
||
$publicKeyId = $this->keyUpgrade->getPublicKeyId( | ||
$scopeType, | ||
$scopeCode, | ||
$this->_request->getParam('accessKey') | ||
); | ||
|
||
$result = $this->jsonResultFactory->create(); | ||
if (!empty($publicKeyId)) { | ||
$this->keyUpgrade->updateKeysInConfig( | ||
$publicKeyId, | ||
$scopeType, | ||
$scopeCode | ||
); | ||
|
||
$this->cacheManager->clean([CacheTypeConfig::TYPE_IDENTIFIER]); | ||
$result->setData(['result' => 'success']); | ||
$this->messageManager->addSuccessMessage('Amazon Pay keys upgraded successfully.'); | ||
} else { | ||
$result->setData(['result' => 'error']); | ||
$this->messageManager->addErrorMessage('Amazon Pay keys could not be upgraded. ' | ||
. 'See the paywithamazon.log for more details'); | ||
} | ||
|
||
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.