64 lines
2.9 KiB
PHP
64 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Front\Order\Payment;
|
|
|
|
use App\Controllers\Front\Order\OrderController;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
abstract class PaymentController extends OrderController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
}
|
|
|
|
abstract public function getFields(string $action = ""): array;
|
|
abstract public function getFieldFilters(): array;
|
|
abstract public function getFieldBatchFilters(): array;
|
|
|
|
//Update관련 (결제처리용)
|
|
protected function update_form_process($entity)
|
|
{
|
|
$entity = parent::update_form_process($entity);
|
|
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
|
|
return $entity;
|
|
}
|
|
final public function update_form($uid)
|
|
{
|
|
try {
|
|
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
|
$this->_product = $this->getProductModel()->getEntity([$this->_model->getPrimaryKey() => $entity->product_uid]);
|
|
$this->_viewDatas = $this->init(__FUNCTION__);
|
|
$this->_viewDatas['entity'] = $this->update_form_process($entity);
|
|
helper(['form']);
|
|
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
|
return view($this->_viewPath . '/update', ['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());
|
|
}
|
|
}
|
|
final public function update($uid)
|
|
{
|
|
$msg = "";
|
|
try {
|
|
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
|
$this->_product = $this->getProductModel()->getEntity([$this->_model->getPrimaryKey() => $entity->product_uid]);
|
|
$this->_viewDatas = $this->init(__FUNCTION__);
|
|
$this->update_validate($entity);
|
|
$entity = $this->update_process($entity);
|
|
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 결제가 완료하였습니다.";
|
|
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
|
} catch (\Exception $e) {
|
|
$msg = "{$this->_viewDatas['title']}에서 결제를 실패하였습니다.\n" . $e->getMessage();
|
|
log_message("error", $e->getMessage());
|
|
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
|
return redirect()->back()->withInput();
|
|
} finally {
|
|
$this->_session->setFlashdata("return_message", $msg);
|
|
}
|
|
}
|
|
}
|