/
AcquiringController.php
58 lines (43 loc) · 1.33 KB
/
AcquiringController.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
51
52
53
54
55
56
57
58
<?php namespace FintechFab\MPSP\Controllers;
use FintechFab\MPSP\Repositories\TransferRepository;
use Input;
use Queue;
class AcquiringController extends BaseController
{
public function __construct(TransferRepository $transfers)
{
$this->transfers = $transfers;
}
/**
* завершить 3DS
*/
public function finish_3ds()
{
$phone = Input::get('phone');
$code = Input::get('code');
$dataFor3DS = Input::except('phone', 'code');
if (is_null($phone) || is_null($code)) {
$this->setResponseCode(self::C_CODE_VALIDATION_ERROR);
$this->setResponseMessage('phone или code некорректны');
return $this->createErrorResponseData();
}
// ищем трансфер
$transfer = $this->transfers->findByPhoneAndCode($phone, $code);
// трансфер не найден
if (is_null($transfer)) {
$this->setResponseCode(self::C_CODE_TRANSFER_DOES_NOT_EXIST);
return $this->createErrorResponseData();
}
$queueData = [
'transfer' => $transfer->toArray(),
'3ds_data' => $dataFor3DS,
];
// кидаем в очередь задачу с полученными данными
Queue::connection('gateway')
->push('acquiringFinish3DS', $queueData);
$this->setResponseCode(self::C_CODE_SUCCESS);
return $this->createSuccessResponseData([
'transfer' => $transfer->toArray(),
]);
}
}