refactor(ecommerce,pay): 간편결제 브랜드 마크 카탈로그 편입 + 애플페이 iOS 게이팅 이관

3사 PG 플러그인의 체크아웃 DOM 인젝터가 렌더 후 브랜드 마크를 주입하고
injector끼리 같은 버튼을 두고 경합하던 구조를 제거한다. 시각정보(색 배지/
SVG 로고)를 결제수단 카탈로그(_cached_brand_mark)로 편입해 코어 체크아웃
레이아웃의 신규 BrandMark 컴포넌트가 데이터 기반으로 직접 렌더한다.
reconcileKginicisPatchedDuplicates(중복 방어)도 함께 제거했다.

애플페이 iOS 게이팅도 injector 밖으로 이관: 이커머스 모듈 DetectDevice
미들웨어가 UA로 기기를 판정해 코어 core.frontend.filter_app_config 훅으로
appConfig.isIos를 주입하고(1차), 템플릿 부트스트랩이 iPadOS 데스크탑 UA를
클라 신호로 보정한다(2차). 코어는 훅만 제공하고 감지 로직은 모듈이 소유한다.

미들웨어는 Router::pushMiddlewareToGroup 이 아닌 HTTP Kernel::appendMiddlewareToGroup
으로 web 그룹에 등록한다(전자는 Router 레지스트리만 갱신해 SSR 셸 요청 파이프라인에
미반영 → isIos 항상 false). sirsoft-gdpr 선례와 동일.

코어 최소 요구 버전 7.0.5 상향(appConfig 필터 훅 도입).
This commit is contained in:
HeuJung committed 2026-07-15 17:50:39 +09:00
1 parent e896a47d4f
commit 8b9bfd0c91
58 files changed
+1582 -2013

No files matched your search

@@ -17,6 +17,9 @@
- 결제 플러그인이 제공하는 간편결제도 신용카드·가상계좌와 동일하게 정식 결제수단으로 취급됩니다. 주문 내역에 실제로 선택한 결제수단(예: 네이버페이)이 그대로 기록되어 관리자 주문 상세와 주문 목록에서 확인할 수 있습니다.
- 쇼핑몰 환경설정 > 주문설정의 결제수단 목록에서 간편결제가 "PG 불필요"가 아니라 "PG 고정"으로 표시되고 어느 결제대행사를 통해 처리되는지 함께 보여줍니다. 간편결제는 해당 결제대행사 전용이므로 다른 대행사로 바꿀 수 없습니다.
- 주문서의 간편결제 버튼에 표시되는 브랜드 마크(네이버페이·카카오페이·삼성페이 등의 색상 배지와 로고)를 표준화했습니다. 이전에는 결제 플러그인이 화면이 그려진 뒤 버튼 모양을 덧입히는 방식이라 여러 결제사가 함께 켜져 있을 때 드물게 표시가 겹치거나 어긋날 수 있었는데, 이제 결제수단 정보에 담긴 브랜드 마크를 주문서가 처음부터 직접 그리도록 바꿔 표시가 안정적입니다.
- 애플페이 간편결제 버튼이 iOS 기기(iPhone·iPad)에서만 주문서에 표시되도록 했습니다. 애플페이는 iOS에서만 결제할 수 있으므로 다른 기기에서는 버튼을 감춰 혼선을 줄입니다.
- 위 표시 개선을 위해 코어 최소 요구 버전을 7.0.5로 상향했습니다. 쇼핑몰 모듈을 업데이트하기 전에 코어를 7.0.5 이상으로 먼저 업데이트해 주세요.
## [1.0.3] - 2026-07-14
@@ -11,7 +11,7 @@
"ko": "그누보드7 이커머스 모듈 - 상품, 주문, 결제 관리",
"en": "Gnuboard7 Ecommerce Module - Product, Order, Payment Management"
},
"g7_version": ">=7.0.0",
"g7_version": ">=7.0.5",
"dependencies": {
"modules": {},
"plugins": {}
@@ -19,6 +19,7 @@ use Modules\Sirsoft\Ecommerce\Listeners\CouponUseListener;
use Modules\Sirsoft\Ecommerce\Listeners\EcommerceAdminActivityLogListener;
use Modules\Sirsoft\Ecommerce\Listeners\EcommerceNotificationDataListener;
use Modules\Sirsoft\Ecommerce\Listeners\EcommerceUserActivityLogListener;
use Modules\Sirsoft\Ecommerce\Listeners\InjectAppConfigDeviceListener;
use Modules\Sirsoft\Ecommerce\Listeners\MergeCartOnLoginListener;
use Modules\Sirsoft\Ecommerce\Listeners\MileageTransactionListener;
use Modules\Sirsoft\Ecommerce\Listeners\OrderActivityLogListener;
@@ -2007,6 +2008,7 @@ class Module extends AbstractModule
UserMileageCleanupListener::class,
EcommerceNotificationDataListener::class,
OrderStatusNotificationListener::class,
InjectAppConfigDeviceListener::class,
];
}
@@ -24,6 +24,13 @@ class DeviceDetector
*/
private const MOBILE_UA_KEYWORDS = ['Mobile', 'Android', 'iPhone', 'iPad', 'iPod'];
/**
* iOS User-Agent 키워드 (iPhone/iPad/iPod)
*
* @var array<int, string>
*/
private const IOS_UA_KEYWORDS = ['iPhone', 'iPad', 'iPod'];
/**
* Request 의 User-Agent 로 결제 디바이스 판별
*
@@ -51,4 +58,25 @@ class DeviceDetector
return 'pc';
}
/**
* User-Agent 문자열이 iOS 기기(iPhone/iPad/iPod)인지 판별
*
* 애플페이는 iOS 기기에서만 결제 가능하므로, 체크아웃 결제수단 목록에서
* 애플페이 노출 여부를 정하는 데 쓰인다. 데스크탑 UA 를 보내는 iPadOS 는
* 이 판정에서 false 가 될 수 있으며, 그 경우 클라이언트(maxTouchPoints)가 보정한다.
*
* @param string $userAgent User-Agent 헤더 값
* @return bool iOS 기기 여부
*/
public static function isIosFromUserAgent(string $userAgent): bool
{
foreach (self::IOS_UA_KEYWORDS as $keyword) {
if (stripos($userAgent, $keyword) !== false) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,61 @@
<?php
namespace Modules\Sirsoft\Ecommerce\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Modules\Sirsoft\Ecommerce\Helpers\DeviceDetector;
use Symfony\Component\HttpFoundation\Response;
/**
* 요청 User-Agent 로 iOS 기기 여부를 결정해 컨테이너에 보관하는 미들웨어.
*
* SetTimezone / ResolveShippingCountry 패턴(App::instance + static accessor)을 미러한다.
* web 그룹(SSR 셸 렌더 경로)에 적용되며, InjectAppConfigDeviceListener 가 코어의
* `core.frontend.filter_app_config` 필터 훅에서 이 값을 읽어 appConfig.isIos 로 주입한다.
* 프론트는 window.G7Config.appConfig → _global.appConfig.isIos 로 받는다.
*
* 서버 UA 판정은 데스크탑 UA 를 보내는 iPadOS 를 놓칠 수 있으므로, 템플릿 부트스트랩이
* 클라이언트 신호(maxTouchPoints/userAgentData)로 이를 보정한다.
*/
class DetectDevice
{
/**
* 애플리케이션 컨테이너에 저장되는 iOS 여부 키
*/
public const IS_IOS_KEY = 'ecommerce_request_is_ios';
/**
* 들어오는 요청의 iOS 여부를 판별해 컨테이너에 보관합니다.
*
* @param Request $request HTTP 요청
* @param Closure $next 다음 미들웨어 또는 요청 핸들러
* @return Response HTTP 응답
*/
public function handle(Request $request, Closure $next): Response
{
App::instance(
self::IS_IOS_KEY,
DeviceDetector::isIosFromUserAgent($request->userAgent() ?? '')
);
return $next($request);
}
/**
* 현재 요청이 iOS 기기인지 반환합니다.
*
* 미들웨어가 실행되지 않은 컨텍스트에서는 false(애플페이 기본 숨김 — fail-safe)를 반환합니다.
*
* @return bool iOS 기기 여부
*/
public static function isIos(): bool
{
if (App::bound(self::IS_IOS_KEY)) {
return (bool) App::make(self::IS_IOS_KEY);
}
return false;
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace Modules\Sirsoft\Ecommerce\Listeners;
use App\Contracts\Extension\HookListenerInterface;
use Modules\Sirsoft\Ecommerce\Http\Middleware\DetectDevice;
/**
* 요청 기기 유형(iOS 여부)을 프론트엔드 appConfig 에 주입하는 리스너.
*
* 코어 `core.frontend.filter_app_config` 필터 훅을 구독해, DetectDevice 미들웨어가
* 컨테이너에 보관한 iOS 판정값을 `appConfig.isIos` 로 주입한다. 프론트는
* window.G7Config.appConfig → _global.appConfig.isIos 로 받아 체크아웃 레이아웃의
* 애플페이 iOS 게이팅에 활용한다.
*
* 코어는 config/frontend.php 정적 값만 노출하므로, 요청별로 달라지는 값(기기 유형)은
* 이 훅을 통해 이커머스 모듈이 채운다.
*/
class InjectAppConfigDeviceListener implements HookListenerInterface
{
/**
* 구독할 훅 목록 반환
*
* @return array<string, array<string, mixed>>
*/
public static function getSubscribedHooks(): array
{
return [
'core.frontend.filter_app_config' => [
'method' => 'injectDeviceFlags',
'priority' => 20,
'type' => 'filter',
],
];
}
/**
* 기본 핸들러 (미사용).
*
* @param mixed ...$args
*/
public function handle(...$args): void {}
/**
* appConfig 에 요청 기기 iOS 여부를 주입합니다.
*
* @param array<string, mixed> $appConfig 코어가 조립한 프론트엔드 appConfig
* @return array<string, mixed> isIos 가 추가된 appConfig
*/
public function injectDeviceFlags(array $appConfig): array
{
$appConfig['isIos'] = DetectDevice::isIos();
return $appConfig;
}
}
@@ -4,6 +4,8 @@ namespace Modules\Sirsoft\Ecommerce\Providers;
use App\Extension\BaseModuleServiceProvider;
use App\Seo\SitemapGenerator;
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Modules\Sirsoft\Ecommerce\Console\Commands\AggregateEcommerceStatsCommand;
use Modules\Sirsoft\Ecommerce\Console\Commands\CancelPendingPaymentOrdersCommand;
use Modules\Sirsoft\Ecommerce\Console\Commands\EarnMileageCommand;
@@ -11,6 +13,7 @@ use Modules\Sirsoft\Ecommerce\Console\Commands\ExpireMileageCommand;
use Modules\Sirsoft\Ecommerce\Console\Commands\NotifyExpiringMileageCommand;
use Modules\Sirsoft\Ecommerce\Console\Commands\PruneExpiredCartsCommand;
use Modules\Sirsoft\Ecommerce\Console\Commands\ReconcileMileageBalanceCommand;
use Modules\Sirsoft\Ecommerce\Http\Middleware\DetectDevice;
use Modules\Sirsoft\Ecommerce\Repositories\BrandRepository;
use Modules\Sirsoft\Ecommerce\Repositories\CartRepository;
use Modules\Sirsoft\Ecommerce\Repositories\CategoryImageRepository;
@@ -210,6 +213,20 @@ class EcommerceServiceProvider extends BaseModuleServiceProvider
$this->commands($this->commands);
}
// 요청 기기 유형(iOS) 감지 미들웨어를 web 그룹(SSR 셸 렌더 경로)에 등록.
// InjectAppConfigDeviceListener 가 core.frontend.filter_app_config 훅에서 이 값을 읽어
// appConfig.isIos 로 주입한다(체크아웃 애플페이 iOS 게이팅). DB/인증 비의존 순수 UA 판정이라
// 마이그레이션 이전에도 안전하다.
//
// Router::pushMiddlewareToGroup 은 Router 자체 레지스트리만 갱신해 실제 요청 파이프라인이
// 참조하는 HTTP Kernel 의 web 그룹에는 반영되지 않는다(미들웨어 미실행 → isIos 항상 false).
// sirsoft-gdpr 선례와 동일하게 HTTP Kernel::appendMiddlewareToGroup 을 사용한다
// (Kernel 은 중복 등록을 자체 방지하므로 매 부팅 호출돼도 1회만 등록).
$kernel = $this->app->make(HttpKernelContract::class);
if ($kernel instanceof HttpKernel) {
$kernel->appendMiddlewareToGroup('web', DetectDevice::class);
}
// Sitemap 기여자 등록
$this->app->booted(function () {
if ($this->app->bound(SitemapGenerator::class)) {
@@ -796,6 +796,12 @@ class EcommerceSettingsService implements ModuleSettingsInterface
'refund_method' => $refundMethod,
];
// iOS 전용 노출 플래그(애플페이 등) — 정의가 SSoT. 관리자가 편집하는 값이 아니며,
// 체크아웃 레이아웃이 비-iOS 기기에서 해당 수단을 렌더하지 않는 데 쓰인다.
if (! empty($definition['requires_ios'])) {
$capabilities['requires_ios'] = true;
}
if ($savedItem) {
$merged[] = array_merge([
'id' => $id,
@@ -810,6 +816,7 @@ class EcommerceSettingsService implements ModuleSettingsInterface
'_cached_name' => $definition['name'],
'_cached_description' => $definition['description'] ?? ['ko' => '', 'en' => ''],
'_cached_icon' => $definition['icon'] ?? 'circle-question',
'_cached_brand_mark' => $definition['brand_mark'] ?? null,
'_cached_source' => $definition['source'] ?? 'builtin',
], $capabilities);
} else {
@@ -825,6 +832,7 @@ class EcommerceSettingsService implements ModuleSettingsInterface
'_cached_name' => $definition['name'],
'_cached_description' => $definition['description'] ?? ['ko' => '', 'en' => ''],
'_cached_icon' => $definition['icon'] ?? 'circle-question',
'_cached_brand_mark' => $definition['brand_mark'] ?? null,
'_cached_source' => $definition['source'] ?? 'builtin',
], $capabilities);
}
@@ -874,6 +882,7 @@ class EcommerceSettingsService implements ModuleSettingsInterface
$savedMethods[$index]['_cached_name'] = $def['name'] ?? $method['_cached_name'] ?? null;
$savedMethods[$index]['_cached_description'] = $def['description'] ?? $method['_cached_description'] ?? null;
$savedMethods[$index]['_cached_icon'] = $def['icon'] ?? $method['_cached_icon'] ?? null;
$savedMethods[$index]['_cached_brand_mark'] = $def['brand_mark'] ?? $method['_cached_brand_mark'] ?? null;
$savedMethods[$index]['_cached_source'] = $def['source'] ?? $method['_cached_source'] ?? 'builtin';
}
// 고아 항목은 기존 _cached_* 유지
@@ -0,0 +1,76 @@
/**
* 체크아웃 간편결제 브랜드 마크 데이터 기반 렌더 + 애플페이 iOS 게이팅.
*
* 3사(kginicis/nhnkcp/nicepayments) 동시 활성 체크아웃에서, 각 간편결제 버튼의 브랜드 마크
* (색 배지 / 브랜드 SVG 로고)가 카탈로그 _cached_brand_mark 데이터로 렌더되고(injector 후처리
* 없이), 애플페이는 iOS 기기에서만 노출되는지 검증. 템플릿 sirsoft-basic (유저 화면).
* (skeleton, placeholder)
*
* @effects badge_renders_text_and_color,
* svg_renders_inline_logo,
* svg_dangerous_content_sanitized,
* none_form_falls_back_to_icon,
* applepay_shown_on_ios,
* applepay_hidden_on_non_ios,
* non_ios_methods_unaffected,
* injectors_removed
*
* e2e:allow 브랜드 마크 렌더/게이팅 — 카탈로그→레이아웃 계약을 단위/렌더/리소스 테스트로 1차 차단하고,
* 브라우저 회귀는 본 placeholder(test.describe.skip)가 data-testid 보강 + 3-PG 동시활성 시드 후 활성화될 때 검증한다.
* 현재 커버리지:
* (1) 카탈로그 보강 — modules/_bundled/sirsoft-ecommerce/tests/Unit/Services/EcommerceSettingsOrderSettingsTest.php
* (brand_mark→_cached_brand_mark 병합, requires_ios 전달, 마크 없는 builtin=null) green.
* (2) 등록 리스너 — plugins/_bundled/sirsoft-pay_{nhnkcp,nicepayments,kginicis}/tests/Unit/Listeners/RegisterEasyPayMethodsListenerTest.php
* (배지 9종 text/class, SVG 6종 markup, 애플페이만 requires_ios) green.
* (3) BrandMark 컴포넌트 — templates/_bundled/sirsoft-basic/src/components/composite/__tests__/BrandMark.test.tsx
* (배지/SVG 렌더, SVG script/onload/foreignObject sanitize 제거, 마크 없음→null) green.
* (4) 레이아웃 렌더 + iOS 필터 — templates/_bundled/sirsoft-basic/__tests__/layouts/checkout-payment-brand-mark.test.tsx
* (BrandMark 노드 바인딩 + Icon 폴백, iteration source 필터가 iOS↔비iOS 로 애플페이 포함/제외) green.
* (5) 서버/클라 iOS 게이팅 — tests/Unit/Helpers/DeviceDetectorTest.php + tests/Unit/Middleware/DetectDeviceTest.php
* + tests/Unit/Services/SettingsServiceAppConfigTest.php + templates/_bundled/sirsoft-basic/src/handlers/__tests__/deviceCorrection.test.ts
* (UA→appConfig.isIos, iPadOS 데스크탑 UA 클라 보정) green.
* 라이브 검수는 Chrome MCP 실측(3사 브랜드 버튼 공존 + 마크 표시, iOS 에뮬레이션 애플페이 노출/숨김, 스크린샷)으로 기록 예정.
*/
// @scenario mark_form=svg, requires_ios=false, device=ios
// @scenario mark_form=svg, requires_ios=false, device=non_ios
// @scenario mark_form=none, requires_ios=false, device=non_ios
// @scenario mark_form=badge, requires_ios=false, device=non_ios
import { test, expect, authenticatePage } from '../../fixtures/ecommerce-auth';
test.describe.skip('체크아웃 간편결제 브랜드 마크 + 애플페이 iOS 게이팅 (skeleton)', () => {
test('3사 간편결제 버튼이 브랜드 마크(배지/SVG)로 렌더된다', async ({ page, userToken }) => {
await authenticatePage(page, userToken);
await page.goto('/shop/checkout');
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
// 활성화 시: 배지 형태(nhnkcp 네이버페이 'N')와 SVG 형태(kginicis 네이버페이 로고)가 함께 렌더
await expect(page.getByTestId('payment-method-nhnkcp_naverpay').getByText('N')).toBeVisible();
await expect(page.getByTestId('payment-method-kginicis_naverpay').locator('svg')).toBeVisible();
// 마크 없는 무통장은 아이콘 폴백
await expect(page.getByTestId('payment-method-dbank').locator('i')).toBeVisible();
});
test('비-iOS 기기에서 애플페이 버튼이 노출되지 않는다', async ({ page, userToken }) => {
await authenticatePage(page, userToken);
await page.goto('/shop/checkout');
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
// 활성화 시: 데스크탑(비-iOS)에서는 애플페이 수단 카드가 렌더되지 않음
await expect(page.getByTestId('payment-method-nhnkcp_applepay')).toHaveCount(0);
// 비-애플페이 수단은 정상 노출
await expect(page.getByTestId('payment-method-nhnkcp_naverpay')).toBeVisible();
});
test('iOS 기기 에뮬레이션에서 애플페이 버튼이 노출된다', async ({ browser }) => {
// 활성화 시: iPhone UA 컨텍스트에서 애플페이 수단 카드가 렌더됨(서버 UA 게이팅)
const context = await browser.newContext({
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15',
});
const page = await context.newPage();
await page.goto('/shop/checkout');
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
await expect(page.getByTestId('payment-method-nhnkcp_applepay')).toBeVisible();
await context.close();
});
});
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace Modules\Sirsoft\Ecommerce\Tests\Unit\Helpers;
use Modules\Sirsoft\Ecommerce\Helpers\DeviceDetector;
use Modules\Sirsoft\Ecommerce\Tests\ModuleTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class DeviceDetectorTest extends ModuleTestCase
{
#[DataProvider('deviceTypeProvider')]
public function test_detect_from_user_agent(string $userAgent, string $expected): void
{
$this->assertSame($expected, DeviceDetector::detectFromUserAgent($userAgent));
}
/**
* @return array<string, array{0: string, 1: string}>
*/
public static function deviceTypeProvider(): array
{
return [
'iPhone' => ['Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)', 'mobile'],
'iPad' => ['Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X)', 'mobile'],
'Android' => ['Mozilla/5.0 (Linux; Android 14; Pixel 8)', 'mobile'],
'desktop Chrome' => ['Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120', 'pc'],
'macOS Safari' => ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/17', 'pc'],
'empty' => ['', 'pc'],
];
}
/**
* @scenario mark_form=badge, requires_ios=true, device=ios
*
* @effects server_ua_sets_is_ios, applepay_shown_on_ios
*/
#[DataProvider('iosProvider')]
public function test_is_ios_from_user_agent(string $userAgent, bool $expected): void
{
$this->assertSame($expected, DeviceDetector::isIosFromUserAgent($userAgent));
}
/**
* @return array<string, array{0: string, 1: bool}>
*/
public static function iosProvider(): array
{
return [
'iPhone' => ['Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)', true],
'iPad' => ['Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X)', true],
'iPod' => ['Mozilla/5.0 (iPod touch; CPU iPhone OS 15_0 like Mac OS X)', true],
// Android 모바일은 iOS 가 아님(애플페이 미노출).
'Android' => ['Mozilla/5.0 (Linux; Android 14; Pixel 8)', false],
// 데스크탑 UA 를 보내는 iPadOS 는 서버 UA 판정으로 놓친다(클라 보정 대상).
'macOS desktop UA' => ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/17', false],
'Windows' => ['Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120', false],
'empty' => ['', false],
];
}
}
@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
namespace Modules\Sirsoft\Ecommerce\Tests\Unit\Middleware;
use App\Extension\HookManager;
use App\Services\SettingsService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Sirsoft\Ecommerce\Http\Middleware\DetectDevice;
use Modules\Sirsoft\Ecommerce\Listeners\InjectAppConfigDeviceListener;
use Modules\Sirsoft\Ecommerce\Tests\ModuleTestCase;
class DetectDeviceTest extends ModuleTestCase
{
/**
* @scenario mark_form=badge, requires_ios=true, device=ios
*
* @effects server_ua_sets_is_ios, applepay_shown_on_ios
*/
public function test_ios_user_agent_sets_is_ios_true_in_container(): void
{
$request = Request::create('/', 'GET', server: [
'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)',
]);
(new DetectDevice)->handle($request, fn () => new Response);
$this->assertTrue(DetectDevice::isIos());
}
/**
* @scenario mark_form=badge, requires_ios=true, device=non_ios
*
* @effects server_ua_sets_is_ios, applepay_hidden_on_non_ios
*/
public function test_desktop_user_agent_sets_is_ios_false_in_container(): void
{
$request = Request::create('/', 'GET', server: [
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120',
]);
(new DetectDevice)->handle($request, fn () => new Response);
$this->assertFalse(DetectDevice::isIos());
}
public function test_is_ios_defaults_false_when_middleware_not_run(): void
{
// 컨테이너 미바인딩(미들웨어 미실행) 시 fail-safe(애플페이 기본 숨김).
$this->assertFalse(DetectDevice::isIos());
}
/**
* @scenario mark_form=badge, requires_ios=true, device=ipados_desktop_ua
*
* @effects is_ios_flows_to_global_appconfig
*/
public function test_listener_injects_is_ios_into_app_config_via_hook(): void
{
// iOS 미들웨어 통과 상태 재현.
$request = Request::create('/', 'GET', server: [
'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)',
]);
(new DetectDevice)->handle($request, fn () => new Response);
// 리스너를 훅에 등록(모듈 부팅이 하는 것과 동일).
HookManager::addFilter(
'core.frontend.filter_app_config',
[new InjectAppConfigDeviceListener, 'injectDeviceFlags'],
20
);
$appConfig = app(SettingsService::class)->getAppConfigForFrontend();
$this->assertArrayHasKey('isIos', $appConfig);
$this->assertTrue($appConfig['isIos']);
}
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Modules\Sirsoft\Ecommerce\Tests\Unit\Providers;
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Modules\Sirsoft\Ecommerce\Http\Middleware\DetectDevice;
use Modules\Sirsoft\Ecommerce\Tests\ModuleTestCase;
/**
* DetectDevice 미들웨어가 실제 요청 파이프라인의 web 그룹에 등록되는지 검증.
*
* 회귀: EcommerceServiceProvider 가 Router::pushMiddlewareToGroup('web', ...) 로 등록하면
* HTTP Kernel 이 참조하는 web 그룹에 반영되지 않아(Router 자체 레지스트리만 갱신) SSR 셸
* 요청에서 미들웨어가 실행되지 않는다. 그 결과 appConfig.isIos 가 항상 fail-safe false 가 되어
* 애플페이 iOS 게이팅 서버층이 동작하지 않는다. Kernel::appendMiddlewareToGroup 을 써야 한다.
*/
class DetectDeviceMiddlewareRegistrationTest extends ModuleTestCase
{
/**
* @scenario mark_form=badge, requires_ios=true, device=non_ios
*
* @effects server_ua_sets_is_ios
*/
public function test_detect_device_is_registered_in_kernel_web_group(): void
{
$kernel = $this->app->make(HttpKernelContract::class);
$this->assertInstanceOf(HttpKernel::class, $kernel);
// HTTP Kernel 이 실제 요청 처리 시 참조하는 web 그룹을 조회한다.
$webGroup = $kernel->getMiddlewareGroups()['web'] ?? [];
$this->assertContains(
DetectDevice::class,
$webGroup,
'DetectDevice 미들웨어가 HTTP Kernel 의 web 그룹에 등록되어야 SSR 셸 요청에서 실행된다.'
);
}
}
@@ -257,6 +257,55 @@ class EcommerceSettingsOrderSettingsTest extends TestCase
$this->assertFalse($toss['is_active']); // 기본값: 비활성
}
/**
* @scenario mark_form=svg, requires_ios=false, device=non_ios
*
* @effects brand_mark_flows_to_cached, requires_ios_flag_carried, none_form_cached_brand_mark_null
*/
public function test_brand_mark_and_requires_ios_flow_from_definition_to_merged_catalog(): void
{
// 플러그인이 brand_mark(배지/SVG) + requires_ios 를 등록하면
// 병합 카탈로그가 _cached_brand_mark / requires_ios 로 노출해 레이아웃까지 전달한다.
$this->addPaymentMethodFilter(function (array $methods) {
$methods[] = [
'id' => 'pgtest_badge',
'name' => ['ko' => '배지결제', 'en' => 'Badge Pay'],
'description' => ['ko' => '배지 결제', 'en' => 'Badge Payment'],
'icon' => 'wallet',
'source' => 'plugin:sirsoft-pgtest',
'brand_mark' => ['text' => 'B', 'class' => 'bg-green-500 text-white'],
'defaults' => ['is_active' => true, 'min_order_amount' => 0, 'stock_deduction_timing' => 'payment_complete'],
];
$methods[] = [
'id' => 'pgtest_svg_ios',
'name' => ['ko' => 'SVG결제', 'en' => 'SVG Pay'],
'description' => ['ko' => 'SVG 결제', 'en' => 'SVG Payment'],
'icon' => 'smartphone',
'source' => 'plugin:sirsoft-pgtest',
'brand_mark' => ['svg' => '<svg><rect fill="#03C75A"/></svg>'],
'requires_ios' => true,
'defaults' => ['is_active' => true, 'min_order_amount' => 0, 'stock_deduction_timing' => 'payment_complete'],
];
return $methods;
});
$this->service->clearCache();
$methods = collect($this->service->getSettings('order_settings')['payment_methods'])->keyBy('id');
$badge = $methods->get('pgtest_badge');
$this->assertSame(['text' => 'B', 'class' => 'bg-green-500 text-white'], $badge['_cached_brand_mark']);
$this->assertArrayNotHasKey('requires_ios', $badge);
$svg = $methods->get('pgtest_svg_ios');
$this->assertSame(['svg' => '<svg><rect fill="#03C75A"/></svg>'], $svg['_cached_brand_mark']);
$this->assertTrue($svg['requires_ios']);
// brand_mark 없는 builtin 은 _cached_brand_mark 가 null.
$dbank = $methods->get('dbank');
$this->assertNull($dbank['_cached_brand_mark']);
}
// ──────────────────────────────────────────────
// 결제수단 병합 (사용자 저장 설정 오버라이드)
// ──────────────────────────────────────────────
@@ -0,0 +1,76 @@
feature: checkout_brand_mark_rendering
description: >
체크아웃 간편결제 버튼의 브랜드 시각정보(색 배지 / 브랜드 SVG 로고)를 결제수단 카탈로그
(`_cached_brand_mark`)로 편입해, 코어 체크아웃 레이아웃의 BrandMark 컴포넌트가 데이터 기반
으로 직접 렌더한다. 과거에는 각 PG 플러그인의 체크아웃 DOM 인젝터(checkoutEasyPayInjector /
checkoutNaverpayBrandButton)가 렌더 후 DOM 을 후처리해 마크를 주입했고, injector 끼리 같은
버튼을 두고 경합하며 reconcileKginicisPatchedDuplicates 로 중복을 방어했다. 시각정보를
카탈로그로 옮기면서 세 injector + reconcile 을 제거했다.
애플페이 iOS 게이팅도 injector 밖으로 이관했다: 이커머스 모듈의 DetectDevice 미들웨어가
UA 로 기기를 감지해 컨테이너에 보관하고, InjectAppConfigDeviceListener 가 코어
`core.frontend.filter_app_config` 훅에서 이를 appConfig.isIos 로 주입해 내려준다(1차).
템플릿 부트스트랩이 iPadOS(데스크탑 UA)를 클라 신호(maxTouchPoints)로 보정한다(2차).
체크아웃 레이아웃 iteration source 필터가 requires_ios 수단을 _global.appConfig.isIos 에 따라
포함/제외한다. (미들웨어·감지 로직은 코어가 아닌 이커머스 모듈 소유 — 코어는 appConfig 필터 훅만 제공.)
test_files:
- modules/_bundled/sirsoft-ecommerce/tests/Unit/Services/EcommerceSettingsOrderSettingsTest.php
- modules/_bundled/sirsoft-ecommerce/tests/Unit/Helpers/DeviceDetectorTest.php
- modules/_bundled/sirsoft-ecommerce/tests/Unit/Middleware/DetectDeviceTest.php
- modules/_bundled/sirsoft-ecommerce/tests/Unit/Providers/DetectDeviceMiddlewareRegistrationTest.php
- tests/Unit/Services/SettingsServiceAppConfigTest.php
- plugins/_bundled/sirsoft-pay_nhnkcp/tests/Unit/Listeners/RegisterEasyPayMethodsListenerTest.php
- plugins/_bundled/sirsoft-pay_nicepayments/tests/Unit/Listeners/RegisterEasyPayMethodsListenerTest.php
- plugins/_bundled/sirsoft-pay_kginicis/tests/Unit/Listeners/RegisterEasyPayMethodsListenerTest.php
- templates/_bundled/sirsoft-basic/src/components/composite/__tests__/BrandMark.test.tsx
- templates/_bundled/sirsoft-basic/src/handlers/__tests__/deviceCorrection.test.ts
- templates/_bundled/sirsoft-basic/__tests__/layouts/checkout-payment-brand-mark.test.tsx
- modules/_bundled/sirsoft-ecommerce/tests/Playwright/specs/shop/checkout-brand-mark.spec.ts
# 입력 axis — 브랜드 마크 렌더 + iOS 게이팅에 영향을 주는 변수
axes:
# 브랜드 마크 형태: 배지(nhnkcp/nicepay) / SVG 로고(kginicis) / 없음(무통장·카드 등 builtin)
mark_form: [badge, svg, none]
# iOS 전용 노출 수단 여부 (애플페이만 true)
requires_ios: [true, false]
# 요청 기기 (서버 UA 판정 + 클라 보정 결과)
device: [ios, non_ios, ipados_desktop_ua]
exclusions:
- mark_form: none
requires_ios: true
reason: "브랜드 마크 없는 builtin(무통장/카드/가상계좌)에는 iOS 전용 수단이 없다"
- mark_form: svg
requires_ios: true
reason: "SVG 마크(kginicis)에는 애플페이 수단이 없다 — kginicis 는 애플페이 미제공"
# 후속 효과 체인 — 시각정보 이관 + injector 제거가 낳는 관찰 가능 효과
effects:
# 카탈로그 → 레이아웃 데이터 전달
- brand_mark_flows_to_cached # brand_mark 등록값이 _cached_brand_mark 로 병합 카탈로그에 노출
- requires_ios_flag_carried # requires_ios 가 method 최상위로 노출(레이아웃 접근 가능)
- none_form_cached_brand_mark_null # 마크 없는 수단은 _cached_brand_mark=null (아이콘 폴백)
# 렌더 (BrandMark 컴포넌트)
- badge_renders_text_and_color # 배지 형태는 text + Tailwind 색상 클래스로 렌더
- svg_renders_inline_logo # SVG 형태는 인라인 SVG 로고로 렌더
- svg_dangerous_content_sanitized # SVG 내부 script/onload/foreignObject 는 sanitize 제거(XSS 방어)
- none_form_falls_back_to_icon # 마크 없는 수단은 Icon 폴백 렌더
# iOS 게이팅
- server_ua_sets_is_ios # DetectDevice 미들웨어가 UA 로 appConfig.isIos 설정
- is_ios_flows_to_global_appconfig # appConfig.isIos 가 _global.appConfig 로 전달
- client_corrects_ipados_desktop_ua # 부트스트랩이 iPadOS 데스크탑 UA 를 클라 신호로 보정
- applepay_shown_on_ios # iOS 기기에서 애플페이 버튼 노출
- applepay_hidden_on_non_ios # 비-iOS 기기에서 애플페이 버튼 미노출(iteration 필터 제외)
- non_ios_methods_unaffected # iOS 게이팅이 비-애플페이 수단 노출에 영향 없음
# injector 제거 (기술부채 상환)
- injectors_removed # 세 injector + reconcile + install 호출 제거
- shared_helpers_preserved # applePayDevice(결제 시점 방어) / JPY restrictor / admin injector 잔존
sub_flows:
- id: three_pg_coexist
description: 3사(kginicis/nhnkcp/nicepayments) 동시 활성 체크아웃에서 브랜드 버튼 공존
effects:
- badge_renders_text_and_color
- svg_renders_inline_logo
- none_form_falls_back_to_icon