Skip to content

Commit

Permalink
Merge pull request #93 from conferencetools/mark-purchase-paid
Browse files Browse the repository at this point in the history
Mark purchase paid
  • Loading branch information
carnage authored Apr 7, 2018
2 parents df6dd9f + 60f050f commit 6f6e5f6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
\ConferenceTools\Tickets\Cli\Command\IssueFreeTicket::class => \ConferenceTools\Tickets\Cli\Command\IssueFreeTicketFactory::class,
\ConferenceTools\Tickets\Cli\Command\ReportToCsv::class => \ConferenceTools\Tickets\Cli\Command\ReportToCsvFactory::class,
\ConferenceTools\Tickets\Cli\Command\CancelTicket::class => \ConferenceTools\Tickets\Cli\Command\CancelTicketFactory::class,
\ConferenceTools\Tickets\Cli\Command\MarkPurchasePaid::class => \ConferenceTools\Tickets\Cli\Command\MarkPurchasePaidFactory::class,
],
],
'command_handlers' => [
Expand Down
56 changes: 56 additions & 0 deletions src/Cli/Command/MarkPurchasePaid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace ConferenceTools\Tickets\Cli\Command;

use Carnage\Cqrs\MessageBus\MessageBusInterface;
use Carnage\Cqrs\Service\EventCatcher;
use ConferenceTools\Tickets\Domain\Command\Ticket\CompletePurchase;
use ConferenceTools\Tickets\Domain\Command\Ticket\MakePayment;
use ConferenceTools\Tickets\Domain\Command\Ticket\ReserveTickets;
use ConferenceTools\Tickets\Domain\Event\Ticket\TicketPurchaseCreated;
use ConferenceTools\Tickets\Domain\Service\Configuration;
use ConferenceTools\Tickets\Domain\ValueObject\Delegate;
use ConferenceTools\Tickets\Domain\ValueObject\DiscountCode;
use ConferenceTools\Tickets\Domain\ValueObject\TicketReservationRequest;
use ConferenceTools\Tickets\Domain\ValueObject\TicketType;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class MarkPurchasePaid extends Command
{
/**
* @var MessageBusInterface
*/
private $commandBus;

public static function build(MessageBusInterface $commandBus)
{
$instance = new static();
$instance->commandBus = $commandBus;

return $instance;
}

protected function configure()
{
$this->setName('tickets:mark-purchase-paid')
->setDescription('Marks a purchase made via the web as paid')
->setDefinition([
new InputArgument('purchaseId', InputArgument::REQUIRED, 'Id of purchase to mark paid'),
new InputArgument('email', InputArgument::REQUIRED, 'Email address for purchaser'),
]);
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$email = $input->getArgument('email');
$purchaseId = $input->getArgument('purchaseId');

$this->commandBus->dispatch(new MakePayment($purchaseId, $email));

$output->writeln(sprintf('Marked paid. PurchaseId: %s', $purchaseId));
}
}
21 changes: 21 additions & 0 deletions src/Cli/Command/MarkPurchasePaidFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace ConferenceTools\Tickets\Cli\Command;


use Carnage\Cqrs\Command\CommandBusInterface;
use Carnage\Cqrs\Service\EventCatcher;
use ConferenceTools\Tickets\Domain\Service\Configuration;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class MarkPurchasePaidFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator)
{
$serviceLocator = $serviceLocator->getServiceLocator();
return MarkPurchasePaid::build(
$serviceLocator->get(CommandBusInterface::class)
);
}
}

0 comments on commit 6f6e5f6

Please sign in to comment.