Files
Gnuboard7/plugins/_bundled/sirsoft-tosspayments/plugin.php
T
HeuJung 26a349590e feat(plugins): 토스페이먼츠 번들 플러그인 복원
7.0.0 정식 출시 커밋에서 PG 3종이 함께 제거되었으나, 그중 토스페이먼츠만
번들로 되돌린다. 삭제 직전 트리를 기준으로 플러그인 40개 파일과 일본어
언어팩 6개 파일을 복원하고, 삭제에 연동되어 변경되었던 README 목록·언어팩
빌드 스크립트 엔트리·이커머스 편집기 샘플의 PG provider 를 함께 되살렸다.

복원된 코드는 삭제 시점에 멈춰 있어 현행 코드베이스와 어긋나는 지점이 있어
함께 정합화했다.

- PluginTestCase 가 활성 디렉토리 경로를 참조해 _bundled 단독 실행 시
 라우트가 등록되지 않던 문제를 자기 기준 경로로 교체
- SettingsServiceProvider 의 site_url override 로 app.url 이 오염되어
 assertRedirect 가 간헐 실패하던 문제를 APP_URL 명시 리셋으로 차단
- 환경설정 레이아웃의 시맨틱 클래스가 한 칸씩 밀려 순환 배치되어 2열 폼이
 무너지고 섹션 제목이 에러 색으로 표시되던 결함을 정정 (회귀 테스트 신설)
- 편집기 저장 시 silent drop 되던 미표준 root 키 제거, Icon 을 size prop 으로 전환
2026-08-06 11:29:47 +09:00

160 lines
5.5 KiB
PHP

<?php
namespace Plugins\Sirsoft\Tosspayments;
use App\Extension\AbstractPlugin;
/**
* 토스페이먼츠 PG 플러그인
*
* 토스페이먼츠 통합결제창(카드/간편결제) 연동을 제공합니다.
* sirsoft-ecommerce 모듈 전용 플러그인입니다.
*/
class Plugin extends AbstractPlugin
{
/**
* 플러그인 메타데이터 반환
*
* @return array 메타데이터
*/
public function getMetadata(): array
{
return [
'author' => 'Sirsoft',
'license' => 'MIT',
'homepage' => 'https://sir.kr',
'keywords' => ['payment', 'tosspayments', 'pg', 'card', 'ecommerce'],
];
}
/**
* 환경설정 스키마 반환
*
* @return array 설정 스키마
*/
public function getSettingsSchema(): array
{
return [
'is_test_mode' => [
'type' => 'boolean',
'default' => true,
'label' => ['ko' => '테스트 모드', 'en' => 'Test Mode'],
'hint' => [
'ko' => '테스트 모드에서는 실제 결제가 발생하지 않습니다.',
'en' => 'No real payments occur in test mode.',
],
],
'test_client_key' => [
'type' => 'string',
'default' => '',
'label' => ['ko' => '테스트 클라이언트 키', 'en' => 'Test Client Key'],
'hint' => [
'ko' => '개발자센터 > API 개별 연동 키에서 확인',
'en' => 'Found in Developer Center > API Keys',
],
],
'test_secret_key' => [
'type' => 'string',
'default' => '',
'sensitive' => true,
'label' => ['ko' => '테스트 시크릿 키', 'en' => 'Test Secret Key'],
'hint' => [
'ko' => '외부에 노출되지 않도록 주의하세요.',
'en' => 'Keep this key secret.',
],
],
'live_client_key' => [
'type' => 'string',
'default' => '',
'label' => ['ko' => '라이브 클라이언트 키', 'en' => 'Live Client Key'],
],
'live_secret_key' => [
'type' => 'string',
'default' => '',
'sensitive' => true,
'label' => ['ko' => '라이브 시크릿 키', 'en' => 'Live Secret Key'],
'hint' => [
'ko' => '외부에 노출되지 않도록 주의하세요.',
'en' => 'Keep this key secret.',
],
],
'redirect_success_url' => [
'type' => 'string',
'default' => '/shop/orders/{orderId}/complete',
'label' => ['ko' => '결제 성공 리다이렉트 URL', 'en' => 'Payment Success Redirect URL'],
'hint' => [
'ko' => '상대 경로(/shop/...) 또는 전체 URL(https://...) 모두 가능합니다. {orderId}는 주문번호로 자동 치환됩니다.',
'en' => 'Supports relative paths (/shop/...) or full URLs (https://...). {orderId} will be replaced with the actual order number.',
],
],
'redirect_fail_url' => [
'type' => 'string',
'default' => '/shop/checkout',
'label' => ['ko' => '결제 실패 리다이렉트 URL', 'en' => 'Payment Failure Redirect URL'],
'hint' => [
'ko' => '상대 경로 또는 전체 URL 모두 가능합니다. 오류 정보는 쿼리 파라미터로 자동 추가됩니다.',
'en' => 'Supports relative paths or full URLs. Error details are appended as query parameters.',
],
],
];
}
/**
* 기본 설정값 반환
*
* @return array 기본 설정값
*/
public function getConfigValues(): array
{
return [
'is_test_mode' => true,
'test_client_key' => '',
'test_secret_key' => '',
'live_client_key' => '',
'live_secret_key' => '',
'redirect_success_url' => '/shop/orders/{orderId}/complete',
'redirect_fail_url' => '/shop/checkout',
];
}
/**
* 훅 리스너 클래스 반환
*
* @return array 리스너 클래스 목록
*/
public function getHookListeners(): array
{
return [
Listeners\RegisterPgProviderListener::class,
Listeners\PaymentRefundListener::class,
];
}
/**
* 훅 정의 반환
*
* @return array 훅 정의
*/
public function getHooks(): array
{
return [
[
'name' => 'sirsoft-tosspayments.payment.before_confirm',
'type' => 'action',
'description' => [
'ko' => '토스페이먼츠 결제 승인 API 호출 전',
'en' => 'Before TossPayments confirm API call',
],
],
[
'name' => 'sirsoft-tosspayments.payment.after_confirm',
'type' => 'action',
'description' => [
'ko' => '토스페이먼츠 결제 승인 완료 후',
'en' => 'After TossPayments confirm API completed',
],
],
];
}
}