fix(payment): KG 이니시스 결제 콜백 안정성 보강
KG 이니시스 결제에서 통화 스냅샷 이상 시 서버 오류로 새지 않도록 검증 실패/재통보 가능한 응답으로 처리하고, 주문 단위 콜백 락으로 동시 완료 콜백의 중복 후속 처리를 줄입니다. 백엔드 테스트의 통화 스냅샷 fixture도 최신 계약에 맞춰 복구합니다. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
1 parent
d18aaab1fd
commit
8429d8ada5
18 files changed
+472
-19
No files matched your search
@@ -15,6 +15,8 @@ use Plugins\Sirsoft\PayKginicis\Concerns\IssuesReceiptCookie;
|
||||
use Plugins\Sirsoft\PayKginicis\Concerns\PreventsReplayCallback;
|
||||
use Plugins\Sirsoft\PayKginicis\Concerns\ResolvesEasyPaySelection;
|
||||
use Plugins\Sirsoft\PayKginicis\Concerns\SanitizesPgResponse;
|
||||
use Plugins\Sirsoft\PayKginicis\Concerns\SerializesPaymentCallbacks;
|
||||
use Plugins\Sirsoft\PayKginicis\Concerns\ValidatesCbtOrderContext;
|
||||
use Plugins\Sirsoft\PayKginicis\Http\Requests\MobileCallbackRequest;
|
||||
use Plugins\Sirsoft\PayKginicis\Services\KgInicisApiService;
|
||||
|
||||
@@ -33,6 +35,8 @@ class MobileCallbackController
|
||||
use PreventsReplayCallback;
|
||||
use ResolvesEasyPaySelection;
|
||||
use SanitizesPgResponse;
|
||||
use SerializesPaymentCallbacks;
|
||||
use ValidatesCbtOrderContext;
|
||||
|
||||
private const PLUGIN_IDENTIFIER = 'sirsoft-pay_kginicis';
|
||||
|
||||
@@ -172,6 +176,7 @@ class MobileCallbackController
|
||||
// cancelPayment 를 호출해 PG 잔존 승인을 해제한다 (사용자 환불 보장).
|
||||
$approvedTid = null;
|
||||
$approvedTotPrice = 0;
|
||||
$callbackLock = null;
|
||||
|
||||
try {
|
||||
$order = $this->orderService->findByOrderNumber($moid);
|
||||
@@ -182,6 +187,8 @@ class MobileCallbackController
|
||||
return redirect($this->resolveFailUrl(['error' => 'order_not_found', 'orderId' => $moid]));
|
||||
}
|
||||
|
||||
$callbackLock = $this->acquireOrderCallbackLock('mobileAuthCallback', $moid);
|
||||
|
||||
// 서버 승인 요청: POST P_REQ_URL with P_MID + P_TID
|
||||
$result = $this->apiService->authorizeMobilePayment($reqUrl, $pTid);
|
||||
|
||||
@@ -228,6 +235,21 @@ class MobileCallbackController
|
||||
$approvedTotPrice = $totPrice;
|
||||
$embeddedPgProvider = $this->resolveEmbeddedPgProvider($selectedEasyPayMethod);
|
||||
|
||||
$expectedAmount = $this->resolveExpectedPaymentPriceOrNull($order, 'mobile_auth_callback', [
|
||||
'tid' => $tid,
|
||||
'received_amount' => $totPrice,
|
||||
]);
|
||||
if ($expectedAmount === null) {
|
||||
$this->autoCancelIfApproved($approvedTid, $moid, $approvedTotPrice, 'invalid_payment_currency');
|
||||
|
||||
return redirect($this->resolveFailUrl(['error' => 'invalid_payment_currency', 'orderId' => $moid]));
|
||||
}
|
||||
if ($expectedAmount > 0 && $totPrice !== $expectedAmount) {
|
||||
$this->autoCancelIfApproved($approvedTid, $moid, $approvedTotPrice, 'amount_mismatch');
|
||||
|
||||
return redirect($this->resolveFailUrl(['error' => 'amount_mismatch', 'orderId' => $moid]));
|
||||
}
|
||||
|
||||
Log::info('KG Inicis mobile: completing card payment', [
|
||||
'P_OID' => $moid,
|
||||
'P_TID' => $tid,
|
||||
@@ -298,6 +320,8 @@ class MobileCallbackController
|
||||
'message' => $e->getMessage(),
|
||||
'orderId' => $moid,
|
||||
]));
|
||||
} finally {
|
||||
$this->releaseOrderCallbackLock($callbackLock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user