v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* KG 이니시스 입금통보/에스크로/모바일 가상계좌 통보 IP 화이트리스트 미들웨어
|
||||
*
|
||||
* KG 이니시스 공식 발송 IP 만 허용. 로컬/테스트 환경(127.0.0.1, ::1)은 예외.
|
||||
* 위변조/재처리 방어의 1차 게이트로, FormRequest::authorize() 대신 라우트
|
||||
* 미들웨어 계층에서 처리해 권한 책임을 명확히 분리한다.
|
||||
*/
|
||||
class InicisNotifyIpWhitelist
|
||||
{
|
||||
/** KG 이니시스 공식 발송 IP — 입금통보/에스크로/모바일 가상계좌 통보 공통 */
|
||||
private const ALLOWED_IPS = [
|
||||
'203.238.37.15',
|
||||
'203.238.37.50',
|
||||
'39.115.212.9',
|
||||
'39.115.212.200',
|
||||
'118.129.210.25',
|
||||
'183.109.71.153',
|
||||
];
|
||||
|
||||
/**
|
||||
* 요청 IP 가 화이트리스트에 있는지 확인하고 통과 여부 결정
|
||||
*
|
||||
* @param Request $request 들어온 HTTP 요청
|
||||
* @param Closure $next 다음 미들웨어
|
||||
* @return Response 다음 미들웨어 응답 또는 403
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (app()->environment('testing', 'local')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if (! in_array($request->ip(), self::ALLOWED_IPS, true)) {
|
||||
abort(403, 'Forbidden');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AuthCallbackRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* authorize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* rules
|
||||
|
||||
*
|
||||
|
||||
* @return array
|
||||
|
||||
*/
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'resultCode' => ['required', 'string'],
|
||||
'resultMsg' => ['nullable', 'string'],
|
||||
'authToken' => ['nullable', 'string'],
|
||||
'authUrl' => ['nullable', 'string'],
|
||||
'checkAckUrl' => ['nullable', 'string'], // authUrl 과 동일 역할, 버전에 따라 다름
|
||||
'netCancelUrl' => ['nullable', 'string'],
|
||||
'idc_name' => ['nullable', 'string'],
|
||||
// 주문번호: 구버전 MOID 또는 신버전 orderNumber
|
||||
'MOID' => ['nullable', 'string'],
|
||||
'orderNumber' => ['nullable', 'string'],
|
||||
// 결제금액: 콜백에 없을 수 있음 → 컨트롤러에서 주문 조회로 보완
|
||||
'TotPrice' => ['nullable', 'integer', 'min:0'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator): void
|
||||
{
|
||||
Log::error('KG Inicis: AuthCallbackRequest validation failed', [
|
||||
'errors' => $validator->errors()->toArray(),
|
||||
'input' => array_keys($this->all()),
|
||||
]);
|
||||
|
||||
throw new \Illuminate\Validation\ValidationException($validator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* KG 이니시스 CBT 인증 콜백 요청 검증.
|
||||
*
|
||||
* PG 실패/취소 콜백도 정상 라우팅되어야 하므로 필드는 대부분 nullable 로 두고,
|
||||
* 컨트롤러가 결과 코드와 주문 상태에 따라 결제 성공/실패 흐름을 결정한다.
|
||||
*/
|
||||
class CbtCallbackRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* authorize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'sid' => ['nullable', 'string', 'max:255'],
|
||||
'resultCode' => ['nullable', 'string', 'max:100'],
|
||||
'resultMsg' => ['nullable', 'string', 'max:500'],
|
||||
'orderID' => ['nullable', 'string', 'max:100'],
|
||||
'orderId' => ['nullable', 'string', 'max:100'],
|
||||
'oid' => ['nullable', 'string', 'max:100'],
|
||||
'mid' => ['nullable', 'string', 'max:30'],
|
||||
'paymethod' => ['nullable', 'string', 'max:50'],
|
||||
'selectedPaymentMethod' => ['nullable', 'string', 'max:50'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* KG 이니시스 CBT 편의점 입금 NOTI 요청 검증.
|
||||
*
|
||||
* POST /plugins/sirsoft-pay_kginicis/payment/cbt/cvs-notify
|
||||
*
|
||||
* CBT CVS 입금 통보는 JSON으로 수신되며, PG 재시도 정책 때문에 필수값 누락도
|
||||
* Laravel 422가 아니라 컨트롤러에서 "FAIL" text/plain으로 응답한다.
|
||||
*/
|
||||
class CbtCvsNotifyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* authorize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->all() !== []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $this->getContent();
|
||||
if ($content === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! mb_check_encoding($content, 'UTF-8')) {
|
||||
$converted = @mb_convert_encoding($content, 'UTF-8', 'CP949');
|
||||
if ($converted !== false && $converted !== '') {
|
||||
$content = $converted;
|
||||
}
|
||||
}
|
||||
|
||||
$decoded = json_decode($content, true);
|
||||
if (is_array($decoded)) {
|
||||
$this->replace($decoded);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'tid' => ['nullable', 'string', 'max:80'],
|
||||
'mid' => ['nullable', 'string', 'max:20'],
|
||||
'applDt' => ['nullable', 'string', 'max:8'],
|
||||
'applTm' => ['nullable', 'string', 'max:6'],
|
||||
'status' => ['nullable', 'string', 'max:10'],
|
||||
'payNm' => ['nullable', 'string', 'max:50'],
|
||||
'orderId' => ['nullable', 'string', 'max:100'],
|
||||
'applNo' => ['nullable', 'string', 'max:80'],
|
||||
'sid' => ['nullable', 'string', 'max:100'],
|
||||
'convenience' => ['nullable', 'string', 'max:30'],
|
||||
'confNo' => ['nullable', 'string', 'max:80'],
|
||||
'receiptNo' => ['nullable', 'string', 'max:80'],
|
||||
'paymentTerm' => ['nullable', 'string', 'max:20'],
|
||||
'amount' => ['nullable'],
|
||||
'currencyCd' => ['nullable', 'string', 'max:10'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class MobileCallbackRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* authorize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* rules
|
||||
|
||||
*
|
||||
|
||||
* @return array
|
||||
|
||||
*/
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// 인증 결과 코드: '00' = 성공
|
||||
'P_STATUS' => ['required', 'string'],
|
||||
'P_RMESG1' => ['nullable', 'string'],
|
||||
// 거래번호
|
||||
'P_TID' => ['nullable', 'string'],
|
||||
// 서버 승인 URL (IDC 화이트리스트 검증 대상)
|
||||
'P_REQ_URL' => ['nullable', 'string'],
|
||||
// 결제 금액
|
||||
'P_AMT' => ['nullable', 'string'],
|
||||
// 주문번호
|
||||
'P_OID' => ['nullable', 'string'],
|
||||
// IDC 센터 코드 (fc/ks/stg)
|
||||
'idc_name' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator): void
|
||||
{
|
||||
Log::error('KG Inicis: MobileCallbackRequest validation failed', [
|
||||
'errors' => $validator->errors()->toArray(),
|
||||
'input' => array_keys($this->all()),
|
||||
]);
|
||||
|
||||
throw new \Illuminate\Validation\ValidationException($validator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class MobileSignatureRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* authorize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* rules
|
||||
|
||||
*
|
||||
|
||||
* @return array
|
||||
|
||||
*/
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'oid' => ['required', 'string', 'max:40'],
|
||||
'price' => ['required', 'integer', 'min:1'],
|
||||
'timestamp' => ['required', 'string', 'max:20'],
|
||||
'buyer_email' => ['nullable', 'string', 'max:255'],
|
||||
'buyer_phone' => ['nullable', 'string', 'max:30'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* KG 이니시스 모바일 가상계좌 입금 통보 요청 검증
|
||||
*
|
||||
* POST /plugins/sirsoft-pay_kginicis/payment/mobile/vbank-notify
|
||||
* 공식 매뉴얼: https://manual.inicis.com/pay/etc-noti.html#mo
|
||||
*
|
||||
* P_STATUS == "02" && P_TYPE == "VBANK" 인 경우만 실제 입금 처리.
|
||||
* 응답으로 "OK" (200, text/plain) 를 돌려줘야 합니다.
|
||||
*/
|
||||
class MobileVbankNotifyRequest extends FormRequest
|
||||
{
|
||||
/** EUC-KR → UTF-8 변환 대상 필드 */
|
||||
private const KOREAN_FIELDS = ['P_FN_NM', 'P_UNAME'];
|
||||
|
||||
/**
|
||||
|
||||
* authorize
|
||||
|
||||
*
|
||||
|
||||
* @return bool
|
||||
|
||||
*/
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$data = $this->all();
|
||||
|
||||
foreach (self::KOREAN_FIELDS as $field) {
|
||||
if (empty($data[$field]) || ! is_string($data[$field])) {
|
||||
continue;
|
||||
}
|
||||
if (! mb_check_encoding($data[$field], 'UTF-8')) {
|
||||
$converted = @mb_convert_encoding($data[$field], 'UTF-8', 'CP949');
|
||||
if ($converted !== false && $converted !== '') {
|
||||
$data[$field] = $converted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->replace($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* rules
|
||||
|
||||
*
|
||||
|
||||
* @return array
|
||||
|
||||
*/
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// 필수 식별자
|
||||
'P_TID' => ['required', 'string', 'max:40'],
|
||||
'P_MID' => ['required', 'string', 'max:10'],
|
||||
'P_OID' => ['required', 'string', 'max:100'],
|
||||
'P_AMT' => ['required', 'string', 'max:12'],
|
||||
'P_STATUS' => ['required', 'string', 'max:2'],
|
||||
'P_TYPE' => ['required', 'string', 'max:10'],
|
||||
|
||||
// 입금 정보
|
||||
'P_AUTH_DT' => ['nullable', 'string', 'max:14'],
|
||||
'P_FN_CD1' => ['nullable', 'string', 'max:4'],
|
||||
'P_FN_NM' => ['nullable', 'string', 'max:50'],
|
||||
'P_UNAME' => ['nullable', 'string', 'max:30'],
|
||||
'P_RMESG1' => ['nullable', 'string', 'max:500'],
|
||||
|
||||
// 기타 (선택, 차단 안 되게 nullable)
|
||||
'P_FN_CD2' => ['nullable', 'string'],
|
||||
'P_RMESG2' => ['nullable', 'string'],
|
||||
'P_NOTI' => ['nullable', 'string', 'max:600'],
|
||||
'P_AUTH_NO' => ['nullable', 'string'],
|
||||
|
||||
// 현금영수증 정보 (선택)
|
||||
'P_CSHR_AMT' => ['nullable', 'string', 'max:12'],
|
||||
'P_CSHR_TAX' => ['nullable', 'string', 'max:12'],
|
||||
'P_CSHR_TYPE' => ['nullable', 'string', 'max:14'],
|
||||
'P_CSHR_DT' => ['nullable', 'string', 'max:14'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PaymentCloseReportRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 결제창 닫힘 보고 요청을 허용합니다.
|
||||
*
|
||||
* @return bool 요청 허용 여부
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 결제창 닫힘 보고 요청 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, array<int, string>> 필드별 검증 규칙
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'oid' => ['required', 'string', 'max:40'],
|
||||
'price' => ['required', 'integer', 'min:1'],
|
||||
'buyer_email' => ['nullable', 'string', 'max:255'],
|
||||
'buyer_phone' => ['nullable', 'string', 'max:30'],
|
||||
'payment_method' => ['nullable', 'string', 'max:50'],
|
||||
'reason' => ['nullable', 'string', 'max:80'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SignatureRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* authorize
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* rules
|
||||
|
||||
*
|
||||
|
||||
* @return array
|
||||
|
||||
*/
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'oid' => ['required', 'string', 'max:40'],
|
||||
'price' => ['required', 'integer', 'min:100'],
|
||||
'timestamp' => ['required', 'string', 'max:20'],
|
||||
'buyer_email' => ['nullable', 'string', 'max:255'],
|
||||
'buyer_phone' => ['nullable', 'string', 'max:30'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plugins\Sirsoft\PayKginicis\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* KG 이니시스 PC 가상계좌 입금 통보 요청 검증
|
||||
*
|
||||
* POST /plugins/sirsoft-pay_kginicis/payment/vbank-notify
|
||||
* 공식 매뉴얼: https://manual.inicis.com/pay/etc-noti.html#pc
|
||||
*
|
||||
* KG 이니시스 서버가 직접 호출하는 입금 확인 웹훅.
|
||||
* 응답으로 정확히 "OK" (200, text/plain) 를 돌려줘야 하며,
|
||||
* 그렇지 않으면 최대 10회까지 재시도합니다.
|
||||
*
|
||||
* 한글 데이터(nm_inputbank, nm_input)는 EUC-KR 인코딩으로 수신될 수 있으므로
|
||||
* prepareForValidation 에서 UTF-8 로 자동 변환합니다.
|
||||
*/
|
||||
class VbankNotifyRequest extends FormRequest
|
||||
{
|
||||
/** EUC-KR → UTF-8 변환 대상 필드 */
|
||||
private const KOREAN_FIELDS = ['nm_inputbank', 'nm_input'];
|
||||
|
||||
/**
|
||||
|
||||
* authorize
|
||||
|
||||
*
|
||||
|
||||
* @return bool
|
||||
|
||||
*/
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$data = $this->all();
|
||||
|
||||
foreach (self::KOREAN_FIELDS as $field) {
|
||||
if (empty($data[$field]) || ! is_string($data[$field])) {
|
||||
continue;
|
||||
}
|
||||
if (! mb_check_encoding($data[$field], 'UTF-8')) {
|
||||
$converted = @mb_convert_encoding($data[$field], 'UTF-8', 'CP949');
|
||||
if ($converted !== false && $converted !== '') {
|
||||
$data[$field] = $converted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->replace($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* rules
|
||||
|
||||
*
|
||||
|
||||
* @return array
|
||||
|
||||
*/
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// 필수 식별자
|
||||
'no_tid' => ['required', 'string', 'max:40'],
|
||||
'no_oid' => ['required', 'string', 'max:40'],
|
||||
'id_merchant' => ['required', 'string', 'max:10'],
|
||||
|
||||
// 거래 일시
|
||||
'dt_trans' => ['required', 'string', 'max:8'],
|
||||
'tm_trans' => ['required', 'string', 'max:6'],
|
||||
|
||||
// 계좌 정보
|
||||
'cd_bank' => ['required', 'string', 'max:8'],
|
||||
'cd_deal' => ['nullable', 'string', 'max:8'],
|
||||
'no_vacct' => ['required', 'string', 'max:20'],
|
||||
'amt_input' => ['required', 'string', 'max:13'],
|
||||
|
||||
// 입금자 정보 (선택)
|
||||
'nm_inputbank' => ['nullable', 'string', 'max:10'],
|
||||
'nm_input' => ['nullable', 'string', 'max:20'],
|
||||
|
||||
// 정산 정보 (선택)
|
||||
'dt_inputstd' => ['nullable', 'string', 'max:8'],
|
||||
'dt_calculstd' => ['nullable', 'string', 'max:8'],
|
||||
'flg_close' => ['nullable', 'string', 'max:1'],
|
||||
|
||||
// 현금영수증 정보 (선택)
|
||||
'dt_cshr' => ['nullable', 'string', 'max:8'],
|
||||
'tm_cshr' => ['nullable', 'string', 'max:6'],
|
||||
'no_cshr_appl' => ['nullable', 'string', 'max:9'],
|
||||
'no_cshr_tid' => ['nullable', 'string', 'max:40'],
|
||||
|
||||
// 기타 (선택, 차단 안 되게 nullable)
|
||||
'msg_id' => ['nullable', 'string'],
|
||||
'no_msgseq' => ['nullable', 'string'],
|
||||
'cd_joinorg' => ['nullable', 'string'],
|
||||
'dt_transbase' => ['nullable', 'string'],
|
||||
'no_transeq' => ['nullable', 'string'],
|
||||
'type_msg' => ['nullable', 'string'],
|
||||
'cl_close' => ['nullable', 'string'],
|
||||
'cl_kor' => ['nullable', 'string'],
|
||||
'no_msgmanage' => ['nullable', 'string'],
|
||||
'amt_check' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user