拆分支付POC:测试和验证指南
本指南将指导您按照应测试的顺序验证每个组件是否正常工作。 从下开始(Commerce模块),然后再从上开始(App Builder)。
步骤1 — 验证Commerce模块的安装
运行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
预期输出:在sales_order中显示以split_开头的四列。
步骤2 — 验证Commerce管理配置
在Commerce Admin中:
- Stores > Configuration > Sales > Payment Methods — 确认已启用Cash On Delivery,标题为
Cash - Stores > Configuration > Customers > Customer Configuration > Store Credit Options — 确认已启用
- 确认您的测试客户拥有商店积分: Customers > All Customers > [客户] > Store Credit
步骤3 — 验证REST端点是否可访问
使用curl确认端点响应(它们会拒绝未授权请求,但401会确认它们已正确路由):
# 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}'
步骤4 — 测试签出UI
-
以测试客户(拥有商店积分)的身份登录到店面
-
将产品添加到购物车(发货后加税后合计不到$100)
-
继续以结账
-
在付款步骤中,选择现金(或货到付款)
-
验证是否显示拆分付款字段:
- 显示的商店贷方余额
- 使用订单总额预填充的现金金额字段
- 显示$0.00的“此订单的商店积分”字段(因为现金=全部订单总计)
-
减少现金金额(例如,为$50的订单输入$10)
-
Verify the store credit portion updates to $40.00
-
Verify the message appears:
"The remaining $40.00 will automatically be applied from your store credit."
Test validation:
- Enter a cash amount greater than the order total → error message
- Enter a cash amount that requires more store credit than available → error message
- Enter cash = 0 → error (or store credit covers entire order)
Step 5 — Test Threshold Guard
- Add products totaling more than $100 (subtotal + shipping + tax > $100)
- Proceed to checkout, select Cash
- Attempt to place the order
- Verify the error message appears:
"Payment could not be processed. Please try again or contact support." - Verify the cart is preserved (customer can still adjust cart and try again)
Step 6 — Place a Test Split Payment Order
- Build a cart under $100 (logged in customer with store credit)
- Select Cash at checkout
- Enter a cash amount less than the order total (e.g., $10 of a $45 order)
- Confirm the store credit message appears
- Click Place Order
After order placement, verify in Commerce Admin:
-
Order is in
pending_paymentstatus -
Order has two history comments:
"Cash payment of $X.XX pending. Awaiting admin confirmation."(from App Builderpayment-orchestrator)"Split payment orchestration completed. Order awaiting cash confirmation."(from App Builder)
-
The split payment amounts are visible in the order payment block
If no App Builder comments appear: Check App Builder action logs with
aio app logs. The event may not have fired or the action may have an error.
Step 7 — Test Accept via Simulation Script
The simulation script is the fastest way to test the accept/decline flow without the full operator 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
After accept, verify in Commerce Admin order view:
- Order status is
processing - History comment:
"Cash payment of $X.XX received." - Cash invoice created (visible in Invoices tab)
- Shipment created (visible in Shipments tab, if applicable)
- History comment:
"Split payment: cash portion invoiced #XXXXXXXX." - History comment:
"Split payment: shipment created after cash was accepted (App Builder / API)."
Step 8 — Test Decline via Simulation Script
Place another test order (same setup as Step 6), then:
node commerce-backend-ui-1/scripts/simulate-split-payment.mjs decline <orderId>
After decline, verify in Commerce Admin:
- Order status is
canceled - History comment:
"Cash payment declined (simulated fraud check)." split_cash_status=declined
Step 9 — Test the Demo Dashboard
After deploying the split-payment-orchestrator, aio app deploy prints the action URLs.
Open the demo-dashboard URL in a browser:
https://[runtime-host]/api/v1/web/split_payment_orchestrator/demo-dashboard
If DEMO_UI_SECRET is set:
https://[runtime-host]/api/v1/web/split_payment_orchestrator/demo-dashboard?secret=<your-secret>
With a pending order:
- The dashboard should show the order in the pending list
- Click Accept → order should move to
processingin Commerce - Place another order; click Decline → order should be
canceledin Commerce
Step 10 — Test App Builder Action Logs
# 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>
For the payment-orchestrator, look for:
[INFO] Split payment orchestration finished { orderId: '42' }
For payment-accept or payment-decline:
[INFO] Cash payment accepted on Commerce via REST { orderId: '42' }
Common Issues and Fixes
“The signature is invalid” from Commerce OAuth
Cause: Clock skew between App Builder runtime and Commerce, or an OAuth signing bug.
Fix:
- Confirm
COMMERCE_BASE_URLhas no trailing slash - Confirm the four OAuth credentials are for an activated integration
- Test with the simulation script first — if the script works but App Builder doesn’t, it’s likely an env variable not loaded (check
aio app deployoutput for missing env vars)
Split payment fields not appearing in checkout
Cause: LayoutProcessorPlugin injection paths don’t match your checkout layout.
Fix:
- Check the browser console for RequireJS errors loading
Client_SplitPayment/js/view/payment/split-payment - Check
bin/magento setup:static-content:deploycompleted successfully - Flush cache:
bin/magento cache:flush - If your theme has a custom checkout, the
LayoutProcessorPluginpath to inject the component may need adjustment
Store credit not applying / “Payment could not be processed” at place order
Cause: Usually one of the edge case plugins not working correctly.
Check:
- Is
SplitPaymentSessionreturning the correct amounts? Add temporary debug logging inPlaceOrderPlugin - Is
FixSplitPaymentGrandTotalPluginrunning and affecting the quote total beforeBalanceManagementInterface::apply()is called? ThebeginBalanceApply()flag should suppress it. - Is the customer balance module enabled in Commerce?
App Builder action receives event but orderId is missing
Cause: The io_events.xml field list doesn’t include entity_id, or the event payload shape changed.
修复:
- 确认
io_events.xml在字段列表中包含entity_id - 在操作中,暂时记录
JSON.stringify(params)以查看完整的有效负载形状 - 检查
extractValue()函数是否找到了正确的嵌套级别
订单未显示在演示仪表板中
原因: Commerce REST orders搜索条件未返回订单,或split_cash_status字段不在REST响应中。
修复:
- 确认
OrderRepositoryPlugin是否正确加载扩展属性 - 直接测试:
GET /rest/V1/orders?searchCriteria[pageSize]=5并检查响应中是否显示extension_attributes.split_cash_status - 检查
extension_attributes.xml是否在OrderInterface上正确声明split_cash_status属性
验证核对清单
- [ ]
split_*列显示在sales_order表中 - [ 在没有身份验证的情况下调用] REST端点时返回401(不是404)
- [ 选择“现金”时,]拆分付款UI在结账时呈现
- [ ]验证消息有效(付款过多、信用不足)
- [ ]阈值保护阻止订单> $100
- [ ]已下订单具有
pending_payment状态和App Builder备注 - [ ]
simulate-split-payment.mjs list显示具有拆分金额的测试订单 - [ ]
simulate-split-payment.mjs accept <id>将订单移动到processing,其中包含发票和装运 - [ ]
simulate-split-payment.mjs decline <id>取消订单 - [ ]演示仪表板列出待处理订单并接受/拒绝来自UI的工作
Related split payment POC resources
- 创建拆分支付POC:App Builder和AI工具
- 创建拆分付款POC:App Builder完整演示
- 分割支付POC:架构和设计决策
- 拆分付款POC:先决条件和环境设置
- 拆分付款POC:环境变量参考
- Split payment POC: Commerce module AI prompt
- Split payment POC: App Builder orchestrator AI prompt
- 拆分付款POC:Experience Cloud UI扩展人工智能提示
- 拆分支付POC:测试和验证指南
- Split payment POC: next steps after the proof of concept
- Split payment POC: tutorial quick reference for authors