-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirect_billing_calculate.php
50 lines (45 loc) · 1.85 KB
/
direct_billing_calculate.php
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
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use Simpay\Configuration;
use Simpay\DirectBillingCalculateApi;
use Simpay\Model\Request\Amount;
use Simpay\Model\Request\ServiceId;
$configuration = new Configuration('your_api_key', 'your_api_password', 'en');
$factory = new Simpay\HttpClientFactory($configuration);
$api = new DirectBillingCalculateApi($factory);
try {
// Fee calculation for a specific provider
$serviceId = new ServiceId('d151e4f9');
$serviceCalculation = $api->directBillingServiceCalculate($serviceId, new Amount(23.00));
if (null !== $serviceCalculation->orange) {
echo $serviceCalculation->orange->net . PHP_EOL;
echo $serviceCalculation->orange->gross . PHP_EOL;
}
if (null !== $serviceCalculation->play) {
echo $serviceCalculation->play->net . PHP_EOL;
echo $serviceCalculation->play->gross . PHP_EOL;
}
if (null !== $serviceCalculation->tMobile) {
echo $serviceCalculation->tMobile->net . PHP_EOL;
echo $serviceCalculation->tMobile->gross . PHP_EOL;
}
} catch (Simpay\Exception\Unauthorized $exception) {
// Handle unauthorized exception
\print_r($exception->getMessage());
} catch (Simpay\Exception\Forbidden $exception) {
// Handle forbidden exception
\print_r($exception->getMessage());
} catch (Simpay\Exception\NotFound $exception) {
// Handle not found exception
\print_r($exception->getMessage());
} catch (Simpay\Exception\UnprocessableEntity $exception) {
// Handle unprocessable entity exception
\print_r($exception->getMessage());
} catch (Simpay\Exception\InternalServerError $exception) {
// Handle internal server error exception
\print_r($exception->getMessage());
} catch (Simpay\Exception\Unknown $exception) {
// Handle unknown exception
\print_r($exception->getMessage());
}