diff --git a/src/Application/Controller/Admin/AdminOrder.php b/src/Application/Controller/Admin/AdminOrder.php index ed79a99..6117bb0 100644 --- a/src/Application/Controller/Admin/AdminOrder.php +++ b/src/Application/Controller/Admin/AdminOrder.php @@ -92,7 +92,12 @@ class AdminOrder extends AdminController oxNew(successfullySentException::class, $sms->getResponse()->getSmsCount() ) ); } else { - Registry::getUtilsView()->addErrorToDisplay( Registry::getLang()->translateString( 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' ) ); + Registry::getUtilsView()->addErrorToDisplay( + sprintf( + Registry::getLang()->translateString( 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' ), + $sms->getResponse()->getErrorMessage() + ) + ); } } catch (noRecipientFoundException $e) { Registry::getUtilsView()->addErrorToDisplay($e); diff --git a/src/Application/Controller/Admin/AdminUser.php b/src/Application/Controller/Admin/AdminUser.php index deb1ed8..bc33d5f 100644 --- a/src/Application/Controller/Admin/AdminUser.php +++ b/src/Application/Controller/Admin/AdminUser.php @@ -94,7 +94,10 @@ class AdminUser extends AdminController ); } else { Registry::getUtilsView()->addErrorToDisplay( - Registry::getLang()->translateString('D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND') + sprintf( + Registry::getLang()->translateString( 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' ), + $sms->getResponse()->getErrorMessage() + ) ); } } diff --git a/src/Application/Model/Sms.php b/src/Application/Model/Sms.php index 4129d78..9308481 100644 --- a/src/Application/Model/Sms.php +++ b/src/Application/Model/Sms.php @@ -21,6 +21,7 @@ use D3\Linkmobility4OXID\Application\Model\RequestFactory; use D3\LinkmobilityClient\Exceptions\ApiException; use D3\LinkmobilityClient\Request\RequestInterface; use D3\LinkmobilityClient\Response\ResponseInterface; +use D3\LinkmobilityClient\SMS\SmsRequestInterface; use D3\LinkmobilityClient\ValueObject\Recipient; use D3\LinkmobilityClient\ValueObject\Sender; use GuzzleHttp\Exception\GuzzleException; @@ -99,8 +100,17 @@ class Sms $configuration = oxNew( Configuration::class ); $client = oxNew( MessageClient::class )->getClient(); + /** @var SmsRequestInterface $request */ $request = oxNew( RequestFactory::class, $this->getMessage(), $client )->getSmsRequest(); - $request->setTestMode( $configuration->getTestMode() )->setMethod( RequestInterface::METHOD_POST )->setSenderAddress( oxNew( Sender::class, $configuration->getSmsSenderNumber(), $configuration->getSmsSenderCountry() ) )->setSenderAddressType( RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL ); + $request->setTestMode( $configuration->getTestMode() )->setMethod( RequestInterface::METHOD_POST ) + ->setSenderAddress( + oxNew( + Sender::class, + $configuration->getSmsSenderNumber(), + $configuration->getSmsSenderCountry() + ) + ) + ->setSenderAddressType( RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL ); $recipientsList = $request->getRecipientsList(); foreach ($recipientsArray as $recipient) { @@ -111,6 +121,10 @@ class Sms $this->response = $response; + if (false === $response->isSuccessful()) { + Registry::getLogger()->warning( $response->getErrorMessage(), [$request->getBody()] ); + } + return $response->isSuccessful(); } catch (abortSendingExceptionInterface $e) { Registry::getLogger()->warning($e->getMessage()); diff --git a/src/Application/views/admin/de/d3Linkmobility_lang.php b/src/Application/views/admin/de/d3Linkmobility_lang.php index ac06b59..685c974 100644 --- a/src/Application/views/admin/de/d3Linkmobility_lang.php +++ b/src/Application/views/admin/de/d3Linkmobility_lang.php @@ -30,7 +30,7 @@ $aLang = [ 'SHOP_MODULE_GROUP_d3linkmobility_sms' => 'SMS-Versand', 'SHOP_MODULE_d3linkmobility_smsSenderNumber' => 'Sendernummer', - 'HELP_SHOP_MODULE_d3linkmobility_smsSenderNumber' => 'Ihre Mobilfunknummer, die als Antwortziel verwendet werden kann.', + 'HELP_SHOP_MODULE_d3linkmobility_smsSenderNumber' => 'Ihre Mobilfunknummer, die als Antwortziel verwendet werden kann., Bitte lassen Sie die gewünschte Telefonnummer in Ihrem Konto hinterlegen.', 'SHOP_MODULE_d3linkmobility_smsSenderCountry' => 'Landeskürzel', 'HELP_SHOP_MODULE_d3linkmobility_smsSenderCountry' => 'Geben Sie hier das Landeskürzel (ISO-Alpha-2, z.B. DE, AT, FR) an, zu dem Ihre Mobilfunknummer zugeordnet ist.', 'SHOP_MODULE_d3linkmobility_smsUserRecipientsFields'=> 'Felder des Benutzerkontos, die auf gültige Mobilfunknummern geprüft werden', @@ -52,7 +52,7 @@ $aLang = [ 'D3LM_EXC_MESSAGE_NO_LENGTH' => 'Die Mitteilung muss Inhalt haben', 'D3LM_EXC_SMS_SUCC_SENT' => 'Die Mitteilung wurde erfolgreich versendet. (%1$s Nachricht(en) verwendet)', - 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' => 'Beim Versenden der Nachricht(en) ist ein unerwarteter Fehler aufgetreten.', + 'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' => 'Beim Versenden der Nachricht(en) ist dieser Fehler aufgetreten: %1$s', 'D3LM_EXC_NO_RECIPIENT_SET' => 'Kein (verwendbarer) Empfänger gesetzt.', 'D3LM_REMARK_SMS' => 'SMS-Nachr.',