Skip to content

Commit

Permalink
add melipayamak
Browse files Browse the repository at this point in the history
  • Loading branch information
pamenary authored Mar 17, 2017
1 parent f0350ee commit 9488921
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ http://firstpayamak.ir
http://fortytwo.com
http://freepayamak.ir
http://sms.hostiran.net
http://melipayamak.ir
77 changes: 77 additions & 0 deletions src/Gateways/MelipayamakGateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Pamenary\LaravelSms\Gateways;

/**
* Created by PhpStorm.
* User: Ali
* Date: 12/23/2016
* Time: 12:51 PM
*/
class MelipayamakGateway extends GatewayAbstract {

/**
* AdpdigitalGateway constructor.
*/
public function __construct() {

$this->webService = config('sms.gateway.melipayamak.webService');
$this->username = config('sms.gateway.melipayamak.username');
$this->password = config('sms.gateway.melipayamak.password');
$this->from = config('sms.gateway.melipayamak.from');
}


/**
* @param array $numbers
* @param $text
* @param bool $isflash
*
* @return mixed
* @internal param $to | array
*/
public function sendSMS( array $numbers, $text, $isflash = false ) {
try {
// Check credit for the gateway
if ( ! $this->GetCredit() ) {
return false;
}
$client = new \SoapClient( $this->webService );
$result = $client->SendSms(
[
'username' => $this->username,
'password' => $this->password,
'from' => $this->from,
'to' => $numbers,
'text' => $text,
'isflash' => $isflash,
'udh' => '',
'recId' => [ 0 ],
'status' => 0x0,
]
);

return $result->SendSmsResult;
} catch( SoapFault $ex ) {
echo $ex->faultstring;
}
}


/**
* @return mixed
*/
public function getCredit() {
try {
$client = new \SoapClient( $this->webService );

return $client->GetCredit( [
"username" => $this->username,
"password" => $this->password,
] )->GetCreditResult;
} catch( SoapFault $ex ) {
echo $ex->faultstring;
}
}

}
7 changes: 7 additions & 0 deletions src/Laravel/config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@
'password' => '',
'from' => '',
],
'melipayamak' => [
'website' => 'http://melipayamak.ir',
'webService' => 'http://melipayamak.ir/post/send.asmx?wsdl',
'username' => '',
'password' => '',
'from' => '',
],
],

];

0 comments on commit 9488921

Please sign in to comment.