I'm using the following code to place an order programmatically in Magento 2:
// Configure the quote
$quote = $this->cart->getQuote();
$quote->setInventoryProcessed(false);
$quote->setPaymentMethod('custom_gateway');
$quote->save();
// Set the payment method
$payment = $quote->getPayment();
$payment->importData(['method' => 'custom_gateway']);
// Update the quote
$quote->collectTotals()->save();
// Place the order
$this->cartManagement->placeOrder($quote->getId());
This code is creating the order as expected, but is also sending an email to the shopper.
I would like to send the confirmation email at a later stage in the process, only when the payment has been confirmed.
How can I place an order without notifying the customer?