-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.php
47 lines (40 loc) · 1.31 KB
/
index.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
<?php
require __DIR__ . '/../vendor/autoload.php';
use function GuzzleHttp\Psr7\parse_query;
use Mitake\Message\Receipt;
use Mitake\Message\StatusCode;
use Slim\Http\Request;
use Slim\Http\Response;
$app = new Slim\App();
$app->get('/callback', function (Request $request, Response $response, $args) {
$params = parse_query($request->getUri()->getQuery());
if (!isset($params['msgid'])) {
return $response->withStatus(400)
->withJson([
'error' => 'invalid request',
'uri' => $request->getUri()->__toString(),
]);
}
$receipt = new Receipt();
$receipt->setMsgid($params['msgid']);
if (isset($params['dstaddr'])) {
$receipt->setDstaddr($params['dstaddr']);
}
if (isset($params['dlvtime'])) {
$receipt->setDlvtime($params['dlvtime']);
}
if (isset($params['donetime'])) {
$receipt->setDonetime($params['donetime']);
}
if (isset($params['statuscode'])) {
$receipt->setStatuscode(new StatusCode($params['statuscode']));
}
if (isset($params['statusstr'])) {
$receipt->setStatusstr($params['statusstr']);
}
if (isset($params['StatusFlag'])) {
$receipt->setStatusFlag($params['StatusFlag']);
}
return $response->withJson($receipt->toArray());
});
$app->run();