-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
5b8e957
commit 7db6959
Showing
1 changed file
with
43 additions
and
0 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,43 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use Alma\API\RequestError; | ||
use App\Command\Meta\AbstractWriteAlmaCommand; | ||
use App\Command\Meta\DisplayOutputPaymentTrait; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class AlmaPaymentRefundCommand extends AbstractWriteAlmaCommand | ||
{ | ||
use DisplayOutputPaymentTrait; | ||
protected static $defaultName = 'alma:payment:refund'; | ||
protected static $defaultDescription = 'Trigger a payment'; | ||
|
||
protected function configure(): void | ||
{ | ||
$this->configureOutputPaymentOptions(); | ||
$this | ||
->addArgument( | ||
'ID', | ||
InputArgument::REQUIRED, | ||
'the payment id formatted as payment_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx or only xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx if you prefer' | ||
); | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$paymentId = $input->getArgument('ID'); | ||
try { | ||
$payment = $this->almaClient->payments->fullRefund($paymentId); | ||
} catch (RequestError $e) { | ||
return $this->outputRequestError($e); | ||
} | ||
|
||
$this->outputPayment($payment, $input); | ||
return Command::SUCCESS; | ||
} | ||
} |