Skip to content

Commit

Permalink
Preform customerEmail check earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinverschoor committed Jul 13, 2022
1 parent d59c0f2 commit 60f72ef
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Model/Paymentmethod/Paylink.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ public function initialize($paymentAction, $stateObject)
$this->addPaylinkComment($order, $url, $status);
} else {
try {
$paylinktext = __('A PAY. Paylink has been send to');
$order->addStatusHistoryComment($paylinktext . ' ' . $order->getCustomerEmail() . '.', $status)->save();
$customerEmail = [$order->getCustomerEmail()];

if (empty($customerEmail)) {
# Can't send email without customer email so add paylink as a comment instead.
$order->addStatusHistoryComment(__('PAY.: Customer E-mail is empty cannot send E-mail.'), $status)->save();
$this->addPaylinkComment($order, $url, $status);
return false;
}

$supportEmail = $this->_scopeConfig->getValue('trans_email/ident_support/email', 'store', $storeId);
$senderName = $this->_scopeConfig->getValue('trans_email/ident_sales/name', 'store', $storeId);
Expand All @@ -70,15 +76,6 @@ public function initialize($paymentAction, $stateObject)
'email' => $senderEmail,
];

$customerEmail = [$order->getCustomerEmail()];

if (empty($customerEmail)) {
# Can't send email without customer email so add paylink as a comment instead.
$order->addStatusHistoryComment(__('PAY.: Customer E-mail is empty cannot send E-mail.'), $status)->save();
$this->addPaylinkComment($order, $url, $status);
return false;
}

$paymentHelper = $objectManager->create(\Magento\Payment\Helper\Data::class);

$orderHTML = $paymentHelper->getInfoBlockHtml(
Expand Down Expand Up @@ -143,6 +140,9 @@ public function initialize($paymentAction, $stateObject)
->setReplyTo($supportEmail)
->getTransport();
$transport->sendMessage();

$paylinktext = __('A PAY. Paylink has been send to');
$order->addStatusHistoryComment($paylinktext . ' ' . $order->getCustomerEmail() . '.', $status)->save();
} catch (\Exception $e) {
payHelper::logDebug('Paylink exception: ' . $e->getMessage());
$order->addStatusHistoryComment(__('PAY.: Unable to send E-mail'), $status)->save();
Expand Down

0 comments on commit 60f72ef

Please sign in to comment.