Split payment POC: testing and verification guide

This guide walks you through verifying that every component works correctly, in the order they should be tested. Start from the bottom (Commerce module) and work up (App Builder).

Step 1 — Verify Commerce Module Installation

bin/magento setup:upgradeおよびbin/magento setup:di:compileの実行後:

# Confirm module is enabled
bin/magento module:status Client_SplitPayment

# Confirm db_schema columns were added
bin/magento doctrine:schema:validate
# or check directly:
mysql -u <user> -p <dbname> -e "DESCRIBE sales_order;" | grep split

Expected output: four columns starting with split_ visible in sales_order.

Step 2 — Verify Commerce Admin Configuration

In Commerce Admin:

  1. Stores > Configuration > Sales > Payment MethodsCash On Delivery​がタイトル Cashで有効になっていることを確認します
  2. Stores > Configuration > Customers > Customer Configuration > Store Credit Options – 有効化を確認
  3. Confirm your test customer has store credit: Customers > All Customers > [customer] > Store Credit

Step 3 — Verify REST Endpoints Are Accessible

Use curl to confirm the endpoints respond (they will reject unauthorized requests, but a 401 confirms they’re routed correctly):

# Should return 401 (not 404) — endpoint exists but requires auth
curl -X POST https://your-store.example.com/rest/V1/split-payment/orders/1/cash-received

# Should return 200 or session-based response — anonymous endpoint
curl -X POST https://your-store.example.com/rest/V1/split-payment/set \
  -H "Content-Type: application/json" \
  -d '{"storeCreditAmount": 0, "cashAmount": 0}'

Step 4 — Test the Checkout UI

  1. Log in to the storefront as your test customer (who has store credit)

  2. 商品をカートに追加する(送料+税込み後の合計が100 ドル未満)

  3. Proceed to checkout

  4. At the payment step, select Cash (or Cash On Delivery)

  5. Verify the split payment fields appear:

    • Your store credit balance shown
    • Cash amount field pre-filled with the order total
    • “Store credit toward this order” field showing $0.00 (since cash = full order total)
  6. Reduce the cash amount (e.g., enter $10 for a $50 order)

  7. ストアのクレジット部分が$40.00に更新されていることを確認します。

  8. メッセージが表示されることを確認します:"The remaining $40.00 will automatically be applied from your store credit."

テスト検証:

  • 注文合計を超える金額を入力する→のエラーメッセージ
  • 使用可能な店舗クレジットよりも多くの店舗クレジットが必要な現金金額→入力してください
  • Enter cash = 0 → error (またはストアクレジットは注文全体をカバー)

ステップ 5 - テストしきい値ガード

  1. 合計$100以上の商品を追加(小計+送料+税> $100)
  2. チェックアウトに進み、Cash​を選択します
  3. 注文を試みます
  4. エラーメッセージが表示されることを確認します:"Payment could not be processed. Please try again or contact support."
  5. カートが保持されていることを確認します(お客様は引き続きカートを調整し、再試行できます)

ステップ 6 - テスト分割支払い注文を行う

  1. 100 ドル未満でカートを作成(店舗のクレジットを使用して顧客にログイン)
  2. チェックアウト時に現金を選択
  3. 注文総額より少ない金額(例:$45の注文の$10)を入力します。
  4. 店舗のクレジットメッセージが表示されることを確認します
  5. 注文を配置​をクリックします

注文後、Commerce Adminで次の項目を確認します。

  • 注文のステータスはpending_payment

  • 注文には、次の2つの履歴コメントがあります。

    1. "Cash payment of $X.XX pending. Awaiting admin confirmation." (App Builder payment-orchestratorから)
    2. "Split payment orchestration completed. Order awaiting cash confirmation." (App Builderから)
  • 分割支払い金額は、注文支払いブロックに表示されます

App Builder コメントが表示されない場合: App Builderのアクションログをaio app logsで確認します。 イベントが起動しなかったか、アクションにエラーがある可能性があります。

ステップ 7 - シミュレーションスクリプトを使用したテスト受け入れ

シミュレーションスクリプトは、オペレーターUIを完全に使用せずに承認/拒否フローをテストする最も高速な方法です。

cd commerce-checkout-starter-kit
cp commerce-backend-ui-1/.env.simulation.example commerce-backend-ui-1/.env.simulation
# Edit .env.simulation with your credentials

# List recent orders (find your test order entity_id)
node commerce-backend-ui-1/scripts/simulate-split-payment.mjs list

# Show split payment fields for a specific order
node commerce-backend-ui-1/scripts/simulate-split-payment.mjs show 42

# Accept the cash payment
node commerce-backend-ui-1/scripts/simulate-split-payment.mjs accept 42

承認したら、Commerce管理者注文ビューで確認します。

  • 注文ステータスはprocessingです
  • 履歴コメント:"Cash payment of $X.XX received."
  • 作成された現金請求書(請求書タブに表示)
  • 配送が作成されました(該当する場合、「出荷」タブに表示)
  • 履歴コメント:"Split payment: cash portion invoiced #XXXXXXXX."
  • 履歴コメント:"Split payment: shipment created after cash was accepted (App Builder / API)."

ステップ 8 - シミュレーションスクリプトを使用したテスト拒否

別のテスト注文(ステップ 6と同じ設定)を行ってから:

node commerce-backend-ui-1/scripts/simulate-split-payment.mjs decline <orderId>

辞退後、Commerce管理者で次の項目を確認します。

  • 注文ステータスはcanceledです
  • 履歴コメント:"Cash payment declined (simulated fraud check)."
  • split_cash_status = declined

ステップ 9 - デモダッシュボードをテストする

split-payment-orchestratorをデプロイした後、aio app deployはアクション URLを印刷します。

ブラウザーでdemo-dashboard URLを開きます:

https://[runtime-host]/api/v1/web/split_payment_orchestrator/demo-dashboard

DEMO_UI_SECRETが設定されている場合:

https://[runtime-host]/api/v1/web/split_payment_orchestrator/demo-dashboard?secret=<your-secret>

保留中の注文の場合:

  1. ダッシュボードには、保留中のリストに順序が表示されます
  2. 承諾​をクリック→ると、注文はCommerceのprocessingに移動します
  3. 別の注文を行います。「辞退」をクリック→、Commerceでcanceledの注文を行う必要があります

ステップ 10 - App Builder アクションログのテスト

# Follow logs in real-time
aio app logs --tail

# Or view last invocations
aio runtime activation list --limit 10
aio runtime activation logs <activation-id>

payment-orchestratorの場合、次を探します。

[INFO] Split payment orchestration finished { orderId: '42' }

payment-acceptまたはpayment-declineについて:

[INFO] Cash payment accepted on Commerce via REST { orderId: '42' }

一般的な問題と修正

Commerce OAuthの「署名が無効です」

原因: App Builder ランタイムとCommerceの間のクロックスキュー、またはOAuth署名バグ。

修正:

  • COMMERCE_BASE_URLの末尾にスラッシュがないことを確認してください
  • 4つのOAuth資格情報が​ ACTIVATED ​統合用であることを確認してください
  • 最初にシミュレーションスクリプトでテストします。スクリプトが機能するが、App Builderが機能しない場合は、環境変数が読み込まれていない可能性があります(環境の変数が見つからない場合は、aio app deploy出力を確認してください)

チェックアウト時に分割支払いフィールドが表示されない

原因: LayoutProcessorPlugin インジェクション パスがチェックアウト レイアウトと一致しません。

修正:

  • Client_SplitPayment/js/view/payment/split-paymentの読み込み中にRequireJS エラーが発生していないか、ブラウザーコンソールを確認してください
  • bin/magento setup:static-content:deployの確認が正常に完了しました
  • フラッシュ キャッシュ:bin/magento cache:flush
  • テーマにカスタムチェックアウトがある場合、コンポーネントを挿入するためのLayoutProcessorPlugin パスを調整する必要がある場合があります

ストアクレジットが適用されない/「支払いを処理できませんでした」プレースオーダー

原因:​通常、エッジ ケース プラグインのいずれかが正しく機能しません。

確認:

  1. SplitPaymentSessionは正しい金額を返していますか? PlaceOrderPluginに一時的なデバッグログを追加
  2. BalanceManagementInterface::apply()が呼び出される前に、FixSplitPaymentGrandTotalPluginが実行中で見積もり合計に影響を与えていますか? beginBalanceApply() フラグはそれを抑制する必要があります。
  3. Commerceでカスタマーバランスモジュールが有効になっていますか?

App Builder アクションはイベントを受け取りますが、orderIdがありません

原因: io_events.xml フィールドリストにentity_idが含まれていないか、イベントペイロードの形状が変更されています。

Fix:

  • Confirm io_events.xml includes entity_id in the field list
  • In the action, log JSON.stringify(params) temporarily to see the full payload shape
  • Check that the extractValue() function is finding the right nesting level

Orders don’t show in demo dashboard

Cause: Commerce REST orders search criteria not returning orders, or split_cash_status field not in the REST response.

Fix:

  • Confirm OrderRepositoryPlugin is loading extension attributes correctly
  • Test directly: GET /rest/V1/orders?searchCriteria[pageSize]=5 and check if extension_attributes.split_cash_status appears in the response
  • Check that extension_attributes.xml is correctly declaring the split_cash_status attribute on OrderInterface

Verification Checklist

  • [ ] split_* columns visible in sales_order table
  • [ ] REST endpoints return 401 (not 404) when called without auth
  • [ ] Split payment UI renders at checkout when Cash is selected
  • [ ] Validation messages work (overpayment, insufficient credit)
  • [ ] Threshold guard blocks orders > $100
  • [ ] Placed order has pending_payment status and App Builder comments
  • [ ] simulate-split-payment.mjs list shows the test order with split amounts
  • [ ] simulate-split-payment.mjs accept <id> moves order to processing with invoice and shipment
  • [ ] simulate-split-payment.mjs decline <id> cancels the order
  • [ ] Demo dashboard lists pending orders and accept/decline work from the UI

関連する分割支払POC リソース

recommendation-more-help
commerce-learn-help-home