diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index f046263..1a54546 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,7 +1,7 @@ name: Playwright Tests on: push: - branches: [ '4.2' ] + branches: [ '4.4' ] pull_request: paths: - '**' @@ -10,13 +10,15 @@ jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest + env: + TAG: ${{ matrix.tag }} strategy: fail-fast: false matrix: - operating-system: [ ubuntu-20.04 ] + tag: [ '8.2-apache-4.4', '8.3-apache-4.4', '8.4-apache-4.4', '8.5-apache-4.4' ] db: [ mysql, pgsql, sqlite3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup environment if: matrix.db != 'sqlite3' env: @@ -24,24 +26,22 @@ jobs: run: echo "COMPOSE_FILE=docker-compose.yml:docker-compose.${DB_TYPE}.yml:docker-compose.dev.yml" >> $GITHUB_ENV - name: Setup environment if: matrix.db == 'sqlite3' - env: - DB_TYPE: ${{ matrix.db }} run: echo "COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml" >> $GITHUB_ENV - name: Setup EC-CUBE run: docker compose up -d --wait - name: Install dependencies - run: npm ci + run: yarn install --frozen-lockfile - name: Install Playwright Browsers - run: npx playwright install + run: yarn playwright install - run: docker compose logs ec-cube - name: Run Playwright tests env: CI: 1 FORCE_COLOR: 1 run: yarn playwright test - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: - name: playwright-report + name: playwright-report-${{ matrix.tag }}-${{ matrix.db }} path: playwright-report/ retention-days: 30 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..1083ee8 --- /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`) — 入金待ちステータスを持つ方式 + +プラグインコードは `SamplePayment44`、Composer パッケージ名は `ec-cube/samplepayment44`。コード中の Twig 名前空間・クラス名前空間・トランス キーはすべて `SamplePayment44` 接頭辞を使う。 + +### ブランチ運用 + +ブランチ名が対応する 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/SamplePayment44/` 直下のすべての `*.php` が「サービスクラス」として読み込まれるため、ルートに `rector.php` を置くと Symfony が `Plugin\SamplePayment44\rector` クラスを期待し、見つからず **EC-CUBE 全体が 500 エラー**になる (実際に遭遇したエラー): + +``` +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! +``` + +上記 `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..9107576 100644 --- a/Controller/Admin/ConfigController.php +++ b/Controller/Admin/ConfigController.php @@ -11,36 +11,28 @@ * 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 Symfony\Component\Routing\Annotation\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +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; 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: '@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 43d7584..45e0463 100644 --- a/Controller/Admin/OrderController.php +++ b/Controller/Admin/OrderController.php @@ -11,22 +11,22 @@ * 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; -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,17 +41,38 @@ 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()) { // 通信処理 + // 決済金額の計算は, 浮動小数点演算の丸め誤差を避けるため bcmath を使用する. + // EC-CUBE 本体も金額計算を bcmath で行っており, bcmath 拡張が無い環境では + // nanasess/bcmath-polyfill が関数を提供する (本体が依存に含むため別途要求は不要). + // 値は文字列で受け渡し, 第3引数 scale で小数桁を明示するのが本体の慣習. + // 以下はコンビニ決済手数料を例にした加減乗除 (bcadd/bcsub/bcmul/bcdiv) のサンプル. + $paymentTotal = $Order->getPaymentTotal(); // 本体の getPaymentTotal(): string + + // 乗算・除算: 手数料 = 決済総額 × 手数料率(3.5%) ÷ 100 (小数以下切り捨て) + $feeRate = '3.5'; + $fee = bcdiv(bcmul($paymentTotal, $feeRate, 4), '100', 0); + + // 加算: 手数料を加えた金額 + $totalWithFee = bcadd($paymentTotal, $fee, 0); + + // 減算: キャンペーン割引(固定100円)を差し引いた最終請求額 + $discount = '100'; + $newPrice = bcsub($totalWithFee, $discount, 0); + + // 実際のプラグインでは, ここで決済サーバへ変更後の金額を通知し, + // PurchaseFlow で受注金額を再計算・確定する. + // 本サンプルでは計算結果を返すのみで受注金額は変更しない. + $this->addSuccess('sample_payment.admin.order.change_price.success', 'admin'); - return $this->json([]); + return $this->json(['price' => $newPrice]); } throw new BadRequestHttpException(); diff --git a/Controller/Admin/PaymentStatusController.php b/Controller/Admin/PaymentStatusController.php index efcb6c0..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,36 +20,22 @@ 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 Symfony\Component\Routing\Annotation\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +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; +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: '@SamplePayment44/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..57329a6 100644 --- a/Controller/MypageController.php +++ b/Controller/MypageController.php @@ -5,26 +5,24 @@ * * 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. */ -namespace Plugin\SamplePayment42\Controller; +namespace Plugin\SamplePayment44\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: '@SamplePayment44/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: '@SamplePayment44/card_info_complete.twig')] + public function complete(): array { return []; } diff --git a/Controller/PaymentCompanyController.php b/Controller/PaymentCompanyController.php index 56e69e1..0ea8855 100755 --- a/Controller/PaymentCompanyController.php +++ b/Controller/PaymentCompanyController.php @@ -11,13 +11,13 @@ * file that was distributed with this source code. */ -namespace Plugin\SamplePayment42\Controller; +namespace Plugin\SamplePayment44\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: '@SamplePayment44/dummy.twig')] public function index(Request $request) { $orderNo = $request->get('no'); diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 211868d..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,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 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; 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..7686f1b 100644 --- a/Entity/Config.php +++ b/Entity/Config.php @@ -11,52 +11,49 @@ * 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\SamplePayment44\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..6f60674 100644 --- a/Entity/CustomerTrait.php +++ b/Entity/CustomerTrait.php @@ -11,21 +11,21 @@ * 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 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..f41bbea 100644 --- a/Entity/CvsPaymentStatus.php +++ b/Entity/CvsPaymentStatus.php @@ -11,17 +11,17 @@ * 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\SamplePayment44\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..01b06f8 100644 --- a/Entity/CvsType.php +++ b/Entity/CvsType.php @@ -11,17 +11,17 @@ * 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\SamplePayment44\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..31ebb5f 100644 --- a/Entity/OrderTrait.php +++ b/Entity/OrderTrait.php @@ -11,14 +11,14 @@ * 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 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..75852b1 100644 --- a/Entity/PaymentStatus.php +++ b/Entity/PaymentStatus.php @@ -11,17 +11,17 @@ * 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\SamplePayment44\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..91a4c28 100644 --- a/Form/Extension/CreditCardExtention.php +++ b/Form/Extension/CreditCardExtention.php @@ -11,12 +11,11 @@ * 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; 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..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; @@ -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..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; @@ -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..f4eeda9 100644 --- a/Form/Type/Admin/SearchPaymentType.php +++ b/Form/Type/Admin/SearchPaymentType.php @@ -11,19 +11,19 @@ * 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; 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..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,14 +19,13 @@ 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; -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 @@ -35,16 +34,16 @@ 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', ], ]; - 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/README.md b/README.md index 709646e..cb18b7b 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,19 @@ http://doc4.ec-cube.net/quickstart_install 本サンプルプラグインの場合は以下のようになります。 -`/app/Plugin/SamplePayment` +`/app/Plugin/SamplePayment44` ## コマンドラインインタフェース ### 利用例 - インストール -`bin/console eccube:plugin:install --code=SamplePayment` +`bin/console eccube:plugin:install --code=SamplePayment44` - 有効化 -`bin/console eccube:plugin:enable --code=SamplePayment` +`bin/console eccube:plugin:enable --code=SamplePayment44` - 無効化 -`bin/console eccube:plugin:disable --code=SamplePayment` +`bin/console eccube:plugin:disable --code=SamplePayment44` - 削除 -`bin/console eccube:plugin:uninstall --code=SamplePayment` +`bin/console eccube:plugin:uninstall --code=SamplePayment44` ### プラグインジェネレータ @@ -106,7 +106,7 @@ http://doc4.ec-cube.net/quickstart_install ### ルーティングの追加 -`@Route` アノテーションを付与したクラスファイルを `Controller` 以下に配置することで、サイトに新しいルーティングを追加することが可能です。 +`#[Route]` アトリビュートを付与したクラスファイルを `Controller` 以下に配置することで、サイトに新しいルーティングを追加することが可能です。(EC-CUBE 4.4 / Symfony 7 ではアノテーションは廃止され、PHP アトリビュートを使用します) Controllerファイルについては開発ドキュメント・マニュアルの[Controllerのカスタマイズ](http://doc4.ec-cube.net/customize_controller)ページをご確認ください。 @@ -114,9 +114,9 @@ Controllerファイルについては開発ドキュメント・マニュアル クラスファイルを `Entity` 以下に配置することで新しいEntityを追加可能です。 -traitと `@EntityExtension` アノテーションを使用して、既存Entityのフィールドを拡張可能です。 +traitと `#[EntityExtension]` アトリビュートを使用して、既存Entityのフィールドを拡張可能です。 -また、`@EntityExtension` アノテーションで拡張したフィールドに `@FormAppend` アノテーションを追加することで、フォームを自動生成できます。 +また、`#[EntityExtension]` アトリビュートで拡張したフィールドに `#[FormAppend]` アトリビュートを追加することで、フォームを自動生成できます。 Entityファイルについては開発ドキュメント・マニュアルの[Entityのカスタマイズ](http://doc4.ec-cube.net/customize_entity)ページをご確認ください。 @@ -137,7 +137,7 @@ FormExtensionについては開発ドキュメント・マニュアルの[FormTy ```php class Event implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return ['eventName' => 'methodName']; } @@ -159,7 +159,7 @@ class Event implements EventSubscriberInterface ```php class Nav implements EccubeNav { - public static function getNav() + public static function getNav(): array { return [ 'product' => [ @@ -221,7 +221,7 @@ twig内で変数を使用する場合は、TemplateEventで渡します。 ```php class Event implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'xxx.twig' => 'onXxxTwig', @@ -241,13 +241,13 @@ class Event implements EventSubscriberInterface - 商品購入ページ ```twig -{{ include('@SamplePayment/credit.twig', ignore_missing=true) }} -{{ include('@SamplePayment/cvs.twig', ignore_missing=true) }} +{{ include('@SamplePayment44/credit.twig', ignore_missing=true) }} +{{ include('@SamplePayment44/cvs.twig', ignore_missing=true) }} ``` - 商品購入/ご注文確認ページ ```twig -{{ include('@SamplePayment/credit_confirm.twig', ignore_missing=true) }} -{{ include('@SamplePayment/cvs_confirm.twig', ignore_missing=true) }} +{{ include('@SamplePayment44/credit_confirm.twig', ignore_missing=true) }} +{{ include('@SamplePayment44/cvs_confirm.twig', ignore_missing=true) }} ``` ### 画面への介入について @@ -264,12 +264,10 @@ EC-CUBE4からはTemplateEventに新たな関数を用意し、それを利用 * ここで追加したコードは, 内に出力される * javascriptの読み込みやcssの読み込みに利用する. * - * @param $asset + * @param string $asset * @param bool $include twigファイルとしてincludeするかどうか - * - * @return $this */ -public function addAsset($asset, $include = true) +public function addAsset(string $asset, bool $include = true): static { $this->assets[$asset] = $include; @@ -283,12 +281,10 @@ public function addAsset($asset, $include = true) * * ここで追加したコードは, タグ直前に出力される * - * @param $snippet + * @param string $snippet * @param bool $include twigファイルとしてincludeするかどうか - * - * @return $this */ -public function addSnippet($snippet, $include = true) +public function addSnippet(string $snippet, bool $include = true): static { $this->snippets[$snippet] = $include; @@ -310,10 +306,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; class AdminSampleEvent implements EventSubscriberInterface { - /** - * @return array - */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ '@admin/Product/index.twig' => 'productList', @@ -371,16 +364,17 @@ class AdminSampleEvent implements EventSubscriberInterface 注文手続き画面でsubmitされた時に実行する処理を実装します。 主に、クレジットカード決済の有効性チェックをするために使用します。 -このメソッドは、 `PaymentResult` を返します。 -`PaymentResult` には、実行結果、エラーメッセージなどを設定します。 -`Response` を設定して、他の画面にリダイレクトしたり、独自の出力を実装することも可能です。 +このメソッドの戻り型は EC-CUBE 4.4 / Symfony 7 で `PaymentResult|bool` に変更されました。 +**確認画面へ進めたい(成功)場合は `false` を返します。** 失敗時のみ `PaymentResult` を返し、実行結果・エラーメッセージなどを設定します。 +(成功時に `PaymentResult` を返すと本体 `ShoppingController` が `getResponse()->isRedirection()` を null に対して呼び出し 500 エラーになります) +リダイレクトや独自の出力が必要な場合は、`PaymentResult` に `Response` を設定します。 #### `apply()` 注文確認画面でsubmitされた時に、他の Controller へ処理を移譲する実装をします。 主にリンク型決済や、キャリア決済など、決済会社の画面へ遷移する必要がある場合に使用します。 また、独自に作成した Controller に遷移する場合にも使用できます。 -このメソッドは `PaymentDispatcher` を返します。 +このメソッドの戻り型は EC-CUBE 4.4 / Symfony 7 で `PaymentDispatcher|bool` に変更されました。リダイレクトが不要な場合は `false` を返します。 `PaymentDispatcher` は、他の Controller へ `Redirect` もしくは `Forward` させるための情報を設定します。 決済会社の画面など、サイト外へ遷移させる場合は、 `Response` を設定します。 @@ -432,7 +426,7 @@ twigのソースコード内でメッセージを使用する場合には `trans ### DBの更新方法 -1. Entity拡張のORMアノテーションでDBの設定を更新 +1. Entity拡張のORMアトリビュート(`#[ORM\Column]` 等)でDBの設定を更新 1. コマンドラインからプロキシファイルを作成 `bin/console eccube:generate:proxies` 1. DBの更新内容の確認 `bin/console doctrine:schema:update --dump-sql` 1. DBの更新を実行 `bin/console doctrine:schema:update --dump-sql --force` @@ -441,36 +435,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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/Controller/PaymentController.php) リンク型決済およびコンビニ決済と連携するためのコントローラクラス。 @@ -480,99 +474,99 @@ 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.4/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.4/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.4/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.4/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.4/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.4/Entity/CvsType.php) コンビニの種別のエンティティクラス。 -### [Plugin\SamplePayment42\Event](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Event.php) +### [Plugin\SamplePayment44\SamplePaymentEvent](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/SamplePaymentEvent.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.4/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.4/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.4/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.4/Form/Type/Admin/SearchPaymentType.php) 決済ステータス一括変更画面用のフォームタイプ -### [Plugin\SamplePayment42\Nav](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Nav.php) +### [Plugin\SamplePayment44\SamplePaymentNav](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/SamplePaymentNav.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.4/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\Repository\ConfigRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Repository/ConfigRepository.php) プラグイン設定画面用のリポジトリクラス -### [Plugin\SamplePayment42\PluginManager\Repository\PaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/PaymentStatusRepository.php) +### [Plugin\SamplePayment44\Repository\PaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Repository/PaymentStatusRepository.php) 決済ステータス用のリポジトリクラス -### [Plugin\SamplePayment42\PluginManager\Repository\CvsPaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/CvsPaymentStatusRepository.php) +### [Plugin\SamplePayment44\Repository\CvsPaymentStatusRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Repository/CvsPaymentStatusRepository.php) コンビニ決済ステータス用のリポジトリクラス -### [Plugin\SamplePayment42\PluginManager\Repository\CvsTypeRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Repository/CvsTypeRepository.php) +### [Plugin\SamplePayment44\Repository\CvsTypeRepository](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Repository/CvsTypeRepository.php) コンビニ種別用のリポジトリクラス -### [Plugin\SamplePayment42\TwigBlock](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/TwigBlock.php) +### [Plugin\SamplePayment44\SamplePaymentTwigBlock](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/SamplePaymentTwigBlock.php) TwigBlock定義用クラス -### [composer.json](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/composer.json) +### [composer.json](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/composer.json) プラグイン定義ファイル -### [Resource/config/services.yaml](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Resource/config/services.yaml) +### [Resource/config/services.yaml](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Resource/config/services.yaml) パラメータ定義用設定ファイル -### [Resource/locale/messages.ja.yaml](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Resource/locale/messages.ja.yaml) +### [Resource/locale/messages.ja.yaml](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Resource/locale/messages.ja.yaml) メッセージ翻訳ファイル -### [Resource/locale/validators.ja.yaml](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Resource/locale/validators.ja.yaml) +### [Resource/locale/validators.ja.yaml](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Resource/locale/validators.ja.yaml) エラーメッセージ翻訳ファイル -### [Resource/template/*.twig](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.0/Resource/template) +### [Resource/template/*.twig](https://github.com/EC-CUBE/sample-payment-plugin/blob/4.4/Resource/template) 各種テンプレートファイル 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/.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/Resource/template/admin/order_edit.twig b/Resource/template/admin/order_edit.twig index 2c23366..55fc313 100644 --- a/Resource/template/admin/order_edit.twig +++ b/Resource/template/admin/order_edit.twig @@ -96,9 +96,9 @@
決済状況変更のテストはこちらから: - 決済完了 - 期限切れ - 決済失敗 + 決済完了 + 期限切れ + 決済失敗
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' %}