From a4c456f5d93977c755540da3d4ca9e76efc7abf6 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 24 Jun 2026 12:12:57 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20EC-CUBE=204.4=20(Symfony=207.4=20/?= =?UTF-8?q?=20Doctrine=20ORM=203.0=20/=20PHP=208.2)=20=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - docker-compose.yml の image を 8.2-apache-4.4 へ更新 - rector / php-cs-fixer / phpstan 設定を Resource/ 配下に配置 - アノテーション → アトリビュート変換 (@Route, @ORM\Column, @EntityExtension 等) - constructor promotion (DI bind 引数名 $shoppingPurchaseFlow は保持) - Entity trait のゲッターを nullable 化 (PHP 8.2 厳格戻り型対応) - PaymentMethodInterface の戻り型変更に追従 (verify() 成功時は false) - buildForm()/enable()/getSubscribedEvents() 等に戻り型を追加 - E2E テストをカート AJAX 化に追従 - package-lock.json を削除し yarn.lock へ統一 Co-Authored-By: Claude --- .gitignore | 5 +- CLAUDE.md | 122 +++++++++++++++++++ Controller/Admin/ConfigController.php | 18 +-- Controller/Admin/OrderController.php | 13 +- Controller/Admin/PaymentStatusController.php | 52 +++----- Controller/MypageController.php | 20 ++- Controller/PaymentCompanyController.php | 9 +- Controller/PaymentController.php | 87 +++---------- Entity/Config.php | 45 ++++--- Entity/CustomerTrait.php | 12 +- Entity/CvsPaymentStatus.php | 16 +-- Entity/CvsType.php | 12 +- Entity/OrderTrait.php | 73 +++++------ Entity/PaymentStatus.php | 16 +-- Form/Extension/CreditCardExtention.php | 11 +- Form/Extension/CvsExtension.php | 26 +--- Form/Type/Admin/ConfigType.php | 4 +- Form/Type/Admin/SearchPaymentType.php | 8 +- PluginManager.php | 5 +- Resource/.php-cs-fixer.dist.php | 55 +++++++++ Resource/rector.php | 64 ++++++++++ SamplePaymentEvent.php | 2 +- SamplePaymentNav.php | 2 +- SamplePaymentTwigBlock.php | 6 +- Service/Method/Convenience.php | 62 ++++------ Service/Method/CreditCard.php | 71 +++++------ Service/Method/LinkCreditCard.php | 52 +++----- docker-compose.yml | 2 +- package-lock.json | 75 ------------ phpstan.neon.dist | 26 ++++ tests/guest_convini.test.ts | 7 +- tests/guest_credit_link.test.ts | 6 +- tests/guest_credit_token.test.ts | 6 +- yarn.lock | 29 +++++ 34 files changed, 531 insertions(+), 488 deletions(-) create mode 100644 CLAUDE.md create mode 100644 Resource/.php-cs-fixer.dist.php create mode 100644 Resource/rector.php delete mode 100644 package-lock.json create mode 100644 phpstan.neon.dist create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index 597b993..438d3e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ composer.phar /vendor/ +.php-cs-fixer.cache # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock +# 本プラグインはライブラリ (type: eccube-plugin) のため composer.lock はコミットしない +composer.lock node_modules/ /test-results/ /playwright-report/ @@ -11,3 +13,4 @@ node_modules/ /test-results/ /playwright-report/ /playwright/.cache/ +package-lock.json diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..7d45420 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,122 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## このリポジトリについて + +EC-CUBE 4 系の**決済プラグイン実装サンプル**。実際の決済代行会社向けプラグインを実装する開発者の参考実装として、3 種類の決済方式を 1 プラグインに収めている。 + +- **リンク型クレジットカード決済** (`LinkCreditCard`) — 外部決済サーバの入力画面へリダイレクトする方式 +- **トークン型クレジットカード決済** (`CreditCard`) — トークンを受け取り自サイト内で完結する方式 +- **コンビニ決済** (`Convenience`) — 入金待ちステータスを持つ方式 + +プラグインコードは `SamplePayment42`、Composer パッケージ名は `ec-cube/samplepayment42`。コード中の Twig 名前空間・クラス名前空間・トランス キーはすべて `SamplePayment42` 接頭辞を使う。 + +### ブランチ運用 + +ブランチ名が対応する EC-CUBE 本体バージョンを表す (`4.2`, `support-4.3`, `4.4` など)。`4.2` がデフォルトブランチ。本体 API の差異に応じて各バージョン用ブランチを保守している。各バージョンで動作する Docker イメージは `docker-compose.yml` の `image:` タグ (例 `ghcr.io/ec-cube/ec-cube-php:7.4-apache-4.2`) で固定されている。 + +## 開発・テストコマンド + +このプラグイン単体では動作せず、**EC-CUBE 本体に組み込んだ状態**で開発・テストする。本体への組み込みと有効化は `docker-compose.dev.yml` の entrypoint が自動実行する (`eccube:composer:require` → `eccube:plugin:enable` → `dtb_payment_option` への INSERT)。 + +```bash +# 開発環境 (SQLite) の起動 — 本体取得・プラグイン有効化まで自動 +docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --wait + +# MySQL / PostgreSQL で起動する場合は対応ファイルを重ねる +docker compose -f docker-compose.yml -f docker-compose.mysql.yml -f docker-compose.dev.yml up -d --wait +docker compose -f docker-compose.yml -f docker-compose.pgsql.yml -f docker-compose.dev.yml up -d --wait + +# 起動確認・ログ +docker compose logs ec-cube +``` + +起動後のフロント URL は `https://localhost:4430` (自己署名証明書のため `ignoreHTTPSErrors`)、メールは MailCatcher (`http://localhost:1080`) で受信。 + +### E2E テスト (Playwright) + +テストは `tests/*.test.ts` の Playwright E2E のみ (PHPUnit は無い)。`baseURL` は `https://localhost:4430`、対象は起動中の Docker 環境。 + +```bash +npm ci # 依存インストール +npx playwright install # ブラウザ取得 +yarn playwright test # 全 E2E 実行 +yarn playwright test tests/guest_credit_token.test.ts # 単一ファイル実行 +npx playwright test -g "テスト名" # タイトル一致で単一テスト実行 +``` + +テストファイルは決済方式ごと: `guest_credit_link` (リンク型) / `guest_credit_token` (トークン型) / `guest_convini` (コンビニ)。CI (`.github/workflows/playwright.yml`) は mysql / pgsql / sqlite3 のマトリクスで実行される。 + +## 決済プラグインのアーキテクチャ + +### 決済処理ライフサイクル (最重要) + +各決済方式は `Eccube\Service\Payment\PaymentMethodInterface` を実装する `Service/Method/*.php` で、本体の購入フロー (`PurchaseFlow`) と連携して 3 段階で呼ばれる。**この 3 メソッドの責務分担が決済プラグイン実装の核心**: + +1. **`verify()`** — 注文確認画面遷移時。カードの有効性チェック等。`PaymentResult` を返す。トークン型はここでカード下 4 桁を取得・保持する。リンク型は実質何もしない。 +2. **`apply()`** — 注文確定時、決済実行**前**。受注ステータスを「決済処理中(PENDING)」、決済ステータスを「未決済(OUTSTANDING)」に変更し `purchaseFlow->prepare()` を呼ぶ。**リンク型はここで `PaymentDispatcher` に `RedirectResponse` を載せて返し、外部決済画面へ遷移させる**(`checkout()` は使わない)。 +3. **`checkout()`** — 注文確定時、決済実行。決済成功時は受注ステータスを NEW、決済ステータスを「仮売上(PROVISIONAL_SALES)」にして `purchaseFlow->commit()`、失敗時は `purchaseFlow->rollback()` してエラーを `PaymentResult` に詰める。 + +成功/失敗は必ず `PaymentResult::setSuccess()` で表現し、`purchaseFlow` の `prepare`/`commit`/`rollback` と受注・決済ステータス更新を**対で**行うのが規約。各 Method は本体の `PurchaseFlow $shoppingPurchaseFlow` を DI で受け取る。 + +### リンク型決済のリダイレクトフロー + +リンク型は `apply()` でのリダイレクト後、外部決済サーバとのやり取りを `Controller/PaymentController.php` (注文/戻る/完了通知) と `Controller/PaymentCompanyController.php` (決済会社画面の模擬) で処理する。本物の決済プラグインではここが Webhook / コールバック受信に相当する。 + +### Entity 拡張 (trait + @EntityExtension) + +本体の既存 Entity にカラムを追加する際は `Entity/*Trait.php` に trait を定義し、クラス DocComment に `@EntityExtension("Eccube\Entity\Order")` を付与する。本サンプルでは: + +- `OrderTrait` — `Order` にトークン・カード下 4 桁・コンビニ種別・決済ステータスを追加 (`dtb_order.sample_payment_*` カラム)。下 4 桁のみ永続化せず確認画面表示用。 +- `CustomerTrait` — `Customer` にカード情報変更機能用のカラムを追加。 + +プラグイン独自 Entity (`Config`, `PaymentStatus`, `CvsPaymentStatus`, `CvsType`) は通常の Doctrine Entity として `Entity/` に置き、対応する `Repository/` を持つ。 + +### 画面への介入 (TemplateEvent) + +`SamplePaymentEvent.php` (`EventSubscriberInterface`) が `getSubscribedEvents()` でフックする Twig を宣言し、`TemplateEvent::addSnippet()` で `Resource/template/*.twig` を差し込む。本体テンプレートを直接編集せずに購入画面・確認画面・管理画面注文編集・マイページナビへ UI を追加する。`SamplePaymentNav.php` が管理画面メニュー、`SamplePaymentTwigBlock.php` がブロックを追加する。 + +### PluginManager (インストール時処理) + +`PluginManager.php` の `enable()` が有効化時に実行される。決済方法 (`Payment` レコード) 3 種・初期設定・各種マスタ (PaymentStatus / CvsPaymentStatus / CvsType) ・マイページのカード情報変更ページ (`createPages()`) を登録する。決済方法と `Service/Method/*` クラスの紐付けもここで行う。 + +### スロットリング設定 + +`Resource/config/services.yaml` の `eccube.rate_limiter` でルート単位のレート制限を宣言できる (本サンプルではカード情報変更 `sample_payment_mypage_card_info` を ip/customer で 60 分 5 回に制限)。EC-CUBE 4.2+ のレートリミッタ機能を使う実装例。 + +### 開発ツール設定ファイルは `Resource/` 配下に置く (rector.php / .php-cs-fixer.dist.php) + +`rector.php` や `.php-cs-fixer.dist.php` を**プラグインのルート直下に置いてはならない**。`Resource/rector.php` のように `Resource/` 配下に置く。 + +**理由**: EC-CUBE 本体の `config/eccube/services.yaml` がプラグインを丸ごと PSR-4 サービス検出対象として読み込む: + +```yaml +Plugin\: + resource: '../../../app/Plugin/*' + exclude: '../../../app/Plugin/*/{Entity,Resource,ServiceProvider,Tests,Codeception,DoctrineMigrations}' +``` + +`app/Plugin/SamplePayment42/` 直下のすべての `*.php` が「サービスクラス」として読み込まれるため、ルートに `rector.php` を置くと Symfony が `Plugin\SamplePayment42\rector` クラスを期待し、見つからず **EC-CUBE 全体が 500 エラー**になる (実際に遭遇したエラー): + +``` +Expected to find class "Plugin\SamplePayment42\rector" in file +".../app/Plugin/SamplePayment42/rector.php" while importing services from +resource "../../../app/Plugin/*", but it was not found! +``` + +上記 `exclude` に `Resource` が含まれるため、`Resource/` 配下に置けばサービス検出から外れ衝突しない。 + +**本体では問題にならない理由**: 本体の autoconfigure 対象は `src/Eccube/*` で、プロジェクトルートはその外。ルート直下の `rector.php` / `.php-cs-fixer.dist.php` はグロブにかからないため本体では慣習どおりルートに置ける。プラグインは「ルートディレクトリ自体が PSR-4 ルートかつサービス検出対象」という点が決定的に異なる。 + +**トレードオフ / 運用上の注意**: +- 代償として `__DIR__` 基準のパスを `dirname(__DIR__)` に変更し、実行時に `--config=Resource/rector.php` を明示する必要がある。 +- 代替案 (ルートに置いて本体の `exclude` に追記) は本体改変が必要でプラグインの独立性を損なうため不可。プラグイン側の `services.yaml` では本体の `Plugin\:` 定義を上書きできない。 +- `.php-cs-fixer.dist.php` はドット始まりのため単体ではグロブに当たらない可能性もあるが (未検証)、`rector.php` と配置・運用を揃える一貫性のため同じ `Resource/` に置く。 +- **将来「本体に合わせてルートへ戻す」とリグレッションするため、この配置を変更しないこと。** + +## 規約メモ + +- 命名規約は本体の `eccube:plugin:generate` が生成する推奨ディレクトリ構成に合わせる (詳細は README.md および [issue #6](https://github.com/EC-CUBE/sample-payment-plugin/issues/6))。 +- 翻訳は `Resource/locale/messages.ja.yaml` / `validators.ja.yaml`。コードからは `trans('sample_payment.xxx')` で参照する。 +- 全 PHP ファイル冒頭に EC-CUBE 標準のライセンスヘッダを付与する。 diff --git a/Controller/Admin/ConfigController.php b/Controller/Admin/ConfigController.php index 04d0402..f431248 100644 --- a/Controller/Admin/ConfigController.php +++ b/Controller/Admin/ConfigController.php @@ -16,31 +16,23 @@ use Eccube\Controller\AbstractController; use Plugin\SamplePayment42\Form\Type\Admin\ConfigType; use Plugin\SamplePayment42\Repository\ConfigRepository; -use Symfony\Component\Routing\Annotation\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Attribute\Route; class ConfigController extends AbstractController { - /** - * @var ConfigRepository - */ - protected $configRepository; - /** * ConfigController constructor. * * @param ConfigRepository $configRepository */ - public function __construct(ConfigRepository $configRepository) + public function __construct(protected ConfigRepository $configRepository) { - $this->configRepository = $configRepository; } - /** - * @Route("/%eccube_admin_route%/sample_payment/config", name="sample_payment_admin_config") - * @Template("@SamplePayment/admin/config.twig") - */ + #[Route(path: '/%eccube_admin_route%/sample_payment/config', name: 'sample_payment_admin_config')] + #[Template(template: '@SamplePayment42/admin/config.twig')] public function index(Request $request) { $Config = $this->configRepository->get(); diff --git a/Controller/Admin/OrderController.php b/Controller/Admin/OrderController.php index 43d7584..80a7e11 100644 --- a/Controller/Admin/OrderController.php +++ b/Controller/Admin/OrderController.php @@ -15,18 +15,18 @@ use Eccube\Controller\AbstractController; use Eccube\Entity\Order; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\Routing\Attribute\Route; class OrderController extends AbstractController { /** * 受注編集 > 決済のキャンセル処理 - * - * @Route("/%eccube_admin_route%/sample_payment/order/cancel/{id}", requirements={"id" = "\d+"}, name="sample_payment_admin_order_cancel", methods={"POST"}) */ - public function cancel(Request $request, Order $Order) + #[Route(path: '/%eccube_admin_route%/sample_payment/order/cancel/{id}', requirements: ['id' => '\d+'], name: 'sample_payment_admin_order_cancel', methods: ['POST'])] + public function cancel(Request $request, Order $Order): JsonResponse { if ($request->isXmlHttpRequest() && $this->isTokenValid()) { // 通信処理 @@ -41,10 +41,9 @@ public function cancel(Request $request, Order $Order) /** * 受注編集 > 決済の金額変更 - * - * @Route("/%eccube_admin_route%/sample_payment/order/change_price/{id}", requirements={"id" = "\d+"}, name="sample_payment_admin_order_change_price", methods={"POST"}) */ - public function changePrice(Request $request, Order $Order) + #[Route(path: '/%eccube_admin_route%/sample_payment/order/change_price/{id}', requirements: ['id' => '\d+'], name: 'sample_payment_admin_order_change_price', methods: ['POST'])] + public function changePrice(Request $request, Order $Order): JsonResponse { if ($request->isXmlHttpRequest() && $this->isTokenValid()) { // 通信処理 diff --git a/Controller/Admin/PaymentStatusController.php b/Controller/Admin/PaymentStatusController.php index efcb6c0..8613372 100644 --- a/Controller/Admin/PaymentStatusController.php +++ b/Controller/Admin/PaymentStatusController.php @@ -22,34 +22,20 @@ use Knp\Component\Pager\PaginatorInterface; use Plugin\SamplePayment42\Form\Type\Admin\SearchPaymentType; use Plugin\SamplePayment42\Repository\PaymentStatusRepository; -use Symfony\Component\Routing\Annotation\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bridge\Twig\Attribute\Template; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Attribute\Route; /** * 決済状況管理 */ class PaymentStatusController extends AbstractController { - /** - * @var PaymentStatusRepository - */ - protected $paymentStatusRepository; - - /** - * @var PageMaxRepository - */ - protected $pageMaxRepository; - - /** - * @var OrderRepository - */ - protected $orderRepository; - /** * @var array */ - protected $bulkActions = [ + protected array $bulkActions = [ ['id' => 1, 'name' => '一括売上'], ['id' => 2, 'name' => '一括取消'], ['id' => 3, 'name' => '一括再オーソリ'], @@ -60,24 +46,17 @@ class PaymentStatusController extends AbstractController * * @param OrderStatusRepository $orderStatusRepository */ - public function __construct( - PaymentStatusRepository $paymentStatusRepository, - PageMaxRepository $pageMaxRepository, - OrderRepository $orderRepository - ) { - $this->paymentStatusRepository = $paymentStatusRepository; - $this->pageMaxRepository = $pageMaxRepository; - $this->orderRepository = $orderRepository; + public function __construct(protected PaymentStatusRepository $paymentStatusRepository, protected PageMaxRepository $pageMaxRepository, protected OrderRepository $orderRepository, private readonly PaginatorInterface $paginator) + { } /** * 決済状況一覧画面 - * - * @Route("/%eccube_admin_route%/sample_payment/payment_status", name="sample_payment_admin_payment_status") - * @Route("/%eccube_admin_route%/sample_payment/payment_status/{page_no}", requirements={"page_no" = "\d+"}, name="sample_payment_admin_payment_status_pageno") - * @Template("@SamplePayment/admin/payment_status.twig") */ - public function index(Request $request, $page_no = null, PaginatorInterface $paginator) + #[Route(path: '/%eccube_admin_route%/sample_payment/payment_status', name: 'sample_payment_admin_payment_status')] + #[Route(path: '/%eccube_admin_route%/sample_payment/payment_status/{page_no}', requirements: ['page_no' => '\d+'], name: 'sample_payment_admin_payment_status_pageno')] + #[Template(template: '@SamplePayment42/admin/payment_status.twig')] + public function index(Request $request, $page_no = null): array { $searchForm = $this->createForm(SearchPaymentType::class); @@ -157,7 +136,7 @@ public function index(Request $request, $page_no = null, PaginatorInterface $pag } $qb = $this->createQueryBuilder($searchData); - $pagination = $paginator->paginate( + $pagination = $this->paginator->paginate( $qb, $page_no, $page_count @@ -176,10 +155,9 @@ public function index(Request $request, $page_no = null, PaginatorInterface $pag /** * 一括処理. - * - * @Route("/%eccube_admin_route%/sample_payment/payment_status/bulk_action/{id}", requirements={"id" = "\d+"}, name="sample_payment_admin_payment_status_bulk_action", methods={"POST"}) */ - public function bulkAction(Request $request, $id) + #[Route(path: '/%eccube_admin_route%/sample_payment/payment_status/bulk_action/{id}', requirements: ['id' => '\d+'], name: 'sample_payment_admin_payment_status_bulk_action', methods: ['POST'])] + public function bulk(Request $request, string $id): RedirectResponse { if (!isset($this->bulkActions[$id])) { throw new BadRequestHttpException(); @@ -198,12 +176,12 @@ public function bulkAction(Request $request, $id) // 通信処理 // Order等の更新処理 break; - // 一括取消 + // 一括取消 case 2: // 通信処理 // Order等の更新処理 break; - // 一括再オーソリ + // 一括再オーソリ case 3: // 通信処理 // Order等の更新処理 diff --git a/Controller/MypageController.php b/Controller/MypageController.php index d5305ce..b69b765 100644 --- a/Controller/MypageController.php +++ b/Controller/MypageController.php @@ -5,7 +5,7 @@ * * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. * - * http://www.ec-cube.co.jp/ + * https://www.ec-cube.co.jp/ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,17 +14,15 @@ namespace Plugin\SamplePayment42\Controller; use Eccube\Controller\AbstractController; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; class MypageController extends AbstractController { - /** - * @Route("/mypage/sample_payment_card_info", name="sample_payment_mypage_card_info", methods={"GET", "POST"}) - * @Template("@SamplePayment42/card_info.twig") - */ + #[Route(path: '/mypage/sample_payment_card_info', name: 'sample_payment_mypage_card_info', methods: ['GET', 'POST'])] + #[Template(template: '@SamplePayment42/card_info.twig')] public function index(Request $request) { $builder = $this->formFactory->createBuilder(); @@ -44,11 +42,9 @@ public function index(Request $request) ]; } - /** - * @Route("/mypage/sample_payment_card_info_complete", name="sample_payment_mypage_card_info_complete", methods={"GET"}) - * @Template("@SamplePayment42/card_info_complete.twig") - */ - public function complete(Request $request) + #[Route(path: '/mypage/sample_payment_card_info_complete', name: 'sample_payment_mypage_card_info_complete', methods: ['GET'])] + #[Template(template: '@SamplePayment42/card_info_complete.twig')] + public function complete(): array { return []; } diff --git a/Controller/PaymentCompanyController.php b/Controller/PaymentCompanyController.php index 56e69e1..af25e75 100755 --- a/Controller/PaymentCompanyController.php +++ b/Controller/PaymentCompanyController.php @@ -14,10 +14,10 @@ namespace Plugin\SamplePayment42\Controller; use Eccube\Controller\AbstractController; -use Symfony\Component\Routing\Annotation\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Attribute\Route; /** * リンク式決済のカード番号入力画面. @@ -26,10 +26,9 @@ class PaymentCompanyController extends AbstractController { /** * 決済サーバのカード入力画面. - * - * @Route("/payment_company") - * @Template("@SamplePayment42/dummy.twig") */ + #[Route(path: '/payment_company')] + #[Template(template: '@SamplePayment42/dummy.twig')] public function index(Request $request) { $orderNo = $request->get('no'); diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 211868d..43f972e 100755 --- a/Controller/PaymentController.php +++ b/Controller/PaymentController.php @@ -22,96 +22,44 @@ use Eccube\Service\OrderStateMachine; use Eccube\Service\PurchaseFlow\PurchaseContext; use Eccube\Service\PurchaseFlow\PurchaseFlow; -use Eccube\Service\ShoppingService; use Plugin\SamplePayment42\Entity\CvsPaymentStatus; use Plugin\SamplePayment42\Entity\PaymentStatus; use Plugin\SamplePayment42\Repository\CvsPaymentStatusRepository; use Plugin\SamplePayment42\Repository\PaymentStatusRepository; use Plugin\SamplePayment42\Service\Method\Convenience; -use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Routing\Attribute\Route; /** * リンク式決済の注文/戻る/完了通知を処理する. */ class PaymentController extends AbstractController { - /** - * @var OrderRepository - */ - protected $orderRepository; - - /** - * @var OrderStatusRepository - */ - protected $orderStatusRepository; - - /** - * @var PaymentStatusRepository - */ - protected $paymentStatusRepository; - - /** - * @var CvsPaymentStatusRepository - */ - protected $cvsPaymentStatusRepository; - - /** - * @var PurchaseFlow - */ - protected $purchaseFlow; - - /** - * @var CartService - */ - protected $cartService; - - /** - * @var OrderStateMachine - */ - protected $orderStateMachine; - - /** * PaymentController constructor. * * @param OrderRepository $orderRepository * @param OrderStatusRepository $orderStatusRepository * @param PaymentStatusRepository $paymentStatusRepository - * @param CvsPaymentStatusRepository $CvsPaymentStatusRepository * @param PurchaseFlow $shoppingPurchaseFlow, * @param CartService $cartService * @param OrderStateMachine $orderStateMachine + * @param CvsPaymentStatusRepository $CvsPaymentStatusRepository */ - public function __construct( - OrderRepository $orderRepository, - OrderStatusRepository $orderStatusRepository, - PaymentStatusRepository $paymentStatusRepository, - CvsPaymentStatusRepository $cvsPaymentStatusRepository, - PurchaseFlow $shoppingPurchaseFlow, - CartService $cartService, - OrderStateMachine $orderStateMachine - ) { - $this->orderRepository = $orderRepository; - $this->orderStatusRepository = $orderStatusRepository; - $this->paymentStatusRepository = $paymentStatusRepository; - $this->cvsPaymentStatusRepository = $cvsPaymentStatusRepository; - $this->purchaseFlow = $shoppingPurchaseFlow; - $this->cartService = $cartService; - $this->orderStateMachine = $orderStateMachine; + public function __construct(protected OrderRepository $orderRepository, protected OrderStatusRepository $orderStatusRepository, protected PaymentStatusRepository $paymentStatusRepository, protected CvsPaymentStatusRepository $cvsPaymentStatusRepository, protected PurchaseFlow $shoppingPurchaseFlow, protected CartService $cartService, protected OrderStateMachine $orderStateMachine) + { } /** - * @Route("/sample_payment_back", name="sample_payment_back") - * * @param Request $request * * @return RedirectResponse */ + #[Route(path: '/sample_payment_back', name: 'sample_payment_back')] public function back(Request $request) { $orderNo = $request->get('no'); @@ -134,7 +82,7 @@ public function back(Request $request) $Order->setSamplePaymentPaymentStatus($PaymentStatus); // purchaseFlow::rollbackを呼び出し, 購入処理をロールバックする. - $this->purchaseFlow->rollback($Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->rollback($Order, new PurchaseContext()); $this->entityManager->flush(); @@ -143,10 +91,9 @@ public function back(Request $request) /** * 完了画面へ遷移する. - * - * @Route("/sample_payment_complete", name="sample_payment_complete") */ - public function complete(Request $request) + #[Route(path: '/sample_payment_complete', name: 'sample_payment_complete')] + public function complete(Request $request): RedirectResponse { $orderNo = $request->get('no'); $Order = $this->getOrderByNo($orderNo); @@ -172,10 +119,9 @@ public function complete(Request $request) /** * 結果通知URLを受け取る. - * - * @Route("/sample_payment_receive_complete", name="sample_payment_receive_complete") */ - public function receiveComplete(Request $request) + #[Route(path: '/sample_payment_receive_complete', name: 'sample_payment_receive_complete')] + public function receiveComplete(Request $request): Response { // 決済会社から受注番号を受け取る $orderNo = $request->get('no'); @@ -197,7 +143,7 @@ public function receiveComplete(Request $request) $Order->appendCompleteMailMessage(''); // purchaseFlow::commitを呼び出し, 購入処理を完了させる. - $this->purchaseFlow->commit($Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->commit($Order, new PurchaseContext()); $this->entityManager->flush(); @@ -206,10 +152,9 @@ public function receiveComplete(Request $request) /** * 結果通知URLを受け取る(コンビニ決済). - * - * @Route("/sample_payment_receive_cvs_status", name="sample_payment_receive_cvs_status") */ - public function receiveCvsStatus(Request $request) + #[Route(path: '/sample_payment_receive_cvs_status', name: 'sample_payment_receive_cvs_status')] + public function receiveCvsStatus(Request $request): Response { // 決済会社から受注番号を受け取る $orderNo = $request->get('no'); @@ -244,7 +189,7 @@ public function receiveCvsStatus(Request $request) } break; - // 期限切れ + // 期限切れ case CvsPaymentStatus::EXPIRED: // 受注ステータスをキャンセルへ変更 $OrderStatus = $this->orderStatusRepository->find(OrderStatus::CANCEL); @@ -259,7 +204,7 @@ public function receiveCvsStatus(Request $request) } break; - // 決済完了 + // 決済完了 case CvsPaymentStatus::COMPLETE: default: // 受注ステータスを対応中へ変更 @@ -287,7 +232,7 @@ public function receiveCvsStatus(Request $request) * * @return Order */ - private function getOrderByNo($orderNo) + private function getOrderByNo($orderNo): Order { /** @var OrderStatus $pendingOrderStatus */ $pendingOrderStatus = $this->orderStatusRepository->find(OrderStatus::PENDING); diff --git a/Entity/Config.php b/Entity/Config.php index d67b088..98cb734 100644 --- a/Entity/Config.php +++ b/Entity/Config.php @@ -13,50 +13,47 @@ namespace Plugin\SamplePayment42\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Plugin\SamplePayment42\Repository\ConfigRepository; /** * Config - * - * @ORM\Table(name="plg_sample_payment_config") - * @ORM\Entity(repositoryClass="Plugin\SamplePayment42\Repository\ConfigRepository") */ +#[ORM\Table(name: 'plg_sample_payment_config')] +#[ORM\Entity(repositoryClass: ConfigRepository::class)] class Config { /** * @var int - * - * @ORM\Column(name="id", type="integer", options={"unsigned":true}) - * @ORM\Id - * @ORM\GeneratedValue(strategy="IDENTITY") */ - private $id; + #[ORM\Column(name: 'id', type: Types::INTEGER, options: ['unsigned' => true])] + #[ORM\Id] + #[ORM\GeneratedValue(strategy: 'IDENTITY')] + private ?int $id = null; /** * @var string - * - * @ORM\Column(name="api_url", type="string", length=1024, nullable=true) */ - private $api_url; + #[ORM\Column(name: 'api_url', type: Types::STRING, length: 1024, nullable: true)] + private ?string $api_url = null; /** * @var string - * - * @ORM\Column(name="api_id", type="string", length=255, nullable=true) */ - private $api_id; + #[ORM\Column(name: 'api_id', type: Types::STRING, length: 255, nullable: true)] + private ?string $api_id = null; /** * @var string - * - * @ORM\Column(name="api_password", type="string", length=255, nullable=true) */ - private $api_password; + #[ORM\Column(name: 'api_password', type: Types::STRING, length: 255, nullable: true)] + private ?string $api_password = null; /** * @return int */ - public function getId() + public function getId(): int { return $this->id; } @@ -64,7 +61,7 @@ public function getId() /** * @return string */ - public function getApiUrl() + public function getApiUrl(): string { return $this->api_url; } @@ -74,7 +71,7 @@ public function getApiUrl() * * @return $this; */ - public function setApiUrl($api_url) + public function setApiUrl(string $api_url) { $this->api_url = $api_url; @@ -84,7 +81,7 @@ public function setApiUrl($api_url) /** * @return string */ - public function getApiId() + public function getApiId(): string { return $this->api_id; } @@ -94,7 +91,7 @@ public function getApiId() * * @return $this; */ - public function setApiId($api_id) + public function setApiId(string $api_id) { $this->api_id = $api_id; @@ -104,7 +101,7 @@ public function setApiId($api_id) /** * @return string */ - public function getApiPassword() + public function getApiPassword(): string { return $this->api_password; } @@ -114,7 +111,7 @@ public function getApiPassword() * * @return $this */ - public function setApiPassword($api_password) + public function setApiPassword(string $api_password) { $this->api_password = $api_password; diff --git a/Entity/CustomerTrait.php b/Entity/CustomerTrait.php index 73c42c7..583b04f 100644 --- a/Entity/CustomerTrait.php +++ b/Entity/CustomerTrait.php @@ -13,19 +13,19 @@ namespace Plugin\SamplePayment42\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use Eccube\Annotation\EntityExtension; +use Eccube\Attribute\EntityExtension; +use Eccube\Entity\Customer; -/** - * @EntityExtension("Eccube\Entity\Customer") - */ +#[EntityExtension(Customer::class)] trait CustomerTrait { /** * カードの記憶用カラム. * * @var string - * @ORM\Column(type="smallint", nullable=true) */ - public $sample_payment_cards; + #[ORM\Column(type: Types::SMALLINT, nullable: true)] + public ?int $sample_payment_cards = null; } diff --git a/Entity/CvsPaymentStatus.php b/Entity/CvsPaymentStatus.php index 93c64ab..ff9da25 100644 --- a/Entity/CvsPaymentStatus.php +++ b/Entity/CvsPaymentStatus.php @@ -15,13 +15,13 @@ use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\Master\AbstractMasterEntity; +use Plugin\SamplePayment42\Repository\CvsPaymentStatusRepository; /** * CvsPaymentStatus - * - * @ORM\Table(name="plg_sample_payment_cvs_payment_status") - * @ORM\Entity(repositoryClass="Plugin\SamplePayment42\Repository\CvsPaymentStatusRepository") */ +#[ORM\Table(name: 'plg_sample_payment_cvs_payment_status')] +#[ORM\Entity(repositoryClass: CvsPaymentStatusRepository::class)] class CvsPaymentStatus extends AbstractMasterEntity { /** @@ -31,21 +31,21 @@ class CvsPaymentStatus extends AbstractMasterEntity /** * 未決済 */ - const OUTSTANDING = 1; + public const OUTSTANDING = 1; /** * 要求成功 */ - const REQUEST = 2; + public const REQUEST = 2; /** * 決済完了 */ - const COMPLETE = 3; + public const COMPLETE = 3; /** * 決済失敗 */ - const FAILURE = 4; + public const FAILURE = 4; /** * 期限切れ */ - const EXPIRED = 5; + public const EXPIRED = 5; } diff --git a/Entity/CvsType.php b/Entity/CvsType.php index b87399a..8d650ac 100644 --- a/Entity/CvsType.php +++ b/Entity/CvsType.php @@ -15,13 +15,13 @@ use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\Master\AbstractMasterEntity; +use Plugin\SamplePayment42\Repository\CvsTypeRepository; /** * コンビニ種別 - * - * @ORM\Table(name="plg_sample_payment_cvs_type") - * @ORM\Entity(repositoryClass="Plugin\SamplePayment42\Repository\CvsTypeRepository") */ +#[ORM\Table(name: 'plg_sample_payment_cvs_type')] +#[ORM\Entity(repositoryClass: CvsTypeRepository::class)] class CvsType extends AbstractMasterEntity { /** @@ -31,14 +31,14 @@ class CvsType extends AbstractMasterEntity /** * ローソン */ - const LAWSON = '00001'; + public const LAWSON = '00001'; /** * ミニストップ */ - const MINISTOP = '00005'; + public const MINISTOP = '00005'; /** * セブンイレブン */ - const SEVENELEVEN = '00007'; + public const SEVENELEVEN = '00007'; } diff --git a/Entity/OrderTrait.php b/Entity/OrderTrait.php index 76ed4d0..703ae5b 100644 --- a/Entity/OrderTrait.php +++ b/Entity/OrderTrait.php @@ -13,12 +13,12 @@ namespace Plugin\SamplePayment42\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use Eccube\Annotation\EntityExtension; +use Eccube\Attribute\EntityExtension; +use Eccube\Entity\Order; -/** - * @EntityExtension("Eccube\Entity\Order") - */ +#[EntityExtension(Order::class)] trait OrderTrait { /** @@ -27,9 +27,9 @@ trait OrderTrait * dtb_order.sample_payment_token * * @var string - * @ORM\Column(type="string", nullable=true) */ - private $sample_payment_token; + #[ORM\Column(type: Types::STRING, nullable: true)] + private ?string $sample_payment_token = null; /** * クレジットカード番号の末尾4桁. @@ -37,7 +37,7 @@ trait OrderTrait * * @var string */ - private $sample_payment_card_no_last4; + private string $sample_payment_card_no_last4; /** * コンビニ用種別を保持するカラム. @@ -45,13 +45,10 @@ trait OrderTrait * dtb_order.sample_payment_cvs_type_id * * @var CvsType - * @ORM\ManyToOne(targetEntity="Plugin\SamplePayment42\Entity\CvsType") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="sample_payment_cvs_type_id", referencedColumnName="id") - * }) */ - private $SamplePaymentCvsType; - + #[ORM\JoinColumn(name: 'sample_payment_cvs_type_id', referencedColumnName: 'id')] + #[ORM\ManyToOne(targetEntity: CvsType::class)] + private ?CvsType $SamplePaymentCvsType = null; /** * 決済ステータスを保持するカラム. @@ -59,12 +56,10 @@ trait OrderTrait * dtb_order.sample_payment_payment_status_id * * @var SamplePaymentPaymentStatus - * @ORM\ManyToOne(targetEntity="Plugin\SamplePayment42\Entity\PaymentStatus") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="sample_payment_payment_status_id", referencedColumnName="id") - * }) */ - private $SamplePaymentPaymentStatus; + #[ORM\JoinColumn(name: 'sample_payment_payment_status_id', referencedColumnName: 'id')] + #[ORM\ManyToOne(targetEntity: PaymentStatus::class)] + private ?PaymentStatus $SamplePaymentPaymentStatus = null; /** * コンビニ用決済ステータスを保持するカラム. @@ -72,17 +67,15 @@ trait OrderTrait * dtb_order.sample_payment_payment_status_id * * @var SamplePaymentCvsPaymentStatus - * @ORM\ManyToOne(targetEntity="Plugin\SamplePayment42\Entity\CvsPaymentStatus") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="sample_payment_cvs_payment_status_id", referencedColumnName="id") - * }) */ - private $SamplePaymentCvsPaymentStatus; + #[ORM\JoinColumn(name: 'sample_payment_cvs_payment_status_id', referencedColumnName: 'id')] + #[ORM\ManyToOne(targetEntity: CvsPaymentStatus::class)] + private ?CvsPaymentStatus $SamplePaymentCvsPaymentStatus = null; /** - * @return string + * @return string|null */ - public function getSamplePaymentToken() + public function getSamplePaymentToken(): ?string { return $this->sample_payment_token; } @@ -92,7 +85,7 @@ public function getSamplePaymentToken() * * @return $this */ - public function setSamplePaymentToken($sample_payment_token) + public function setSamplePaymentToken(string $sample_payment_token) { $this->sample_payment_token = $sample_payment_token; @@ -100,25 +93,25 @@ public function setSamplePaymentToken($sample_payment_token) } /** - * @return string + * @return string|null */ - public function getSamplePaymentCardNoLast4() + public function getSamplePaymentCardNoLast4(): ?string { - return $this->sample_payment_card_no_last4; + return $this->sample_payment_card_no_last4 ?? null; } /** * @param string $sample_payment_card_no_last4 */ - public function setSamplePaymentCardNoLast4($sample_payment_card_no_last4) + public function setSamplePaymentCardNoLast4(string $sample_payment_card_no_last4) { $this->sample_payment_card_no_last4 = $sample_payment_card_no_last4; } /** - * @return CvsType + * @return CvsType|null */ - public function getSamplePaymentCvsType() + public function getSamplePaymentCvsType(): ?CvsType { return $this->SamplePaymentCvsType; } @@ -132,33 +125,33 @@ public function setSamplePaymentCvsType(CvsType $SamplePaymentCvsType) } /** - * @return PaymentStatus + * @return PaymentStatus|null */ - public function getSamplePaymentPaymentStatus() + public function getSamplePaymentPaymentStatus(): ?PaymentStatus { return $this->SamplePaymentPaymentStatus; } /** - * @param PaymentStatus $SamplePaymentPaymentStatus|null + * @param PaymentStatus|null $SamplePaymentPaymentStatus */ - public function setSamplePaymentPaymentStatus(PaymentStatus $SamplePaymentPaymentStatus = null) + public function setSamplePaymentPaymentStatus(?PaymentStatus $SamplePaymentPaymentStatus = null) { $this->SamplePaymentPaymentStatus = $SamplePaymentPaymentStatus; } /** - * @return CvsPaymentStatus + * @return CvsPaymentStatus|null */ - public function getSamplePaymentCvsPaymentStatus() + public function getSamplePaymentCvsPaymentStatus(): ?CvsPaymentStatus { return $this->SamplePaymentCvsPaymentStatus; } /** - * @param CvsPaymentStatus $SamplePaymentCvsPaymentStatus|null + * @param CvsPaymentStatus|null $SamplePaymentCvsPaymentStatus */ - public function setSamplePaymentCvsPaymentStatus(CvsPaymentStatus $SamplePaymentCvsPaymentStatus = null) + public function setSamplePaymentCvsPaymentStatus(?CvsPaymentStatus $SamplePaymentCvsPaymentStatus = null) { $this->SamplePaymentCvsPaymentStatus = $SamplePaymentCvsPaymentStatus; } diff --git a/Entity/PaymentStatus.php b/Entity/PaymentStatus.php index 313cd04..b3c6f6f 100644 --- a/Entity/PaymentStatus.php +++ b/Entity/PaymentStatus.php @@ -15,13 +15,13 @@ use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\Master\AbstractMasterEntity; +use Plugin\SamplePayment42\Repository\PaymentStatusRepository; /** * PaymentStatus - * - * @ORM\Table(name="plg_sample_payment_payment_status") - * @ORM\Entity(repositoryClass="Plugin\SamplePayment42\Repository\PaymentStatusRepository") */ +#[ORM\Table(name: 'plg_sample_payment_payment_status')] +#[ORM\Entity(repositoryClass: PaymentStatusRepository::class)] class PaymentStatus extends AbstractMasterEntity { /** @@ -31,21 +31,21 @@ class PaymentStatus extends AbstractMasterEntity /** * 未決済 */ - const OUTSTANDING = 1; + public const OUTSTANDING = 1; /** * 有効性チェック済 */ - const ENABLED = 2; + public const ENABLED = 2; /** * 仮売上 */ - const PROVISIONAL_SALES = 3; + public const PROVISIONAL_SALES = 3; /** * 実売上 */ - const ACTUAL_SALES = 4; + public const ACTUAL_SALES = 4; /** * キャンセル */ - const CANCEL = 5; + public const CANCEL = 5; } diff --git a/Form/Extension/CreditCardExtention.php b/Form/Extension/CreditCardExtention.php index 6bbf3de..c4051da 100644 --- a/Form/Extension/CreditCardExtention.php +++ b/Form/Extension/CreditCardExtention.php @@ -16,7 +16,6 @@ use Eccube\Entity\Order; use Eccube\Form\Type\Shopping\OrderType; use Eccube\Repository\PaymentRepository; -use Plugin\SamplePayment42\Service\Method\CreditCard; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; @@ -29,17 +28,11 @@ */ class CreditCardExtention extends AbstractTypeExtension { - /** - * @var PaymentRepository - */ - protected $paymentRepository; - - public function __construct(PaymentRepository $paymentRepository) + public function __construct(protected PaymentRepository $paymentRepository) { - $this->paymentRepository = $paymentRepository; } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { // ShoppingController::checkoutから呼ばれる場合は, フォーム項目の定義をスキップする. if ($options['skip_add_form']) { diff --git a/Form/Extension/CvsExtension.php b/Form/Extension/CvsExtension.php index 9d6f325..87cc3d6 100644 --- a/Form/Extension/CvsExtension.php +++ b/Form/Extension/CvsExtension.php @@ -32,25 +32,11 @@ */ class CvsExtension extends AbstractTypeExtension { - /** - * @var PaymentRepository - */ - protected $paymentRepository; - - /** - * @var CvsTypeRepository - */ - protected $cvsTypeRepository; - - public function __construct( - CvsTypeRepository $cvsTypeRepository, - PaymentRepository $paymentRepository - ) { - $this->cvsTypeRepository = $cvsTypeRepository; - $this->paymentRepository = $paymentRepository; + public function __construct(protected CvsTypeRepository $cvsTypeRepository, protected PaymentRepository $paymentRepository) + { } - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { // ShoppingController::checkoutから呼ばれる場合は, フォーム項目の定義をスキップする. if ($options['skip_add_form']) { @@ -64,10 +50,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) $form->add('SamplePaymentCvsType', EntityType::class, [ 'class' => CvsType::class, - 'query_builder' => function (EntityRepository $er) { - return $er->createQueryBuilder('p') - ->orderBy('p.id', 'ASC'); - }, + 'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('p') + ->orderBy('p.id', 'ASC'), 'choice_label' => 'name', 'multiple' => false, 'expanded' => true, diff --git a/Form/Type/Admin/ConfigType.php b/Form/Type/Admin/ConfigType.php index 1d82bcd..f2b96a1 100644 --- a/Form/Type/Admin/ConfigType.php +++ b/Form/Type/Admin/ConfigType.php @@ -23,7 +23,7 @@ class ConfigType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('api_id', TextType::class, [ @@ -43,7 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Config::class, diff --git a/Form/Type/Admin/SearchPaymentType.php b/Form/Type/Admin/SearchPaymentType.php index 13b2da8..f3b800d 100644 --- a/Form/Type/Admin/SearchPaymentType.php +++ b/Form/Type/Admin/SearchPaymentType.php @@ -23,7 +23,7 @@ class SearchPaymentType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('Payments', PaymentType::class, [ @@ -36,10 +36,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]) ->add('PaymentStatuses', EntityType::class, [ 'class' => PaymentStatus::class, - 'query_builder' => function (EntityRepository $er) { - return $er->createQueryBuilder('p') - ->orderBy('p.id', 'ASC'); - }, + 'query_builder' => fn (EntityRepository $er) => $er->createQueryBuilder('p') + ->orderBy('p.id', 'ASC'), 'choice_label' => 'name', 'multiple' => true, 'expanded' => true, diff --git a/PluginManager.php b/PluginManager.php index 59d639e..08e97d7 100644 --- a/PluginManager.php +++ b/PluginManager.php @@ -19,7 +19,6 @@ use Eccube\Entity\PageLayout; use Eccube\Entity\Payment; use Eccube\Plugin\AbstractPluginManager; -use Eccube\Repository\PaymentRepository; use Plugin\SamplePayment42\Entity\Config; use Plugin\SamplePayment42\Entity\CvsPaymentStatus; use Plugin\SamplePayment42\Entity\CvsType; @@ -44,7 +43,7 @@ class PluginManager extends AbstractPluginManager ], ]; - public function enable(array $meta, ContainerInterface $container) + public function enable(array $meta, ContainerInterface $container): void { $this->createTokenPayment($container); $this->createLinkPayment($container); @@ -152,7 +151,7 @@ private function createMasterData(ContainerInterface $container, array $statuses foreach ($statuses as $id => $name) { $PaymentStatus = $entityManager->find($class, $id); if (!$PaymentStatus) { - $PaymentStatus = new $class; + $PaymentStatus = new $class(); } $PaymentStatus->setId($id); $PaymentStatus->setName($name); diff --git a/Resource/.php-cs-fixer.dist.php b/Resource/.php-cs-fixer.dist.php new file mode 100644 index 0000000..7d42e99 --- /dev/null +++ b/Resource/.php-cs-fixer.dist.php @@ -0,0 +1,55 @@ + true, + 'array_syntax' => ['syntax' => 'short'], + 'phpdoc_align' => false, + 'phpdoc_summary' => false, + 'phpdoc_annotation_without_dot' => false, + 'no_superfluous_phpdoc_tags' => false, + 'increment_style' => false, + 'yoda_style' => false, + 'header_comment' => ['header' => $header], + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_param_order' => true, + 'phpdoc_to_comment' => false, // /** @var */ を変換してしまうため + 'phpdoc_trim' => true, + 'global_namespace_import' => [ + 'import_classes' => false, + 'import_constants' => false, + 'import_functions' => false, + ], + // PHPDocの型をネイティブ型へ + 'phpdoc_to_param_type' => true, + 'phpdoc_to_return_type' => true, + 'phpdoc_to_property_type' => true, +]; + +$finder = \PhpCsFixer\Finder::create() + ->in(dirname(__DIR__)) + ->exclude(['vendor', 'node_modules', 'Resource']) + ->name('*.php') +; +$config = new \PhpCsFixer\Config(); + +return $config + ->setRules($rules) + ->setFinder($finder) + ->setRiskyAllowed(true) + ->setUnsupportedPhpVersionAllowed(true) +; diff --git a/Resource/rector.php b/Resource/rector.php new file mode 100644 index 0000000..bf1aa0e --- /dev/null +++ b/Resource/rector.php @@ -0,0 +1,64 @@ +withPhpVersion(PhpVersion::PHP_82) + // プラグインのソースディレクトリ + ->withPaths([ + dirname(__DIR__).'/Controller', + dirname(__DIR__).'/Entity', + dirname(__DIR__).'/Form', + dirname(__DIR__).'/Repository', + dirname(__DIR__).'/Service', + dirname(__DIR__).'/Util', + dirname(__DIR__).'/PluginManager.php', + dirname(__DIR__).'/SamplePaymentEvent.php', + dirname(__DIR__).'/SamplePaymentNav.php', + dirname(__DIR__).'/SamplePaymentTwigBlock.php', + ]) + ->withSkip([ + dirname(__DIR__).'/vendor', + dirname(__DIR__).'/node_modules', + ]) + ->withSets([ + LevelSetList::UP_TO_PHP_82, + // Symfony 7.4 対応 (@Route → #[Route], @Template, buildForm(): void 等) + SymfonySetList::SYMFONY_74, + SymfonySetList::SYMFONY_CODE_QUALITY, + // Doctrine ORM 3.0 / DBAL 3.0 対応 (@ORM → #[ORM], 型付きプロパティ) + DoctrineSetList::DOCTRINE_CODE_QUALITY, + DoctrineSetList::DOCTRINE_DBAL_30, + DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, + ]) + // Symfony/Doctrine 等のアノテーション → アトリビュート変換を有効化 + ->withAttributesSets() + // #[Route] は付与されるが use 文が旧 Annotation のまま残るため Attribute へ統一する + ->withConfiguredRule(RenameClassRector::class, [ + 'Symfony\Component\Routing\Annotation\Route' => 'Symfony\Component\Routing\Attribute\Route', + ]) + ->withImportNames( + importShortClasses: false, + importDocBlockNames: true, + importNames: true + ) + ->withParallel(); diff --git a/SamplePaymentEvent.php b/SamplePaymentEvent.php index 7cd37dc..822c756 100644 --- a/SamplePaymentEvent.php +++ b/SamplePaymentEvent.php @@ -33,7 +33,7 @@ class SamplePaymentEvent implements EventSubscriberInterface * * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'Shopping/index.twig' => 'onShoppingIndexTwig', diff --git a/SamplePaymentNav.php b/SamplePaymentNav.php index e8dd82b..f9a7576 100644 --- a/SamplePaymentNav.php +++ b/SamplePaymentNav.php @@ -20,7 +20,7 @@ class SamplePaymentNav implements EccubeNav /** * @return array */ - public static function getNav() + public static function getNav(): array { return [ 'order' => [ diff --git a/SamplePaymentTwigBlock.php b/SamplePaymentTwigBlock.php index 484bdac..f462a7d 100644 --- a/SamplePaymentTwigBlock.php +++ b/SamplePaymentTwigBlock.php @@ -20,11 +20,11 @@ class SamplePaymentTwigBlock implements EccubeTwigBlock /** * @return array */ - public static function getTwigBlock() + public static function getTwigBlock(): array { return [ - '@SamplePayment/credit.twig', - '@SamplePayment/credit_confirm.twig', + '@SamplePayment42/credit.twig', + '@SamplePayment42/credit_confirm.twig', ]; } } diff --git a/Service/Method/Convenience.php b/Service/Method/Convenience.php index 4a3cb7e..e838047 100644 --- a/Service/Method/Convenience.php +++ b/Service/Method/Convenience.php @@ -25,7 +25,6 @@ use Plugin\SamplePayment42\Entity\CvsPaymentStatus; use Plugin\SamplePayment42\Repository\CvsPaymentStatusRepository; use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; /** * コンビニ払いの決済処理を行う @@ -35,27 +34,12 @@ class Convenience implements PaymentMethodInterface /** * @var Order */ - private $Order; + private Order $Order; /** * @var FormInterface */ - private $form; - - /** - * @var OrderStatusRepository - */ - private $orderStatusRepository; - - /** - * @var CvsPaymentStatusRepository - */ - private $cvsPaymentStatusRepository; - - /** - * @var PurchaseFlow - */ - private $purchaseFlow; + private FormInterface $form; /** * LinkCreditCard constructor. @@ -64,14 +48,8 @@ class Convenience implements PaymentMethodInterface * @param CvsPaymentStatusRepository $cvsPaymentStatusRepository * @param PurchaseFlow $shoppingPurchaseFlow */ - public function __construct( - OrderStatusRepository $orderStatusRepository, - CvsPaymentStatusRepository $cvsPaymentStatusRepository, - PurchaseFlow $shoppingPurchaseFlow - ) { - $this->orderStatusRepository = $orderStatusRepository; - $this->cvsPaymentStatusRepository = $cvsPaymentStatusRepository; - $this->purchaseFlow = $shoppingPurchaseFlow; + public function __construct(private readonly OrderStatusRepository $orderStatusRepository, private readonly CvsPaymentStatusRepository $cvsPaymentStatusRepository, private readonly PurchaseFlow $shoppingPurchaseFlow) + { } /** @@ -79,14 +57,11 @@ public function __construct( * * コンビニ決済は使用しない. * - * @return PaymentResult|void + * @return PaymentResult|bool */ - public function verify() + public function verify(): PaymentResult|bool { - $result = new PaymentResult(); - $result->setSuccess(true); - - return $result; + return false; } /** @@ -94,11 +69,11 @@ public function verify() * * 決済サーバのカード入力画面へリダイレクトする. * - * @return PaymentDispatcher + * @return PaymentDispatcher|bool * * @throws ShoppingException */ - public function apply() + public function apply(): PaymentDispatcher|bool { // 受注ステータスを決済処理中へ変更 $OrderStatus = $this->orderStatusRepository->find(OrderStatus::PENDING); @@ -109,8 +84,9 @@ public function apply() $this->Order->setSamplePaymentCvsPaymentStatus($PaymentStatus); // purchaseFlow::prepareを呼び出し, 購入処理を進める. - $this->purchaseFlow->prepare($this->Order, new PurchaseContext()); - return null; + $this->shoppingPurchaseFlow->prepare($this->Order, new PurchaseContext()); + + return false; } /** @@ -118,7 +94,7 @@ public function apply() * * @return PaymentResult */ - public function checkout() + public function checkout(): PaymentResult { // 決済サーバとの通信処理(コンビニ払い込み情報等の取得) // ... @@ -139,7 +115,7 @@ public function checkout() $this->Order->appendCompleteMailMessage($message); // purchaseFlow::commitを呼び出し, 購入処理を完了させる. - $this->purchaseFlow->commit($this->Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->commit($this->Order, new PurchaseContext()); } else { // 受注ステータスを購入処理中へ変更 $OrderStatus = $this->orderStatusRepository->find(OrderStatus::PROCESSING); @@ -152,7 +128,7 @@ public function checkout() $result->setErrors([trans('sample_payment.shopping.cvs.error')]); // 失敗時はpurchaseFlow::rollbackを呼び出す. - $this->purchaseFlow->rollback($this->Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->rollback($this->Order, new PurchaseContext()); } return $result; @@ -161,16 +137,20 @@ public function checkout() /** * {@inheritdoc} */ - public function setFormType(FormInterface $form) + public function setFormType(FormInterface $form): PaymentMethodInterface { $this->form = $form; + + return $this; } /** * {@inheritdoc} */ - public function setOrder(Order $Order) + public function setOrder(Order $Order): PaymentMethodInterface { $this->Order = $Order; + + return $this; } } diff --git a/Service/Method/CreditCard.php b/Service/Method/CreditCard.php index 32e408b..45593ed 100644 --- a/Service/Method/CreditCard.php +++ b/Service/Method/CreditCard.php @@ -20,6 +20,7 @@ use Eccube\Service\Payment\PaymentMethodInterface; use Eccube\Service\Payment\PaymentResult; use Eccube\Service\PurchaseFlow\PurchaseContext; +use Eccube\Service\PurchaseFlow\PurchaseException; use Eccube\Service\PurchaseFlow\PurchaseFlow; use Plugin\SamplePayment42\Entity\PaymentStatus; use Plugin\SamplePayment42\Repository\PaymentStatusRepository; @@ -33,27 +34,12 @@ class CreditCard implements PaymentMethodInterface /** * @var Order */ - protected $Order; + protected Order $Order; /** * @var FormInterface */ - protected $form; - - /** - * @var OrderStatusRepository - */ - private $orderStatusRepository; - - /** - * @var PaymentStatusRepository - */ - private $paymentStatusRepository; - - /** - * @var PurchaseFlow - */ - private $purchaseFlow; + protected FormInterface $form; /** * CreditCard constructor. @@ -62,14 +48,8 @@ class CreditCard implements PaymentMethodInterface * @param PaymentStatusRepository $paymentStatusRepository * @param PurchaseFlow $shoppingPurchaseFlow */ - public function __construct( - OrderStatusRepository $orderStatusRepository, - PaymentStatusRepository $paymentStatusRepository, - PurchaseFlow $shoppingPurchaseFlow - ) { - $this->orderStatusRepository = $orderStatusRepository; - $this->paymentStatusRepository = $paymentStatusRepository; - $this->purchaseFlow = $shoppingPurchaseFlow; + public function __construct(private readonly OrderStatusRepository $orderStatusRepository, private readonly PaymentStatusRepository $paymentStatusRepository, private readonly PurchaseFlow $shoppingPurchaseFlow) + { } /** @@ -77,26 +57,27 @@ public function __construct( * * クレジットカードの有効性チェックを行う. * - * @return PaymentResult + * @return PaymentResult|bool 成功時は false を返す(EC-CUBE 4.4 以降の仕様) * - * @throws \Eccube\Service\PurchaseFlow\PurchaseException + * @throws PurchaseException */ - public function verify() + public function verify(): PaymentResult|bool { // 決済サーバとの通信処理(有効性チェックやカード番号の下4桁取得) // ... // if (true) { - $result = new PaymentResult(); - $result->setSuccess(true); + // 成功: カード下4桁を設定して確認画面へ進む $this->Order->setSamplePaymentCardNoLast4('****-*****-****-1234'); - } else { - $result = new PaymentResult(); - $result->setSuccess(false); - $result->setErrors([trans('sample_payment.shopping.verify.error')]); + + return false; } + $result = new PaymentResult(); + $result->setSuccess(false); + $result->setErrors([trans('sample_payment.shopping.verify.error')]); + return $result; } @@ -106,9 +87,9 @@ public function verify() * 受注ステータス, 決済ステータスを更新する. * ここでは決済サーバとの通信は行わない. * - * @return PaymentDispatcher|null + * @return PaymentDispatcher|bool */ - public function apply() + public function apply(): PaymentDispatcher|bool { // 受注ステータスを決済処理中へ変更 $OrderStatus = $this->orderStatusRepository->find(OrderStatus::PENDING); @@ -119,7 +100,9 @@ public function apply() $this->Order->setSamplePaymentPaymentStatus($PaymentStatus); // purchaseFlow::prepareを呼び出し, 購入処理を進める. - $this->purchaseFlow->prepare($this->Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->prepare($this->Order, new PurchaseContext()); + + return false; } /** @@ -129,7 +112,7 @@ public function apply() * * @return PaymentResult */ - public function checkout() + public function checkout(): PaymentResult { // 決済サーバに仮売上のリクエスト送る(設定等によって送るリクエストは異なる) // ... @@ -150,7 +133,7 @@ public function checkout() $this->Order->appendCompleteMailMessage('トークン -> '.$token); // purchaseFlow::commitを呼び出し, 購入処理を完了させる. - $this->purchaseFlow->commit($this->Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->commit($this->Order, new PurchaseContext()); $result = new PaymentResult(); $result->setSuccess(true); @@ -164,7 +147,7 @@ public function checkout() $this->Order->setSamplePaymentPaymentStatus($PaymentStatus); // 失敗時はpurchaseFlow::rollbackを呼び出す. - $this->purchaseFlow->rollback($this->Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->rollback($this->Order, new PurchaseContext()); $result = new PaymentResult(); $result->setSuccess(false); @@ -177,16 +160,20 @@ public function checkout() /** * {@inheritdoc} */ - public function setFormType(FormInterface $form) + public function setFormType(FormInterface $form): PaymentMethodInterface { $this->form = $form; + + return $this; } /** * {@inheritdoc} */ - public function setOrder(Order $Order) + public function setOrder(Order $Order): PaymentMethodInterface { $this->Order = $Order; + + return $this; } } diff --git a/Service/Method/LinkCreditCard.php b/Service/Method/LinkCreditCard.php index eca8973..9a9779f 100755 --- a/Service/Method/LinkCreditCard.php +++ b/Service/Method/LinkCreditCard.php @@ -35,27 +35,12 @@ class LinkCreditCard implements PaymentMethodInterface /** * @var Order */ - private $Order; + private Order $Order; /** * @var FormInterface */ - private $form; - - /** - * @var OrderStatusRepository - */ - private $orderStatusRepository; - - /** - * @var PaymentStatusRepository - */ - private $paymentStatusRepository; - - /** - * @var PurchaseFlow - */ - private $purchaseFlow; + private FormInterface $form; /** * LinkCreditCard constructor. @@ -64,14 +49,8 @@ class LinkCreditCard implements PaymentMethodInterface * @param PaymentStatusRepository $paymentStatusRepository * @param PurchaseFlow $shoppingPurchaseFlow */ - public function __construct( - OrderStatusRepository $orderStatusRepository, - PaymentStatusRepository $paymentStatusRepository, - PurchaseFlow $shoppingPurchaseFlow - ) { - $this->orderStatusRepository = $orderStatusRepository; - $this->paymentStatusRepository = $paymentStatusRepository; - $this->purchaseFlow = $shoppingPurchaseFlow; + public function __construct(private readonly OrderStatusRepository $orderStatusRepository, private readonly PaymentStatusRepository $paymentStatusRepository, private readonly PurchaseFlow $shoppingPurchaseFlow) + { } /** @@ -79,14 +58,11 @@ public function __construct( * * リンク式は使用しない. * - * @return PaymentResult|void + * @return PaymentResult|bool */ - public function verify() + public function verify(): PaymentResult|bool { - $result = new PaymentResult(); - $result->setSuccess(true); - - return $result; + return false; } /** @@ -98,7 +74,7 @@ public function verify() * * @throws ShoppingException */ - public function apply() + public function apply(): PaymentDispatcher { // 受注ステータスを決済処理中へ変更 $OrderStatus = $this->orderStatusRepository->find(OrderStatus::PENDING); @@ -109,7 +85,7 @@ public function apply() $this->Order->setSamplePaymentPaymentStatus($PaymentStatus); // purchaseFlow::prepareを呼び出し, 購入処理を進める. - $this->purchaseFlow->prepare($this->Order, new PurchaseContext()); + $this->shoppingPurchaseFlow->prepare($this->Order, new PurchaseContext()); // 決済サーバのカード入力画面へリダイレクトする. $url = '/payment_company?no='.$this->Order->getOrderNo(); @@ -126,7 +102,7 @@ public function apply() * * @return PaymentResult */ - public function checkout() + public function checkout(): PaymentResult { $result = new PaymentResult(); $result->setSuccess(true); @@ -137,16 +113,20 @@ public function checkout() /** * {@inheritdoc} */ - public function setFormType(FormInterface $form) + public function setFormType(FormInterface $form): PaymentMethodInterface { $this->form = $form; + + return $this; } /** * {@inheritdoc} */ - public function setOrder(Order $Order) + public function setOrder(Order $Order): PaymentMethodInterface { $this->Order = $Order; + + return $this; } } diff --git a/docker-compose.yml b/docker-compose.yml index 1726a33..a90cae1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ volumes: services: ### ECCube4 ################################## ec-cube: - image: ghcr.io/ec-cube/ec-cube-php:7.4-apache-4.2 + image: ghcr.io/ec-cube/ec-cube-php:8.2-apache-4.4 ports: - 8080:80 - 4430:443 diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 3210844..0000000 --- a/package-lock.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "sample-payment-plugin", - "version": "0.9.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "sample-payment-plugin", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "playwright-core": "^1.27.1" - }, - "devDependencies": { - "@playwright/test": "^1.27.1" - } - }, - "node_modules/@playwright/test": { - "version": "1.27.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.27.1.tgz", - "integrity": "sha512-mrL2q0an/7tVqniQQF6RBL2saskjljXzqNcCOVMUjRIgE6Y38nCNaP+Dc2FBW06bcpD3tqIws/HT9qiMHbNU0A==", - "dev": true, - "dependencies": { - "@types/node": "*", - "playwright-core": "1.27.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@types/node": { - "version": "18.11.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.7.tgz", - "integrity": "sha512-LhFTglglr63mNXUSRYD8A+ZAIu5sFqNJ4Y2fPuY7UlrySJH87rRRlhtVmMHplmfk5WkoJGmDjE9oiTfyX94CpQ==", - "dev": true - }, - "node_modules/playwright-core": { - "version": "1.27.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.27.1.tgz", - "integrity": "sha512-9EmeXDncC2Pmp/z+teoVYlvmPWUC6ejSSYZUln7YaP89Z6lpAaiaAnqroUt/BoLo8tn7WYShcfaCh+xofZa44Q==", - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=14" - } - } - }, - "dependencies": { - "@playwright/test": { - "version": "1.27.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.27.1.tgz", - "integrity": "sha512-mrL2q0an/7tVqniQQF6RBL2saskjljXzqNcCOVMUjRIgE6Y38nCNaP+Dc2FBW06bcpD3tqIws/HT9qiMHbNU0A==", - "dev": true, - "requires": { - "@types/node": "*", - "playwright-core": "1.27.1" - } - }, - "@types/node": { - "version": "18.11.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.7.tgz", - "integrity": "sha512-LhFTglglr63mNXUSRYD8A+ZAIu5sFqNJ4Y2fPuY7UlrySJH87rRRlhtVmMHplmfk5WkoJGmDjE9oiTfyX94CpQ==", - "dev": true - }, - "playwright-core": { - "version": "1.27.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.27.1.tgz", - "integrity": "sha512-9EmeXDncC2Pmp/z+teoVYlvmPWUC6ejSSYZUln7YaP89Z6lpAaiaAnqroUt/BoLo8tn7WYShcfaCh+xofZa44Q==" - } - } -} diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..e262eef --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,26 @@ +# EC-CUBE 本体に組み込んだ状態 (Docker コンテナ内) で実行する前提の設定. +# bootstrapFiles / objectManagerLoader は本体側の絶対パス (/var/www/html) を参照する. +# 実行例: +# docker compose ... run --rm --no-deps --entrypoint bash ec-cube \ +# -c 'cd /var/www/plugin && /var/www/html/vendor/bin/phpstan analyse' +parameters: + level: 6 + bootstrapFiles: + - /var/www/html/vendor/autoload.php + doctrine: + objectManagerLoader: /var/www/html/tests/object-manager.php + ormRepositoryClass: Eccube\Repository\AbstractRepository + excludePaths: + - vendor/* + - node_modules/* + paths: + - Controller + - Entity + - Form + - Repository + - Service + - Util + - PluginManager.php + - SamplePaymentEvent.php + - SamplePaymentNav.php + - SamplePaymentTwigBlock.php diff --git a/tests/guest_convini.test.ts b/tests/guest_convini.test.ts index 1f4f4eb..73fc19c 100644 --- a/tests/guest_convini.test.ts +++ b/tests/guest_convini.test.ts @@ -8,10 +8,9 @@ test('test', async ({ page }) => { await expect(page).toHaveURL('/products/list?category_id=2'); await page.locator('li:has-text("チェリーアイスサンド ¥3,080 数量 カートに入れる")').getByRole('button', { name: 'カートに入れる' }).click(); - // XXX 何故か headless で動かない - // await expect(page.getByText('カートに追加しました。')).toBeVisible(); - // await page.getByRole('link', { name: 'カートへ進む' }).click(); - await expect(page).toHaveURL('/cart'); + // EC-CUBE 4.4 ではカートボタンが AJAX リクエストを送るため完了を待ってから遷移 + await page.waitForLoadState('networkidle'); + await page.goto('/cart'); await page.getByRole('link', { name: 'レジに進む' }).click(); await expect(page).toHaveURL('/shopping/login'); diff --git a/tests/guest_credit_link.test.ts b/tests/guest_credit_link.test.ts index a6f576b..3922047 100644 --- a/tests/guest_credit_link.test.ts +++ b/tests/guest_credit_link.test.ts @@ -9,9 +9,9 @@ test('test', async ({ page }) => { await page.locator('li:has-text("チェリーアイスサンド ¥3,080 数量 カートに入れる")').getByRole('button', { name: 'カートに入れる' }).click(); - // XXX 何故か headless で動かない - // await page.getByRole('link', { name: 'カートへ進む' }).click(); - // await expect(page).toHaveURL('/cart'); + // EC-CUBE 4.4 ではカートボタンが AJAX リクエストを送るため完了を待ってから遷移 + await page.waitForLoadState('networkidle'); + await page.goto('/cart'); await page.getByRole('link', { name: 'レジに進む' }).click(); await expect(page).toHaveURL('/shopping/login'); diff --git a/tests/guest_credit_token.test.ts b/tests/guest_credit_token.test.ts index 2aeb384..3c78087 100644 --- a/tests/guest_credit_token.test.ts +++ b/tests/guest_credit_token.test.ts @@ -9,9 +9,9 @@ test('test', async ({ page }) => { await page.locator('li:has-text("チェリーアイスサンド ¥3,080 数量 カートに入れる")').getByRole('button', { name: 'カートに入れる' }).click(); - // XXX 何故か headless で動かない - // await page.getByRole('link', { name: 'カートへ進む' }).click(); - // await expect(page).toHaveURL('/cart'); + // EC-CUBE 4.4 ではカートボタンが AJAX リクエストを送るため完了を待ってから遷移 + await page.waitForLoadState('networkidle'); + await page.goto('/cart'); await page.getByRole('link', { name: 'レジに進む' }).click(); await expect(page).toHaveURL('/shopping/login'); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..0916e55 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,29 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@playwright/test@^1.27.1": + version "1.48.2" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.48.2.tgz#87dd40633f980872283404c8142a65744d3f13d6" + integrity sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw== + dependencies: + playwright "1.48.2" + +fsevents@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +playwright-core@1.48.2, playwright-core@^1.27.1: + version "1.48.2" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.48.2.tgz#cd76ed8af61690edef5c05c64721c26a8db2f3d7" + integrity sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA== + +playwright@1.48.2: + version "1.48.2" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.48.2.tgz#fca45ae8abdc34835c715718072aaff7e305167e" + integrity sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ== + dependencies: + playwright-core "1.48.2" + optionalDependencies: + fsevents "2.3.2" From e25532eb9f25e0e1d55ad550fd908b9c36bba978 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 24 Jun 2026 14:49:37 +0900 Subject: [PATCH 2/8] =?UTF-8?q?refactor!:=20=E3=83=97=E3=83=A9=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=20Sample?= =?UTF-8?q?Payment42=20=E3=81=8B=E3=82=89=20SamplePayment44=20=E3=81=B8?= =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EC-CUBE 4.4 対応に合わせ、プラグインの識別子をバージョンに揃える。 - PHP 名前空間 Plugin\SamplePayment42 → Plugin\SamplePayment44 - Twig 名前空間 @SamplePayment42 → @SamplePayment44 - composer パッケージ名 ec-cube/samplepayment42 → ec-cube/samplepayment44 - プラグインコード (extra.code) と docker-compose.dev.yml の require/enable を更新 - composer.json version を 2.0.0 → 3.0.0 に更新 DB スキーマ (plg_sample_payment_*, dtb_order.sample_payment_* カラム) と 翻訳キー (sample_payment.*)・ルート名は snake_case のため不変。 BREAKING CHANGE: composer パッケージ名とプラグインコードが変わるため、 app/Plugin/SamplePayment44 として再インストール・再有効化が必要。 Co-Authored-By: Claude Opus 4.8 (1M context) --- CLAUDE.md | 8 +-- Controller/Admin/ConfigController.php | 8 +-- Controller/Admin/OrderController.php | 2 +- Controller/Admin/PaymentStatusController.php | 8 +-- Controller/MypageController.php | 6 +-- Controller/PaymentCompanyController.php | 4 +- Controller/PaymentController.php | 12 ++--- Entity/Config.php | 4 +- Entity/CustomerTrait.php | 2 +- Entity/CvsPaymentStatus.php | 4 +- Entity/CvsType.php | 4 +- Entity/OrderTrait.php | 2 +- Entity/PaymentStatus.php | 4 +- Form/Extension/CreditCardExtention.php | 2 +- Form/Extension/CvsExtension.php | 8 +-- Form/Type/Admin/ConfigType.php | 4 +- Form/Type/Admin/SearchPaymentType.php | 4 +- PluginManager.php | 20 ++++---- README.md | 52 ++++++++++---------- Repository/ConfigRepository.php | 4 +- Repository/CvsPaymentStatusRepository.php | 4 +- Repository/CvsTypeRepository.php | 4 +- Repository/PaymentStatusRepository.php | 4 +- Resource/template/credit.twig | 2 +- Resource/template/credit_confirm.twig | 2 +- SamplePaymentEvent.php | 8 +-- SamplePaymentNav.php | 2 +- SamplePaymentTwigBlock.php | 6 +-- Service/Method/Convenience.php | 6 +-- Service/Method/CreditCard.php | 6 +-- Service/Method/LinkCreditCard.php | 6 +-- composer.json | 6 +-- docker-compose.dev.yml | 4 +- 33 files changed, 111 insertions(+), 111 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 7d45420..1083ee8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ EC-CUBE 4 系の**決済プラグイン実装サンプル**。実際の決済代 - **トークン型クレジットカード決済** (`CreditCard`) — トークンを受け取り自サイト内で完結する方式 - **コンビニ決済** (`Convenience`) — 入金待ちステータスを持つ方式 -プラグインコードは `SamplePayment42`、Composer パッケージ名は `ec-cube/samplepayment42`。コード中の Twig 名前空間・クラス名前空間・トランス キーはすべて `SamplePayment42` 接頭辞を使う。 +プラグインコードは `SamplePayment44`、Composer パッケージ名は `ec-cube/samplepayment44`。コード中の Twig 名前空間・クラス名前空間・トランス キーはすべて `SamplePayment44` 接頭辞を使う。 ### ブランチ運用 @@ -97,11 +97,11 @@ Plugin\: exclude: '../../../app/Plugin/*/{Entity,Resource,ServiceProvider,Tests,Codeception,DoctrineMigrations}' ``` -`app/Plugin/SamplePayment42/` 直下のすべての `*.php` が「サービスクラス」として読み込まれるため、ルートに `rector.php` を置くと Symfony が `Plugin\SamplePayment42\rector` クラスを期待し、見つからず **EC-CUBE 全体が 500 エラー**になる (実際に遭遇したエラー): +`app/Plugin/SamplePayment44/` 直下のすべての `*.php` が「サービスクラス」として読み込まれるため、ルートに `rector.php` を置くと Symfony が `Plugin\SamplePayment44\rector` クラスを期待し、見つからず **EC-CUBE 全体が 500 エラー**になる (実際に遭遇したエラー): ``` -Expected to find class "Plugin\SamplePayment42\rector" in file -".../app/Plugin/SamplePayment42/rector.php" while importing services from +Expected to find class "Plugin\SamplePayment44\rector" in file +".../app/Plugin/SamplePayment44/rector.php" while importing services from resource "../../../app/Plugin/*", but it was not found! ``` diff --git a/Controller/Admin/ConfigController.php b/Controller/Admin/ConfigController.php index f431248..9107576 100644 --- a/Controller/Admin/ConfigController.php +++ b/Controller/Admin/ConfigController.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller\Admin; +namespace Plugin\SamplePayment44\Controller\Admin; use Eccube\Controller\AbstractController; -use Plugin\SamplePayment42\Form\Type\Admin\ConfigType; -use Plugin\SamplePayment42\Repository\ConfigRepository; +use Plugin\SamplePayment44\Form\Type\Admin\ConfigType; +use Plugin\SamplePayment44\Repository\ConfigRepository; use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; @@ -32,7 +32,7 @@ public function __construct(protected ConfigRepository $configRepository) } #[Route(path: '/%eccube_admin_route%/sample_payment/config', name: 'sample_payment_admin_config')] - #[Template(template: '@SamplePayment42/admin/config.twig')] + #[Template(template: '@SamplePayment44/admin/config.twig')] public function index(Request $request) { $Config = $this->configRepository->get(); diff --git a/Controller/Admin/OrderController.php b/Controller/Admin/OrderController.php index 80a7e11..c5aed0b 100644 --- a/Controller/Admin/OrderController.php +++ b/Controller/Admin/OrderController.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller\Admin; +namespace Plugin\SamplePayment44\Controller\Admin; use Eccube\Controller\AbstractController; use Eccube\Entity\Order; diff --git a/Controller/Admin/PaymentStatusController.php b/Controller/Admin/PaymentStatusController.php index 8613372..734621f 100644 --- a/Controller/Admin/PaymentStatusController.php +++ b/Controller/Admin/PaymentStatusController.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller\Admin; +namespace Plugin\SamplePayment44\Controller\Admin; use Eccube\Common\Constant; use Eccube\Controller\AbstractController; @@ -20,8 +20,8 @@ use Eccube\Repository\OrderRepository; use Eccube\Util\FormUtil; use Knp\Component\Pager\PaginatorInterface; -use Plugin\SamplePayment42\Form\Type\Admin\SearchPaymentType; -use Plugin\SamplePayment42\Repository\PaymentStatusRepository; +use Plugin\SamplePayment44\Form\Type\Admin\SearchPaymentType; +use Plugin\SamplePayment44\Repository\PaymentStatusRepository; use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -55,7 +55,7 @@ public function __construct(protected PaymentStatusRepository $paymentStatusRepo */ #[Route(path: '/%eccube_admin_route%/sample_payment/payment_status', name: 'sample_payment_admin_payment_status')] #[Route(path: '/%eccube_admin_route%/sample_payment/payment_status/{page_no}', requirements: ['page_no' => '\d+'], name: 'sample_payment_admin_payment_status_pageno')] - #[Template(template: '@SamplePayment42/admin/payment_status.twig')] + #[Template(template: '@SamplePayment44/admin/payment_status.twig')] public function index(Request $request, $page_no = null): array { $searchForm = $this->createForm(SearchPaymentType::class); diff --git a/Controller/MypageController.php b/Controller/MypageController.php index b69b765..57329a6 100644 --- a/Controller/MypageController.php +++ b/Controller/MypageController.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller; +namespace Plugin\SamplePayment44\Controller; use Eccube\Controller\AbstractController; use Symfony\Bridge\Twig\Attribute\Template; @@ -22,7 +22,7 @@ class MypageController extends AbstractController { #[Route(path: '/mypage/sample_payment_card_info', name: 'sample_payment_mypage_card_info', methods: ['GET', 'POST'])] - #[Template(template: '@SamplePayment42/card_info.twig')] + #[Template(template: '@SamplePayment44/card_info.twig')] public function index(Request $request) { $builder = $this->formFactory->createBuilder(); @@ -43,7 +43,7 @@ public function index(Request $request) } #[Route(path: '/mypage/sample_payment_card_info_complete', name: 'sample_payment_mypage_card_info_complete', methods: ['GET'])] - #[Template(template: '@SamplePayment42/card_info_complete.twig')] + #[Template(template: '@SamplePayment44/card_info_complete.twig')] public function complete(): array { return []; diff --git a/Controller/PaymentCompanyController.php b/Controller/PaymentCompanyController.php index af25e75..0ea8855 100755 --- a/Controller/PaymentCompanyController.php +++ b/Controller/PaymentCompanyController.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller; +namespace Plugin\SamplePayment44\Controller; use Eccube\Controller\AbstractController; use Symfony\Bridge\Twig\Attribute\Template; @@ -28,7 +28,7 @@ class PaymentCompanyController extends AbstractController * 決済サーバのカード入力画面. */ #[Route(path: '/payment_company')] - #[Template(template: '@SamplePayment42/dummy.twig')] + #[Template(template: '@SamplePayment44/dummy.twig')] public function index(Request $request) { $orderNo = $request->get('no'); diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 43f972e..9f7c561 100755 --- a/Controller/PaymentController.php +++ b/Controller/PaymentController.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller; +namespace Plugin\SamplePayment44\Controller; use Eccube\Controller\AbstractController; use Eccube\Entity\Master\OrderStatus; @@ -22,11 +22,11 @@ use Eccube\Service\OrderStateMachine; use Eccube\Service\PurchaseFlow\PurchaseContext; use Eccube\Service\PurchaseFlow\PurchaseFlow; -use Plugin\SamplePayment42\Entity\CvsPaymentStatus; -use Plugin\SamplePayment42\Entity\PaymentStatus; -use Plugin\SamplePayment42\Repository\CvsPaymentStatusRepository; -use Plugin\SamplePayment42\Repository\PaymentStatusRepository; -use Plugin\SamplePayment42\Service\Method\Convenience; +use Plugin\SamplePayment44\Entity\CvsPaymentStatus; +use Plugin\SamplePayment44\Entity\PaymentStatus; +use Plugin\SamplePayment44\Repository\CvsPaymentStatusRepository; +use Plugin\SamplePayment44\Repository\PaymentStatusRepository; +use Plugin\SamplePayment44\Service\Method\Convenience; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/Entity/Config.php b/Entity/Config.php index 98cb734..7686f1b 100644 --- a/Entity/Config.php +++ b/Entity/Config.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Entity; +namespace Plugin\SamplePayment44\Entity; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use Plugin\SamplePayment42\Repository\ConfigRepository; +use Plugin\SamplePayment44\Repository\ConfigRepository; /** * Config diff --git a/Entity/CustomerTrait.php b/Entity/CustomerTrait.php index 583b04f..6f60674 100644 --- a/Entity/CustomerTrait.php +++ b/Entity/CustomerTrait.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Entity; +namespace Plugin\SamplePayment44\Entity; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; diff --git a/Entity/CvsPaymentStatus.php b/Entity/CvsPaymentStatus.php index ff9da25..f41bbea 100644 --- a/Entity/CvsPaymentStatus.php +++ b/Entity/CvsPaymentStatus.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Entity; +namespace Plugin\SamplePayment44\Entity; use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\Master\AbstractMasterEntity; -use Plugin\SamplePayment42\Repository\CvsPaymentStatusRepository; +use Plugin\SamplePayment44\Repository\CvsPaymentStatusRepository; /** * CvsPaymentStatus diff --git a/Entity/CvsType.php b/Entity/CvsType.php index 8d650ac..01b06f8 100644 --- a/Entity/CvsType.php +++ b/Entity/CvsType.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Entity; +namespace Plugin\SamplePayment44\Entity; use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\Master\AbstractMasterEntity; -use Plugin\SamplePayment42\Repository\CvsTypeRepository; +use Plugin\SamplePayment44\Repository\CvsTypeRepository; /** * コンビニ種別 diff --git a/Entity/OrderTrait.php b/Entity/OrderTrait.php index 703ae5b..31ebb5f 100644 --- a/Entity/OrderTrait.php +++ b/Entity/OrderTrait.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Entity; +namespace Plugin\SamplePayment44\Entity; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; diff --git a/Entity/PaymentStatus.php b/Entity/PaymentStatus.php index b3c6f6f..75852b1 100644 --- a/Entity/PaymentStatus.php +++ b/Entity/PaymentStatus.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Entity; +namespace Plugin\SamplePayment44\Entity; use Doctrine\ORM\Mapping as ORM; use Eccube\Entity\Master\AbstractMasterEntity; -use Plugin\SamplePayment42\Repository\PaymentStatusRepository; +use Plugin\SamplePayment44\Repository\PaymentStatusRepository; /** * PaymentStatus diff --git a/Form/Extension/CreditCardExtention.php b/Form/Extension/CreditCardExtention.php index c4051da..91a4c28 100644 --- a/Form/Extension/CreditCardExtention.php +++ b/Form/Extension/CreditCardExtention.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Form\Extension; +namespace Plugin\SamplePayment44\Form\Extension; use Eccube\Entity\Order; use Eccube\Form\Type\Shopping\OrderType; diff --git a/Form/Extension/CvsExtension.php b/Form/Extension/CvsExtension.php index 87cc3d6..4865205 100644 --- a/Form/Extension/CvsExtension.php +++ b/Form/Extension/CvsExtension.php @@ -11,15 +11,15 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Form\Extension; +namespace Plugin\SamplePayment44\Form\Extension; use Doctrine\ORM\EntityRepository; use Eccube\Entity\Order; use Eccube\Form\Type\Shopping\OrderType; use Eccube\Repository\PaymentRepository; -use Plugin\SamplePayment42\Entity\CvsType; -use Plugin\SamplePayment42\Repository\CvsTypeRepository; -use Plugin\SamplePayment42\Service\Method\Convenience; +use Plugin\SamplePayment44\Entity\CvsType; +use Plugin\SamplePayment44\Repository\CvsTypeRepository; +use Plugin\SamplePayment44\Service\Method\Convenience; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\FormBuilderInterface; diff --git a/Form/Type/Admin/ConfigType.php b/Form/Type/Admin/ConfigType.php index f2b96a1..81a54f4 100644 --- a/Form/Type/Admin/ConfigType.php +++ b/Form/Type/Admin/ConfigType.php @@ -11,9 +11,9 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Form\Type\Admin; +namespace Plugin\SamplePayment44\Form\Type\Admin; -use Plugin\SamplePayment42\Entity\Config; +use Plugin\SamplePayment44\Entity\Config; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\UrlType; diff --git a/Form/Type/Admin/SearchPaymentType.php b/Form/Type/Admin/SearchPaymentType.php index f3b800d..f4eeda9 100644 --- a/Form/Type/Admin/SearchPaymentType.php +++ b/Form/Type/Admin/SearchPaymentType.php @@ -11,12 +11,12 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Form\Type\Admin; +namespace Plugin\SamplePayment44\Form\Type\Admin; use Doctrine\ORM\EntityRepository; use Eccube\Form\Type\Master\OrderStatusType; use Eccube\Form\Type\Master\PaymentType; -use Plugin\SamplePayment42\Entity\PaymentStatus; +use Plugin\SamplePayment44\Entity\PaymentStatus; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/PluginManager.php b/PluginManager.php index 08e97d7..e613d6f 100644 --- a/PluginManager.php +++ b/PluginManager.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42; +namespace Plugin\SamplePayment44; use Doctrine\ORM\EntityManagerInterface; use Eccube\Entity\Layout; @@ -19,13 +19,13 @@ use Eccube\Entity\PageLayout; use Eccube\Entity\Payment; use Eccube\Plugin\AbstractPluginManager; -use Plugin\SamplePayment42\Entity\Config; -use Plugin\SamplePayment42\Entity\CvsPaymentStatus; -use Plugin\SamplePayment42\Entity\CvsType; -use Plugin\SamplePayment42\Entity\PaymentStatus; -use Plugin\SamplePayment42\Service\Method\Convenience; -use Plugin\SamplePayment42\Service\Method\CreditCard; -use Plugin\SamplePayment42\Service\Method\LinkCreditCard; +use Plugin\SamplePayment44\Entity\Config; +use Plugin\SamplePayment44\Entity\CvsPaymentStatus; +use Plugin\SamplePayment44\Entity\CvsType; +use Plugin\SamplePayment44\Entity\PaymentStatus; +use Plugin\SamplePayment44\Service\Method\Convenience; +use Plugin\SamplePayment44\Service\Method\CreditCard; +use Plugin\SamplePayment44\Service\Method\LinkCreditCard; use Psr\Container\ContainerInterface; class PluginManager extends AbstractPluginManager @@ -34,12 +34,12 @@ class PluginManager extends AbstractPluginManager [ 'name' => 'カード情報変更', 'url' => 'sample_payment_mypage_card_info', - 'filename' => 'SamplePayment42/Resource/template/card_info.twig', + 'filename' => 'SamplePayment44/Resource/template/card_info.twig', ], [ 'name' => 'カード情報変更(完了)', 'url' => 'sample_payment_mypage_card_info_complete', - 'filename' => 'SamplePayment42/Resource/template/card_info_complete.twig', + 'filename' => 'SamplePayment44/Resource/template/card_info_complete.twig', ], ]; diff --git a/README.md b/README.md index 709646e..d55d0b8 100644 --- a/README.md +++ b/README.md @@ -441,36 +441,36 @@ twigのソースコード内でメッセージを使用する場合には `trans ## ファイルごとの概要 -### [Plugin\SamplePayment42\Service\Method\CreditCard](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Service/Method/CreditCard.php) +### [Plugin\SamplePayment44\Service\Method\CreditCard](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Service/Method/CreditCard.php) トークン型クレジットカード払い用のビジネスロジッククラス -### [Plugin\SamplePayment42\Service\Method\LinkCreditCard](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Service/Method/LinkCreditCard.php) +### [Plugin\SamplePayment44\Service\Method\LinkCreditCard](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Service/Method/LinkCreditCard.php) リンク型クレジットカード払い用のビジネスロジッククラス -### [Plugin\SamplePayment42\Service\Method\Convenience](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Service/Method/Convenience.php) +### [Plugin\SamplePayment44\Service\Method\Convenience](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Service/Method/Convenience.php) コンビニ決済用のビジネスロジッククラス -### [Plugin\SamplePayment42\Controller\Admin\ConfigController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/Admin/ConfigController.php) +### [Plugin\SamplePayment44\Controller\Admin\ConfigController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/Admin/ConfigController.php) プラグイン設定画面のコントローラクラス。 -### [Plugin\SamplePayment42\Controller\Admin\OrderController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/Admin/OrderController.php) +### [Plugin\SamplePayment44\Controller\Admin\OrderController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/Admin/OrderController.php) 受注編集画面から Ajax で通信するコントローラクラス。 主に管理画面の操作と連動して、決済サーバーとの通信を実装する -### [Plugin\SamplePayment42\Controller\Admin\PaymentStatusController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/Admin/PaymentStatusController.php) +### [Plugin\SamplePayment44\Controller\Admin\PaymentStatusController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/Admin/PaymentStatusController.php) 決済ステータス一括変更画面のコントローラクラス -### [Plugin\SamplePayment42\Controller\PaymentCompanyController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/PaymentCompanyController.php) +### [Plugin\SamplePayment44\Controller\PaymentCompanyController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/PaymentCompanyController.php) リンク型決済のダミー画面。決済会社のカード入力フォームに相当する。 -### [Plugin\SamplePayment42\Controller\PaymentController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/PaymentController.php) +### [Plugin\SamplePayment44\Controller\PaymentController](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Controller/PaymentController.php) リンク型決済およびコンビニ決済と連携するためのコントローラクラス。 @@ -480,78 +480,78 @@ twigのソースコード内でメッセージを使用する場合には `trans などを実装する。 -### [Plugin\SamplePayment42\Entity\Config](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/Config.php) +### [Plugin\SamplePayment44\Entity\Config](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/Config.php) プラグイン設定画面のエンティティクラス。 -### [Plugin\SamplePayment42\Entity\CustomerTrait](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/CustomerTrait.php) +### [Plugin\SamplePayment44\Entity\CustomerTrait](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/CustomerTrait.php) Customer 拡張用のトレイト。決済会社から取得した、クレジットカード等の JSON データを格納する。 -### [Plugin\SamplePayment42\Entity\OrderTrait](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/OrderTrait.php) +### [Plugin\SamplePayment44\Entity\OrderTrait](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/OrderTrait.php) Order 拡張用のトレイト。クレジットカードのトークンや、決済ステータス、コンビニ種別などを格納する。 -### [Plugin\SamplePayment42\Entity\PaymentStatus](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/PaymentStatus.php) +### [Plugin\SamplePayment44\Entity\PaymentStatus](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/PaymentStatus.php) 決済ステータスのエンティティクラス。 -### [Plugin\SamplePayment42\Entity\CvsPaymentStatus](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/CvsPaymentStatus.php) +### [Plugin\SamplePayment44\Entity\CvsPaymentStatus](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/CvsPaymentStatus.php) コンビニ決済の決済ステータスのエンティティクラス。 -### [Plugin\SamplePayment42\Entity\CvsType](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/CvsType.php) +### [Plugin\SamplePayment44\Entity\CvsType](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Entity/CvsType.php) コンビニの種別のエンティティクラス。 -### [Plugin\SamplePayment42\Event](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Event.php) +### [Plugin\SamplePayment44\Event](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Event.php) プラグインで使用する `EventSubscriber` 管理画面のテンプレートを拡張するために使用している。 -### [Plugin\SamplePayment42\Form\Extension\CreditCardExtention](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Extension/CreditCardExtention.php) +### [Plugin\SamplePayment44\Form\Extension\CreditCardExtention](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Extension/CreditCardExtention.php) クレジットカード払い用のフォームエクステンション。 ご注文情報入力画面に、クレジットカード入力フォームを実装するために使用する。 -### [Plugin\SamplePayment42\Form\Extension\CvsExtension](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Extension/CvsExtension.php) +### [Plugin\SamplePayment44\Form\Extension\CvsExtension](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Extension/CvsExtension.php) コンビニ決済用のフォームエクステンション。 ご注文情報入力画面に、コンビニ選択フォームを実装するために使用する。 -### [Plugin\SamplePayment42\Form\Type\Admin\ConfigType](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Type/Admin/ConfigType.php) +### [Plugin\SamplePayment44\Form\Type\Admin\ConfigType](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Type/Admin/ConfigType.php) プラグイン設定画面用のフォームタイプ -### [Plugin\SamplePayment42\Form\Type\Admin\SearchPaymentType](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Type/Admin/SearchPaymentType.php) +### [Plugin\SamplePayment44\Form\Type\Admin\SearchPaymentType](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Form/Type/Admin/SearchPaymentType.php) 決済ステータス一括変更画面用のフォームタイプ -### [Plugin\SamplePayment42\Nav](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Nav.php) +### [Plugin\SamplePayment44\Nav](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Nav.php) 管理画面ナビ拡張用クラス -### [Plugin\SamplePayment42\PluginManager](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/PluginManager.php) +### [Plugin\SamplePayment44\PluginManager](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/PluginManager.php) PluginManager クラス。 install/uninstall/enable/disable の処理を実装する。 -### [Plugin\SamplePayment42\PluginManager\Repository\ConfigRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/ConfigRepository.php) +### [Plugin\SamplePayment44\PluginManager\Repository\ConfigRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/ConfigRepository.php) プラグイン設定画面用のリポジトリクラス -### [Plugin\SamplePayment42\PluginManager\Repository\PaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/PaymentStatusRepository.php) +### [Plugin\SamplePayment44\PluginManager\Repository\PaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/PaymentStatusRepository.php) 決済ステータス用のリポジトリクラス -### [Plugin\SamplePayment42\PluginManager\Repository\CvsPaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/CvsPaymentStatusRepository.php) +### [Plugin\SamplePayment44\PluginManager\Repository\CvsPaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/CvsPaymentStatusRepository.php) コンビニ決済ステータス用のリポジトリクラス -### [Plugin\SamplePayment42\PluginManager\Repository\CvsTypeRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/CvsTypeRepository.php) +### [Plugin\SamplePayment44\PluginManager\Repository\CvsTypeRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/CvsTypeRepository.php) コンビニ種別用のリポジトリクラス -### [Plugin\SamplePayment42\TwigBlock](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/TwigBlock.php) +### [Plugin\SamplePayment44\TwigBlock](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/TwigBlock.php) TwigBlock定義用クラス diff --git a/Repository/ConfigRepository.php b/Repository/ConfigRepository.php index 39f7f19..60f00af 100644 --- a/Repository/ConfigRepository.php +++ b/Repository/ConfigRepository.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Repository; +namespace Plugin\SamplePayment44\Repository; use Doctrine\Persistence\ManagerRegistry as RegistryInterface; use Eccube\Repository\AbstractRepository; -use Plugin\SamplePayment42\Entity\Config; +use Plugin\SamplePayment44\Entity\Config; class ConfigRepository extends AbstractRepository { diff --git a/Repository/CvsPaymentStatusRepository.php b/Repository/CvsPaymentStatusRepository.php index ad35c04..53d16b6 100644 --- a/Repository/CvsPaymentStatusRepository.php +++ b/Repository/CvsPaymentStatusRepository.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Repository; +namespace Plugin\SamplePayment44\Repository; use Doctrine\Persistence\ManagerRegistry as RegistryInterface; use Eccube\Repository\AbstractRepository; -use Plugin\SamplePayment42\Entity\CvsPaymentStatus; +use Plugin\SamplePayment44\Entity\CvsPaymentStatus; class CvsPaymentStatusRepository extends AbstractRepository { diff --git a/Repository/CvsTypeRepository.php b/Repository/CvsTypeRepository.php index 7f0e33b..cb8898c 100644 --- a/Repository/CvsTypeRepository.php +++ b/Repository/CvsTypeRepository.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Repository; +namespace Plugin\SamplePayment44\Repository; use Doctrine\Persistence\ManagerRegistry as RegistryInterface; use Eccube\Repository\AbstractRepository; -use Plugin\SamplePayment42\Entity\CvsType; +use Plugin\SamplePayment44\Entity\CvsType; class CvsTypeRepository extends AbstractRepository { diff --git a/Repository/PaymentStatusRepository.php b/Repository/PaymentStatusRepository.php index 1a57a4f..bd89c2d 100644 --- a/Repository/PaymentStatusRepository.php +++ b/Repository/PaymentStatusRepository.php @@ -11,11 +11,11 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Repository; +namespace Plugin\SamplePayment44\Repository; use Doctrine\Persistence\ManagerRegistry as RegistryInterface; use Eccube\Repository\AbstractRepository; -use Plugin\SamplePayment42\Entity\PaymentStatus; +use Plugin\SamplePayment44\Entity\PaymentStatus; class PaymentStatusRepository extends AbstractRepository { diff --git a/Resource/template/credit.twig b/Resource/template/credit.twig index 49e807f..d370bc6 100644 --- a/Resource/template/credit.twig +++ b/Resource/template/credit.twig @@ -3,7 +3,7 @@ $(".ec-orderPayment").last().after($("#credit").detach()); }); -{% if Order.Payment.getMethodClass == 'Plugin\\SamplePayment42\\Service\\Method\\CreditCard' %} +{% if Order.Payment.getMethodClass == 'Plugin\\SamplePayment44\\Service\\Method\\CreditCard' %}

カード(暫定実装)

diff --git a/Resource/template/credit_confirm.twig b/Resource/template/credit_confirm.twig index 057f9d4..b5e36d6 100644 --- a/Resource/template/credit_confirm.twig +++ b/Resource/template/credit_confirm.twig @@ -1,4 +1,4 @@ -{% if Order.Payment.method_class == 'Plugin\\SamplePayment42\\Service\\Method\\CreditCard' %} +{% if Order.Payment.method_class == 'Plugin\\SamplePayment44\\Service\\Method\\CreditCard' %}