Skip to content

Commit

Permalink
feat: add refund command
Browse files Browse the repository at this point in the history
  • Loading branch information
syjust-alma committed Jan 17, 2023
1 parent 5b8e957 commit 7db6959
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Command/AlmaPaymentRefundCommand.php
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;
}
}

0 comments on commit 7db6959

Please sign in to comment.