-
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.
feat(WIP): add payment cancel command
- Loading branch information
1 parent
7db6959
commit 37d7ae7
Showing
2 changed files
with
46 additions
and
1 deletion.
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,45 @@ | ||
<?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; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
class AlmaPaymentCancelCommand extends AbstractWriteAlmaCommand | ||
{ | ||
use DisplayOutputPaymentTrait; | ||
protected static $defaultName = 'alma:payment:cancel'; | ||
protected static $defaultDescription = 'Cancel an un-started 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' | ||
) | ||
; | ||
} | ||
|
||
/** | ||
* @throws RequestError | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
$paymentId = $input->getArgument('ID'); | ||
$this->almaClient->payments->cancel($paymentId); | ||
|
||
$io->success(sprintf("Payment '%s' successfully canceled", $paymentId)); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |