-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy pathEnablePaymentMethodsCommand.php
48 lines (39 loc) · 1.4 KB
/
EnablePaymentMethodsCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Adyen\Payment\Console\Command;
use Adyen\Payment\Helper\PaymentMethods;
use Adyen\Payment\Helper\PaymentMethodsFactory;
use Magento\Framework\Console\Cli;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class EnablePaymentMethodsCommand extends Command
{
private PaymentMethodsFactory $paymentMethodsFactory;
public function __construct(
PaymentMethodsFactory $paymentMethodsFactory,
)
{
$this->paymentMethodsFactory = $paymentMethodsFactory;
parent::__construct();
}
protected function configure(): void
{
$this->setName('adyen:enablepaymentmethods:run');
parent::configure();
}
/**
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Starting enabling payment methods.');
$paymentMethods = $this->paymentMethodsFactory->create();
/** @var PaymentMethods $paymentMethods */
$activatedPaymentMethods = $paymentMethods->togglePaymentMethodsActivation(true);
foreach ($activatedPaymentMethods as $paymentMethod) {
$output->writeln("Enabled payment method: {$paymentMethod}");
}
$output->writeln('Completed enabling payment methods.');
return Cli::RETURN_SUCCESS;
}
}