From ad1706f8e0d8083fea671f28bc4361b9751a2049 Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 13 Dec 2018 09:34:53 +0100 Subject: [PATCH] Prefix Telenor numbers to make int. ones work --- src/Gateway/Provider/TelenorGateway.php | 6 +++--- tests/Gateway/Provider/TelenorGatewayTest.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Gateway/Provider/TelenorGateway.php b/src/Gateway/Provider/TelenorGateway.php index 123c78e..13be42f 100644 --- a/src/Gateway/Provider/TelenorGateway.php +++ b/src/Gateway/Provider/TelenorGateway.php @@ -131,7 +131,7 @@ protected function buildSendBody(MessageInterface $message): string $header->appendChild($xml->createElement('request_id', $messageId)); } if (($xmlChild = $this->getMessageFromXmlChild($message, $xml))) { - $header->appendChild($xml->createElement('from_alphanumeric', (string) $message->getFrom())); + $header->appendChild($xmlChild); } if ($this->supplementaryInformation !== null) { $header->appendChild($xml->createElement('sub_id_1', $this->supplementaryInformation)); @@ -142,7 +142,7 @@ protected function buildSendBody(MessageInterface $message): string $sms = $xml->createElement('sms'); $sms->appendChild(($messageElement = $xml->createElement('message'))); $messageElement->appendChild($xml->createCDATASection($message->getText())); - $sms->appendChild($xml->createElement('to_msisdn', (string) $message->getTo())); + $sms->appendChild($xml->createElement('to_msisdn', '+' . $message->getTo())); $payload->appendChild($sms); $mobileCtrlSms->appendChild($payload); @@ -158,7 +158,7 @@ protected function getMessageFromXmlChild(MessageInterface $message, DOMDocument } if ($message->getFrom() instanceof PhoneNumber) { - return $xmlDocument->createElement('from_msisdn', (string) $message->getFrom()); + return $xmlDocument->createElement('from_msisdn', '+' . $message->getFrom()); } elseif ($message->getFrom() instanceof Alphanumeric) { return $xmlDocument->createElement('from_alphanumeric', (string) $message->getFrom()); } diff --git a/tests/Gateway/Provider/TelenorGatewayTest.php b/tests/Gateway/Provider/TelenorGatewayTest.php index 0cf583e..1fbcf4f 100644 --- a/tests/Gateway/Provider/TelenorGatewayTest.php +++ b/tests/Gateway/Provider/TelenorGatewayTest.php @@ -55,14 +55,14 @@ public function testCreateGatewayWithInvalidCredentials() public function testSendMessage() { - $message = Message::create('46700123001', 'Hello world!', '46700123456'); + $message = Message::create('46700123001', 'Hello world!', 'Testing'); $url = 'https://sms-pro.net:44343/services/some-customer-id/sendsms'; $headers = ['Authorization' => 'Basic c29tZS11c2VybmFtZTpzb21lLXBhc3N3b3Jk']; $body = ''. "\n"; $body .= "
some-customer-id" - . 'some-customer-password46700123456
' - . '46700123001' + . 'some-customer-passwordTesting' + . '+46700123001' . "
\n";