Skip to content

Commit b9e3c06

Browse files
committed
Added Drivers Melipayamak
1 parent f027f47 commit b9e3c06

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ protected $fillable =
7373
<td>Ghasedak</td>
7474
<td><a href="https://ghasedak.me">https://ghasedak.me</a></td>
7575
</tr>
76+
<tr>
77+
<td>Melipayamak</td>
78+
<td><a href="https://www.melipayamak.com">https://www.melipayamak.com</a></td>
79+
</tr>
7680
</tbody>
7781
</table>
7882

SMS_API_KEY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ VORDIA_SMS_DRIVER=ghasedak
1717
GHASEDAK_API_KEY= Added API KEY
1818
GHASEDAK_OTP_TEMPLATE_ID= Added OTP TEMPLATE ID
1919
```
20+
21+
### Melipayamak.com
22+
23+
```bash
24+
VORDIA_SMS_DRIVER=melipayamak
25+
MELIPAYAMAK_USERNAME=your_username
26+
MELIPAYAMAK_PASSWORD=your_password
27+
MELIPAYAMAK_PATTERN=your_pattern_code
28+
```

config/vordia.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
| This option controls the default SMS driver that is used to send
1111
| messages to mobile phones.
1212
|
13-
| Supported: "smsir", "Ghasedakme"
13+
| Supported: "Smsir", "Ghasedakme", "Melipayamak"
1414
|
1515
*/
1616

@@ -35,12 +35,20 @@
3535
],
3636

3737
'ghasedak' => [
38-
'class' => \Rayiumir\Vordia\Http\Channels\Drivers\Ghasedak\Ghasedak::class,
38+
'class' => Rayiumir\Vordia\Http\Channels\Drivers\Ghasedak\Ghasedak::class,
3939
'config' => [
4040
'api_key' => env('GHASEDAK_API_KEY'),
4141
'template_id' => env('GHASEDAK_OTP_TEMPLATE_ID'),
4242
]
4343
],
44+
'melipayamak' => [
45+
'class' => Rayiumir\Vordia\Http\Channels\Drivers\Melipayamak\Melipayamak::class,
46+
'config' => [
47+
'username' => env('MELIPAYAMAK_USERNAME'),
48+
'password' => env('MELIPAYAMAK_PASSWORD'),
49+
'pattern' => env('MELIPAYAMAK_PATTERN'),
50+
]
51+
],
4452
]
4553
]
4654
];
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Rayiumir\Vordia\Http\Channels\Drivers\Melipayamak;
4+
5+
use Illuminate\Support\Facades\Http;
6+
use InvalidArgumentException;
7+
use Rayiumir\Vordia\Http\Channels\Drivers\SmsDriverInterface;
8+
use RuntimeException;
9+
10+
class Melipayamak implements SmsDriverInterface
11+
{
12+
private string $username;
13+
private string $password;
14+
private string $pattern;
15+
16+
public function __construct(array $config)
17+
{
18+
$this->username = $config['username'] ?? '';
19+
$this->password = $config['password'] ?? '';
20+
$this->pattern = $config['pattern'] ?? '';
21+
22+
if (empty($this->username) || empty($this->password) || empty($this->pattern)) {
23+
throw new InvalidArgumentException('Melipayamak configuration is invalid.');
24+
}
25+
}
26+
27+
public function send(string $receptor, array $parameters): void
28+
{
29+
$code = $parameters['code'] ?? '';
30+
31+
$response = Http::post('https://rest.payamak-panel.com/api/SendSMS/BaseServiceNumber', [
32+
'username' => $this->username,
33+
'password' => $this->password,
34+
'to' => $receptor,
35+
'bodyId' => $this->pattern,
36+
'text' => $code
37+
]);
38+
39+
if (!$response->successful() || $response->json('RetStatus') != 1) {
40+
throw new RuntimeException('Melipayamak error: ' . $response->body());
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)