Skip to content

Commit

Permalink
Prefix Telenor numbers to make int. ones work
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnij committed Dec 13, 2018
1 parent a24edeb commit ad1706f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Gateway/Provider/TelenorGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);

Expand All @@ -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());
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Gateway/Provider/TelenorGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<?xml version="1.0" encoding="ISO-8859-1"?>'. "\n";
$body .= "<mobilectrl_sms><header><customer_id>some-customer-id</customer_id>"
. '<password>some-customer-password</password><from_alphanumeric>46700123456</from_alphanumeric></header>'
. '<payload><sms><message><![CDATA[Hello world!]]></message><to_msisdn>46700123001</to_msisdn></sms>'
. '<password>some-customer-password</password><from_alphanumeric>Testing</from_alphanumeric></header>'
. '<payload><sms><message><![CDATA[Hello world!]]></message><to_msisdn>+46700123001</to_msisdn></sms>'
. "</payload></mobilectrl_sms>\n";


Expand Down

0 comments on commit ad1706f

Please sign in to comment.