Skip to content

SL-327: Fix SaferPay orders not sending email notifications when orde… - #29

Merged
MarijusDilys merged 12 commits into
release-v1.2.8from
SL-327-safer-pay-orders-not-sending-email-notifications-when-order-status-changes-to-shipped
Aug 28, 2025
Merged

SL-327: Fix SaferPay orders not sending email notifications when orde…#29
MarijusDilys merged 12 commits into
release-v1.2.8from
SL-327-safer-pay-orders-not-sending-email-notifications-when-order-status-changes-to-shipped

Conversation

@TLabutis

Copy link
Copy Markdown

…r status changes to shipped

Self-Checks

  • I have performed a self-review of my code.
  • I have updated/added necessary technical documentation in the README file.

JIRA task link

Summary

QA Checklist Labels

  • Bug fix?
  • New feature?
  • Improvement?
  • Technical debt?
  • Reusable?
  • Covered by tests?

QA Checklist

Additional Context

Frontend Changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @TLabutis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug where email notifications for SaferPay orders were not being sent when the order status changed, specifically for 'shipped' status updates. The problem stemmed from an overly restrictive email sending hook within the SaferPay module. The changes refine the email control mechanism to only manage specific email types, allowing all other necessary transactional emails to be sent correctly, thereby restoring full email notification functionality for order status changes.

Highlights

  • Bug Fix: Email Notification Blocking: The core issue was that the hookActionEmailSendBefore method in saferpayofficial.php was too restrictive, only allowing 'new_order' emails to pass through if configured, and implicitly blocking all other email types, including critical order status updates like 'shipped'.
  • Refined Email Sending Logic: The fix involves updating the email handling logic to explicitly define which email templates are controlled by SaferPay's configuration (e.g., 'new_order', 'order_conf'). Any email template not on this controlled list is now allowed to be sent, ensuring that status change emails, such as 'shipped', are no longer suppressed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to fix an issue where email notifications for SaferPay orders were not being sent for status changes like 'shipped'. The changes in saferpayofficial.php correctly address this by modifying the logic in hookActionEmailSendBefore to only control specific email templates (new_order, order_conf) and allow all others to be sent. This is a good improvement over the previous implementation which blocked most emails.

However, I've found a critical issue where the code references a constant SAFERPAY_SEND_ORDER_CONF_MAIL which does not appear to be defined in SaferPayConfig. This will cause a fatal error. Please see my detailed comment.

Comment thread saferpayofficial.php Outdated
@TLabutis
TLabutis changed the base branch from master to release-v1.2.8 August 19, 2025 11:48
…g-email-notifications-when-order-status-changes-to-shipped
Comment thread saferpayofficial.php Outdated
Comment on lines +616 to +629
// Define which email templates should be controlled for SaferPay orders
$controlledTemplates = [
'new_order' => \Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL,
'order_conf' => \Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_ORDER_CONF_MAIL,
];

if ($params['template'] === 'order_conf'
&& Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_ORDER_CONF_MAIL)) {
return true;
// Check if this template should be controlled
if (isset($controlledTemplates[$params['template']])) {
$configKey = $controlledTemplates[$params['template']];
return (bool) Configuration::get($configKey);
}

return false;

// Allow all other email templates (including order status changes like 'shipped')
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use best practices, we can create a service. Inside service we can validate all the stuff and only return true or false. It will be easier to maintain.

Something like that:

try {
    /** @var EmailValidator $emailValidator **/
    $emailValidator = $this->getService(EmailValidator::class);

    $canSend = $emailValidator->validate($params['template']);

    return $canSend;
} catch (\Throwable $e) {
    // logs, etc. and return false
}

@MarijusDilys MarijusDilys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a service

@MarijusDilys
MarijusDilys merged commit ad24866 into release-v1.2.8 Aug 28, 2025
@MarijusDilys
MarijusDilys deleted the SL-327-safer-pay-orders-not-sending-email-notifications-when-order-status-changes-to-shipped branch August 28, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants