Files
HeuJung b07d6c8953 fix(ecommerce,tosspayments,templates): 에스크로 표시 누락·결제수단 전환 시 입력 잔류 수정
- 에스크로 표시가 영구히 렌더되지 않던 문제: is_escrow 가 DB·모델·부분취소 차단
 로직에는 있으나 OrderPaymentResource 가 내보내지 않아, 이 값을 참조하는 주문
 상세(관리자·구매자)의 에스크로 행이 항상 false 로 평가됐다. Resource 에 노출한다.

- 결제수단을 바꿔도 이전 수단의 입력이 주문에 실리던 문제: 결제수단 버튼이
 _local.paymentMethod 만 바꾸고 슬롯이 소유한 확장 페이로드·환불계좌는 비우지
 않았다. 확장 슬롯과 환불계좌 블록은 결제수단 조건부로 언마운트되지만 _local
 값은 남으므로, 무통장에서 현금영수증·환불계좌를 입력한 뒤 카드로 전환하면 그
 값이 주문 생성 요청에 그대로 실렸다.
 프론트는 결제수단 전환 시 슬롯 소유 상태를 초기화하고, 서버는 환불계좌가 쓰이지
 않는 결제수단이면 저장하지 않도록 게이팅한다(현금영수증은 이미 dbank 게이트 보유).

- Modal 이 받지 않는 size prop 을 쓰던 4곳을 width 로 교체(무시되어 의도한 폭이
 나오지 않았다). 토스 에러 모달의 setState target 을 params 안으로 옮긴다.

- 레이아웃 편집기 팔레트에서 체크박스를 넣으면 라벨 없이 네모 칸만 놓이던 문제:
 Checkbox 는 label prop 을 렌더하지 않으므로 Label 래핑 + Span 텍스트로 바꾸고,
 Accordion 이 Label 을 받도록 중첩 스펙을 맞춘다.
2026-08-06 13:58:00 +09:00

79 lines
3.0 KiB
PHP

<?php
namespace Modules\Sirsoft\Ecommerce\Tests\Unit\Http\Resources;
use Illuminate\Http\Request;
use Modules\Sirsoft\Ecommerce\Database\Factories\OrderPaymentFactory;
use Modules\Sirsoft\Ecommerce\Enums\PaymentMethodEnum;
use Modules\Sirsoft\Ecommerce\Http\Resources\OrderPaymentResource;
use Modules\Sirsoft\Ecommerce\Tests\ModuleTestCase;
/**
* 주문 결제 정보 리소스 테스트
*/
class OrderPaymentResourceTest extends ModuleTestCase
{
/**
* 무통장(dbank) 결제의 계좌 요약(account_info)이 은행명·계좌번호·예금주로 구성된다.
*
* 회귀 배경: getAccountInfo() 가 존재하지 않는 'bank_transfer' 케이스로 분기해
* dbank 주문의 account_info 가 항상 null 이던 결함(실제 무통장 수단 값은 'dbank').
*/
public function test_account_info_for_dbank_payment_summarizes_bank_account(): void
{
$payment = OrderPaymentFactory::new()->make([
'payment_method' => PaymentMethodEnum::DBANK,
'dbank_name' => '국민은행',
'dbank_account' => '01026154146',
'dbank_holder' => '정정홍',
]);
$array = (new OrderPaymentResource($payment))->toArray(Request::create('/'));
$this->assertSame('국민은행 01026154146 (정정홍)', $array['account_info']);
}
/**
* 카드 결제의 계좌 요약은 카드사명 + 마스킹 카드번호 (+ 일시불/할부)로 구성된다.
*/
public function test_account_info_for_card_payment_summarizes_card(): void
{
$payment = OrderPaymentFactory::new()->make([
'payment_method' => PaymentMethodEnum::CARD,
'card_name' => '신한카드',
'card_number_masked' => '1234-****-****-5678',
'card_installment_months' => 0,
]);
$array = (new OrderPaymentResource($payment))->toArray(Request::create('/'));
$this->assertStringContainsString('신한카드', $array['account_info']);
$this->assertStringContainsString('1234-****-****-5678', $array['account_info']);
}
/**
* 에스크로 여부가 API 로 노출된다.
*
* 회귀 배경(#454): is_escrow 는 DB·모델·부분취소 차단 로직(PaymentRefundListener)에는
* 있었지만 Resource 가 내보내지 않아, 이 값을 참조하는 주문 상세 화면(관리자/회원)의
* 에스크로 표시가 항상 false 로 평가되어 렌더되지 않았다.
*/
public function test_is_escrow_is_exposed(): void
{
$escrow = OrderPaymentFactory::new()->make([
'payment_method' => PaymentMethodEnum::VBANK,
'is_escrow' => true,
]);
$normal = OrderPaymentFactory::new()->make([
'payment_method' => PaymentMethodEnum::VBANK,
'is_escrow' => false,
]);
$request = Request::create('/');
$this->assertTrue((new OrderPaymentResource($escrow))->toArray($request)['is_escrow']);
$this->assertFalse((new OrderPaymentResource($normal))->toArray($request)['is_escrow']);
}
}