|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Copyright Iain Cambridge 2020-2023. |
|
7
|
|
|
* |
|
8
|
|
|
* Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license. |
|
9
|
|
|
* |
|
10
|
|
|
* Change Date: TBD ( 3 years after 2.2.0 release ) |
|
11
|
|
|
* |
|
12
|
|
|
* On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Parthenon\Billing\Command; |
|
16
|
|
|
|
|
17
|
|
|
use Obol\Provider\ProviderInterface; |
|
18
|
|
|
use Parthenon\Billing\ChargeBack\ChargeBackSyncerInterface; |
|
19
|
|
|
use Parthenon\Billing\Repository\ChargeBackRepositoryInterface; |
|
20
|
|
|
use Symfony\Component\Console\Attribute\AsCommand; |
|
21
|
|
|
use Symfony\Component\Console\Command\Command; |
|
22
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
23
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
24
|
|
|
|
|
25
|
|
|
#[AsCommand(name: 'parthenon:billing:daily:charge-back', description: 'Sync charge backs for the past day', aliases: ['p:b:d:c'])] |
|
26
|
|
|
class DailyChargeBackCommand extends Command |
|
27
|
|
|
{ |
|
28
|
|
|
public function __construct( |
|
29
|
|
|
private ProviderInterface $provider, |
|
30
|
|
|
private ChargeBackSyncerInterface $syncer, |
|
31
|
|
|
private ChargeBackRepositoryInterface $chargeBackRepository, |
|
32
|
|
|
) { |
|
33
|
|
|
parent::__construct(null); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
37
|
|
|
{ |
|
38
|
|
|
$output->writeln('Starting daily charge back command'); |
|
39
|
|
|
|
|
40
|
|
|
$chargeBacks = $this->provider->chargeBacks()->createdSinceYesterday(); |
|
41
|
|
|
|
|
42
|
|
|
foreach ($chargeBacks as $obolChargeBack) { |
|
43
|
|
|
$chargeBack = $this->syncer->sync($obolChargeBack); |
|
44
|
|
|
$this->chargeBackRepository->save($chargeBack); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|