94 lines
3.4 KiB
PHP
94 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Front;
|
|
|
|
use App\Models\PaymentModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class PaymentController extends FrontController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
$this->_model = new PaymentModel($this->getFields());
|
|
parent::initController($request, $response, $logger);
|
|
$this->_viewPath .= strtolower($this->_model->getClassName());
|
|
//Default 회원정보 Category
|
|
$this->_category = DEFAULTS['PAYMENT_CATEGORY'];
|
|
$this->isRole('index');
|
|
}
|
|
|
|
final public function getFields(string $action = ""): array
|
|
{
|
|
switch ($action) {
|
|
case 'insert':
|
|
return ["TID", "ORDERNO", "AMOUNT", "QUOTA", "ACCEPTNO", "ACCEPTDATE", "RESULTCODE", "created_at"];
|
|
break;
|
|
case "index":
|
|
case "excel":
|
|
case "view":
|
|
return ["ORDERNO", "AMOUNT", "QUOTA", "ACCEPTNO", "ACCEPTDATE", "RESULTCODE", "created_at"];
|
|
break;
|
|
default:
|
|
return [];
|
|
break;
|
|
}
|
|
}
|
|
final public function getFieldFilters(): array
|
|
{
|
|
return [];
|
|
}
|
|
final public function getFieldBatchFilters(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
//추가기능
|
|
//결제(uid -> order_uid)
|
|
private function card_init()
|
|
{
|
|
$this->_viewDatas['fields'] = [
|
|
"card_quota", "card_number", "card_expiration", "card_email", "card_mobile"
|
|
];
|
|
$this->_viewDatas['fieldRules'] = [
|
|
'card_quota' => 'required|in_list[00,01]',
|
|
'card_number' => 'required|regex_match[/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}/]',
|
|
'card_expiration' => 'required|regex_match[/^[1-12]{2}-[0-9]{4}/]',
|
|
'card_email' => 'required|valid_email',
|
|
'card_mobile' => 'required|regex_match[/^^[0-9]{3}-[0-9]{4}-[0-9]{4}/]',
|
|
];
|
|
$this->_viewDatas['fieldFilters'] = ['card_quota'];
|
|
$this->_viewDatas['fieldFormOptions']['card_quota'] = lang($this->_model->getClassName() . '.CARD_QUOTA');
|
|
}
|
|
public function card_form($uid)
|
|
{
|
|
try {
|
|
$this->card_init();
|
|
helper(['form']);
|
|
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
|
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
|
return view($this->_viewPath . '/card', ['viewDatas' => $this->_viewDatas]);
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
|
|
}
|
|
}
|
|
protected function card_validate()
|
|
{
|
|
//fieldData Rule 검사
|
|
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
|
throw new \Exception("결제정보의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
|
}
|
|
//fieldData 적용
|
|
$this->_viewDatas['fieldDatas'] = array();
|
|
foreach ($this->_viewDatas['fields'] as $field) {
|
|
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
|
|
}
|
|
}
|
|
protected function card_process()
|
|
{
|
|
return $this->_model->create($this->_viewDatas['fieldDatas']);
|
|
}
|
|
}
|