This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon Schurter
committed
Sep 20, 2018
1 parent
c93a46a
commit 055ccb7
Showing
13 changed files
with
141 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* wallee Magento 2 | ||
* | ||
* This Magento 2 extension enables to process payments with wallee (https://www.wallee.com/). | ||
* | ||
* @package Wallee_Payment | ||
* @author customweb GmbH (http://www.customweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0) | ||
*/ | ||
namespace Wallee\Payment\Cron; | ||
|
||
use Magento\Framework\Api\SearchCriteriaBuilder; | ||
use Psr\Log\LoggerInterface; | ||
use Wallee\Payment\Api\RefundJobRepositoryInterface; | ||
use Wallee\Payment\Model\ApiClient; | ||
use Wallee\Sdk\Service\RefundService; | ||
|
||
/** | ||
* Class to handle pending refund jobs. | ||
*/ | ||
class Refund | ||
{ | ||
|
||
/** | ||
* | ||
* @var LoggerInterface | ||
*/ | ||
protected $_logger; | ||
|
||
/** | ||
* | ||
* @var RefundJobRepositoryInterface | ||
*/ | ||
protected $_refundJobRepository; | ||
|
||
/** | ||
* | ||
* @var SearchCriteriaBuilder | ||
*/ | ||
protected $_searchCriteriaBuilder; | ||
|
||
/** | ||
* | ||
* @var ApiClient | ||
*/ | ||
protected $_apiClient; | ||
|
||
/** | ||
* | ||
* @param LoggerInterface $logger | ||
* @param RefundJobRepositoryInterface $refundJobRepository | ||
* @param SearchCriteriaBuilder $searchCriteriaBuilder | ||
* @param ApiClient $apiClient | ||
*/ | ||
public function __construct(LoggerInterface $logger, RefundJobRepositoryInterface $refundJobRepository, | ||
SearchCriteriaBuilder $searchCriteriaBuilder, ApiClient $apiClient) | ||
{ | ||
$this->_logger = $logger; | ||
$this->_refundJobRepository = $refundJobRepository; | ||
$this->_searchCriteriaBuilder = $searchCriteriaBuilder; | ||
$this->_apiClient = $apiClient; | ||
} | ||
|
||
public function execute() | ||
{ | ||
$searchCriteria = $this->_searchCriteriaBuilder->setPageSize(100)->create(); | ||
$refundJobs = $this->_refundJobRepository->getList($searchCriteria)->getItems(); | ||
foreach ($refundJobs as $refundJob) { | ||
try { | ||
$this->_apiClient->getService(RefundService::class)->refund($refundJob->getSpaceId(), | ||
$refundJob->getRefund()); | ||
} catch (\Wallee\Sdk\ApiException $e) { | ||
if ($e->getResponseObject() instanceof \Wallee\Sdk\Model\ClientError) { | ||
$this->_refundJobRepository->delete($refundJob); | ||
} else { | ||
$this->_logger->critical($e); | ||
} | ||
} catch (\Exception $e) { | ||
$this->_logger->critical($e); | ||
} | ||
} | ||
} | ||
} |
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
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,19 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* wallee Magento 2 | ||
* | ||
* This Magento 2 extension enables to process payments with wallee (https://www.wallee.com/). | ||
* | ||
* @package Wallee_Payment | ||
* @author customweb GmbH (http://www.customweb.com/) | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0) | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd"> | ||
<group id="default"> | ||
<job name="wallee_cron_refund_jobs" instance="Wallee\Payment\Cron\Refund" method="execute"> | ||
<schedule>*/10 * * * *</schedule> | ||
</job> | ||
</group> | ||
</config> |
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