步骤5 — 测试阈值保护

  1. 添加合计超过$100的产品(小计+运费+税> $100)
  2. 继续结帐,选择​现金
  3. 尝试下单
  4. 验证是否显示错误消息: "Payment could not be processed. Please try again or contact support."
  5. 验证购物车是否已保留(客户仍然可以调整购物车并重试)

步骤6 — 下达测试分解支付订单

  1. 构建低于$100的购物车(使用商店点数登录的客户)
  2. 选择结账时收款
  3. 输入小于订单总计的现金金额(例如,$45订单中的$10)
  4. 确认显示商店点数消息
  5. 单击​下单

下订单后,在Commerce管理员中验证:

  • 订单处于pending_payment状态

  • 订单具有两个历史记录注释:

    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没有尾随斜杠
  • 确认四个OAuth凭据用于​ 激活的 ​集成
  • 首先使用模拟脚本进行测试 — 如果脚本可正常使用,但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,或事件有效负载形状已更改。

修复:

  • 确认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的工作

此系列中的所有资源

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.