-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsms_transaction.php
More file actions
66 lines (58 loc) · 2.33 KB
/
sms_transaction.php
File metadata and controls
66 lines (58 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use Simpay\Configuration;
use Simpay\Exception\Forbidden;
use Simpay\Exception\InternalServerError;
use Simpay\Exception\NotFound;
use Simpay\Exception\Unauthorized;
use Simpay\Exception\Unknown;
use Simpay\Exception\UnprocessableEntity;
use Simpay\Model\Request\ServiceId;
use Simpay\Model\Request\SmsTransactionId;
$configuration = new Configuration('your_api_key', 'your_api_password', 'en');
$factory = new Simpay\HttpClientFactory($configuration);
$api = new Simpay\SmsTransactionApi($factory);
try {
// Get all SMS transactions for a service
$serviceId = new ServiceId('d151e4f9');
$transactions = $api->smsTransactionsList($serviceId);
foreach ($transactions->data as $transaction) {
echo $transaction->id . PHP_EOL;
echo $transaction->code . PHP_EOL;
echo $transaction->value . PHP_EOL;
echo $transaction->used . PHP_EOL;
echo $transaction->from . PHP_EOL;
echo $transaction->sendNumber . PHP_EOL;
echo $transaction->sendAt->format('Y-m-d H:i:s') . PHP_EOL;
}
// Get details of an SMS transaction for a service
$serviceId = new ServiceId('d151e4f9');
$transactionId = new SmsTransactionId(123456);
$transaction = $api->smsTransactionsShow($serviceId, $transactionId);
echo $transaction->id . PHP_EOL;
echo $transaction->code . PHP_EOL;
echo $transaction->value . PHP_EOL;
echo $transaction->used . PHP_EOL;
echo $transaction->from . PHP_EOL;
echo $transaction->sendNumber . PHP_EOL;
echo $transaction->sendAt->format('Y-m-d H:i:s') . PHP_EOL;
} catch (Unauthorized $exception) {
// Handle unauthorized exception
echo $exception->getMessage() . PHP_EOL;
} catch (Forbidden $exception) {
// Handle forbidden exception
echo $exception->getMessage() . PHP_EOL;
} catch (NotFound $exception) {
// Handle not found exception
echo $exception->getMessage() . PHP_EOL;
} catch (UnprocessableEntity $exception) {
// Handle unprocessable entity exception
echo $exception->getMessage() . PHP_EOL;
} catch (InternalServerError $exception) {
// Handle internal server error exception
echo $exception->getMessage() . PHP_EOL;
} catch (Unknown $exception) {
// Handle unknown exception
echo $exception->getMessage() . PHP_EOL;
}