. */ namespace Storefront\BTCPay\Console\Command; use Magento\Sales\Api\OrderRepositoryInterface; use Storefront\BTCPay\Model\BTCPay\BTCPayService; 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 PayOrder extends Command { /** * @var BTCPayService */ private $btcPayService; /** * @var OrderRepositoryInterface */ private $orderRepository; public function __construct(BTCPayService $btcPayService, OrderRepositoryInterface $orderRepository, string $name = null) { parent::__construct($name); $this->btcPayService = $btcPayService; $this->orderRepository = $orderRepository; } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $orderId = $input->getArgument('orderId'); $order = $this->orderRepository->get($orderId); $invoice = $this->btcPayService->createInvoice($order); $output->writeln(__('You can pay order %1 by visiting URL %2.', $order->getIncrementId(), $invoice->getUrl())); } /** * {@inheritdoc} */ protected function configure() { $this->setName('btcpay:order:pay'); $this->setDescription('Generate a payment URL for a given order.'); $this->addArgument('orderId', InputArgument::REQUIRED, 'The order ID you want to pay'); parent::configure(); } }