Add handling of subscriber limit error to MailPoet error mapper

When the shop blocked access for an API key due subscriber limit it used
to set the error as "Insufficient privileges," and that was in the plugin
interpreted same as "Subscribers limit reached".
The SHOP-1228 changes the error message will be set to "Subscribers limit reached".
This commit updates the error mapper to be able to process the new error message.
It also keeps the old approach for previously blocked keys.
[MAILPOET-5191]
This commit is contained in:
Rostislav Wolny
2023-04-26 10:41:47 +02:00
committed by Veljko V
parent eb06b6d01e
commit db467d8616
3 changed files with 27 additions and 2 deletions

View File

@@ -134,7 +134,7 @@ class MailPoetMapper {
return $message;
}
private function getInsufficientPrivilegesMessage(): string {
private function getSubscribersLimitReachedMessage(): string {
$message = __('You have reached the subscriber limit of your plan. Please [link1]upgrade your plan[/link1], or [link2]contact our support team[/link2] if you have any questions.', 'mailpoet');
$message = Helpers::replaceLinkTags(
$message,
@@ -248,9 +248,18 @@ class MailPoetMapper {
return [$operation, $message];
}
// Backward compatibility for older blocked keys.
// Exceeded subscribers limit used to use the same error message as insufficient privileges.
// We can change the message to "Insufficient privileges" like wording a couple of months after releasing SHOP-1228
if ($result['error'] === API::ERROR_MESSAGE_INSUFFICIENT_PRIVILEGES) {
$operation = MailerError::OPERATION_INSUFFICIENT_PRIVILEGES;
$message = $this->getInsufficientPrivilegesMessage();
$message = $this->getSubscribersLimitReachedMessage();
return [$operation, $message];
}
if ($result['error'] === API::ERROR_MESSAGE_SUBSCRIBERS_LIMIT_REACHED) {
$operation = MailerError::OPERATION_SUBSCRIBER_LIMIT_REACHED;
$message = $this->getSubscribersLimitReachedMessage();
return [$operation, $message];
}