コンテンツにスキップ

Payment Eligibility Checkers

概要

決済方法の利用可否は PaymentMethodCollectionAssignment (PMCA) を正本 に 判定します。SMILE の 回収方法コード (Customer.customFields.collectionMethod) をキーに、許可する PaymentMethod の code リストを保持するエンティティで、 Dashboard 上では /payment-methods/collection-mapping から編集できます。

判定本体は Vendure 標準の PaymentMethodEligibilityChecker インタフェースに 従う paymentCollectionMethodEligibilityChecker です。

チェッカー一覧

回収方法マッピング判定(現行・唯一)

  • 識別子: paymentCollectionMethodEligibilityChecker
  • 実体コード: payment-collection-method-eligibility
  • 判定対象: Customer.customFields.collectionMethod × PMCA.allowedPaymentMethodCodes
  • 登録: B2BPaymentEligibilityPlugin.configuration() が config の paymentMethodEligibilityCheckers に push する (packages/plugins/src/b2b-extensions/index.ts)

paymentGroupEligibilityChecker / PaymentEligibilityEvaluatorService / payment-group-eligibility は廃止済みです。汎用ポリシー (policyType: payment) 経路も payment scope では使われません。

判定ロジック

  1. Order の Customer から customFields.collectionMethod を取得(正規化付き)。
  2. PaymentMethodCollectionAssignmentService.findOne(code) で assignment を引く。
  3. assignment.enabled === true かつ assignment.allowedPaymentMethodCodes.includes(paymentMethod.code) の場合のみ eligible。
  4. 未割当 / 該当 assignment 無し / enabled=false は ineligible として明示的に 弾く(fail-open しない)。

実装: packages/plugins/src/b2b-extensions/payments/payment-collection-method-eligibility.ts

入力データの流れ

SMILE CSV (回収方法カラム)
  └─→ smile-customer-row.parser
        └─→ Customer.customFields.collectionMethod   ← 判定入力
              └─→ paymentCollectionMethodEligibilityChecker
                    └─→ PaymentMethodCollectionAssignment   ← 正本マッピング
                          └─→ allowedPaymentMethodCodes (PaymentMethod.code[])
  • SMILE → collectionMethod の書き込み: packages/plugins/src/system-integration/smile/services/smile-customer-row.parser.ts
  • 旧内部名 collectionMethod1 は参照しません。

Dashboard での編集

  • 一覧: /payment-methods/collection-mapping
  • 新規作成: /payment-methods/collection-mapping/new
  • 編集: /payment-methods/collection-mapping/<code>
  • サイドバーは Settings 配下と SMILE連携 配下の両方からアクセス可能
  • 必要権限: UpdateSettings
  • コードは半角数字のみ(SMILE 回収方法コードに合わせる)

preview / explain

PMCA 経由判定は条件分岐が単純なため、Vendure 標準 eligiblePaymentMethods の 返却値で判定結果を確認できます。回収方法と決済可否の対応は Dashboard 一覧で 直接確認するのが正規ルートです。

Storefront 表示契約

  • eligiblePaymentMethods は判定結果の正本だが、Storefront の checkout / マイページでは isEligible=true の PaymentMethod だけを顧客向けに表示する。
  • isEligible=false は operator/debug 用の判定結果として扱い、顧客向け UI では disabled option として表示しない。顧客が使える支払い方法だけを見せる。
  • Storefront は過去に保存した選択 method が現在の候補から外れた場合、現在選択可能な method へ差し替える。注文確定時にも同じ候補集合で guard し、候補外 method は fail-closed で拒否する。

PMCA と他経路の責務分離

Customer.customFields.collectionMethod は PMCA 以外の場所でも参照され得るが、 役割が異なるため競合・重複ではない。本ドキュメントの正本(決済可否判定)と 混同しないよう、用途別の境界を以下に固定する。

経路 入力 / 評価対象 用途 備考
paymentCollectionMethodEligibilityChecker (本書) Customer.customFields.collectionMethod → PMCA 決済可否 (checkout) 正本
Campaign / Commercial Rule condition (CUSTOMER_FIELD_OPTIONScollectionMethod) Customer.customFields.collectionMethod 価格・販促ルール の顧客側条件 決済可否ではなく値引・特典対象の絞り込み。直交軸。
Customer.customFields.customerStatus 顧客ステータス 顧客分類 SMILE importer では collectionMethod から派生しない。PMCA の判定には未使用。価格規則 / 表示制御で別軸として使う場合あり。

価格・販促側で collectionMethod を条件に使うのは、PMCA の決済可否判定とは 評価対象が異なる(決済方法ではなく価格)ため許容する。両者を同じ要件として 一本化しないこと。

関連ドキュメント