Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable sending email confirmation after placeOrder #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gateway/Response/OrderCreateResponseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ public function handle(array $handlingSubject, array $response)
{
$paymentDataObject = SubjectReader::readPayment($handlingSubject);
$payment = $paymentDataObject->getPayment();
$order = $payment->getOrder();

$payment
->setTransactionId($response['orderId'])
->setIsTransactionPending(true)
->setIsTransactionClosed(false);

// No not send order confirmation mail
$order
->setCanSendNewEmailFlag(false);

if (array_key_exists(PayUConfigInterface::REDIRECT_URI_FIELD, $response)) {
$payment->setAdditionalInformation(
PayUConfigInterface::PAYU_REDIRECT_URI_CODE,
Expand Down
9 changes: 8 additions & 1 deletion Model/AcceptOrderPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Magento\Framework\DB\Transaction;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Payment\Gateway\Command\CommandException;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use PayU\PaymentGateway\Api\AcceptOrderPaymentInterface;
use PayU\PaymentGateway\Api\OrderPaymentResolverInterface;

Expand All @@ -17,16 +18,19 @@ class AcceptOrderPayment implements AcceptOrderPaymentInterface
private EventManager $eventManager;
private Transaction $transaction;
private OrderPaymentResolverInterface $paymentResolver;
private OrderSender $orderSender;

public function __construct(
EventManager $eventManager,
Transaction $transaction,
OrderPaymentResolverInterface $paymentResolver
OrderPaymentResolverInterface $paymentResolver,
OrderSender $orderSender
)
{
$this->eventManager = $eventManager;
$this->transaction = $transaction;
$this->paymentResolver = $paymentResolver;
$this->orderSender = $orderSender;
}

/**
Expand All @@ -46,6 +50,9 @@ public function execute(string $txnId, float $amount, string $paymentId = null):
}
$payment->capture();
$order = $payment->getOrder();

$this->orderSender->send($order);

$eventData = ['order' => $order, 'payment' => $payment];
$this->eventManager->dispatch('payu_accept_order_payment', $eventData);
$this->eventManager->dispatch('payu_close_repayment_transaction', $eventData);
Expand Down