1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* Copyright (C) 2020-2025 Iain Cambridge |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by |
10
|
|
|
* the Free Software Foundation, either version 2.1 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Lesser General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Parthenon\Billing\Command; |
23
|
|
|
|
24
|
|
|
use Obol\Provider\ProviderInterface; |
25
|
|
|
use Parthenon\Billing\ChargeBack\ChargeBackSyncerInterface; |
26
|
|
|
use Symfony\Component\Console\Attribute\AsCommand; |
27
|
|
|
use Symfony\Component\Console\Command\Command; |
28
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
29
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
30
|
|
|
|
31
|
|
|
#[AsCommand(name: 'parthenon:billing:daily:charge-back', description: 'Sync charge backs for the past day', aliases: ['p:b:d:c'])] |
32
|
|
|
class DailyChargeBackCommand extends Command |
33
|
|
|
{ |
34
|
|
|
public function __construct( |
35
|
|
|
private ProviderInterface $provider, |
36
|
|
|
private ChargeBackSyncerInterface $syncer, |
37
|
|
|
) { |
38
|
|
|
parent::__construct(null); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
42
|
|
|
{ |
43
|
|
|
$output->writeln('Starting daily charge back command'); |
44
|
|
|
|
45
|
|
|
$chargeBacks = $this->provider->chargeBacks()->createdSinceYesterday(); |
46
|
|
|
|
47
|
|
|
foreach ($chargeBacks as $obolChargeBack) { |
48
|
|
|
$chargeBack = $this->syncer->sync($obolChargeBack); |
|
|
|
|
49
|
|
|
} |
|
|
|
|
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|