步骤1.3 — 启用并安装模块

从Commerce项目根目录运行以下命令:

bin/magento module:enable Client_SplitPayment
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush

步骤1.4 — 验证模块是否已正确安装

# Confirm the module is active
bin/magento module:status Client_SplitPayment

# Confirm the split_ columns were added to sales_order
mysql -u <user> -p <dbname> -e "DESCRIBE sales_order;" | grep split

您应该看到五列:split_store_credit_amount、split_cash_amount、split_cash_status、split_sc_invoice_id和split_cash_invoice_id。

然后在浏览器中确认,当具有商店点数的登录客户选择​ 现金 ​作为付款方式时,拆分付款字段会在结账时显示。

阶段2 — 配置环境变量

此操作如下:​准备App Builder Orchestrator、模拟脚本和(可选)Experience Cloud UI扩展使用的凭据文件。 每个.env文件中都会使用来自您的Commerce集成的相同四个OAuth值。

有关每个组件的变量的完整列表,请参阅环境变量引用。

步骤2.1 — 创建Orchestrator .env

在您的split-payment-orchestrator/目录中:

cp .env.example .env

填写每个值:

变量从何处获得
COMMERCE_BASE_URL您的商店URL — 无尾随斜杠
COMMERCE_CONSUMER_KEYCommerce管理员>系统>集成
COMMERCE_CONSUMER_SECRET相同 — 仅在激活时显示
COMMERCE_ACCESS_TOKEN相同
COMMERCE_ACCESS_TOKEN_SECRET相同
PAYMENT_THRESHOLD必须匹配Commerce中的split_payment/general/threshold(默认值: 100)
DEMO_UI_SECRET可选 — 如果设置,则为仪表板URL中的?secret=必需

步骤2.2 — 创建模拟脚本.env

cp commerce-backend-ui-1/.env.simulation.example commerce-backend-ui-1/.env.simulation

填写COMMERCE_BASE_URL和四个OAuth值(与上述凭据相同)。

阶段3 — 构建App Builder Orchestrator

此操作是什么:​生成split-payment-orchestrator App Builder项目:payment-orchestrator I/O事件使用者、payment-accept和payment-decline Web操作以及demo-dashboard操作员UI。

步骤3.1 — 运行Orchestrator提示符

打开App Builder orchestrator AI提示符页。 复制完整提示并从split-payment-orchestrator/目录运行它。

步骤3.2 — 安装依赖项并部署

cd split-payment-orchestrator
npm install
# Confirm .env is filled in (from Phase 2, Step 2.1)
aio app deploy

部署后,aio app deploy打印操作URL。 记下demo-dashboard URL — 您在阶段4中需要它。

步骤3.3 — 确认事件注册

在Adobe Developer Console中,打开您的App Builder项目工作区。 在​ 事件 ​下,确认Split payment — sales order place before注册存在且已绑定到payment-orchestrator操作。

阶段4 — 测试整个流程

按顺序完成验证步骤。 测试和验证指南具有以下每个步骤的完整curl命令、模拟脚本使用和故障排除参考。

步骤4.1 — 验证REST端点是否可路由

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

步骤4.2 — 测试签出UI

  1. 以测试客户(拥有商店点数的客户)的身份登录到店面
  2. 将产品添加到购物车,在配送和征税后购物车总价值在100美元以下
  3. 在付款步骤中,选择​现金
  4. 确认显示的分摊付款字段:显示余额、预付现金、存储贷记为$0
  5. 减少现金金额,并确认商店信用部分正确更新

步骤4.3 — 测试阈值保护

添加合计超过$100的产品,继续结帐,选择“现金”,然后尝试下订单。 必须显示错误"Payment could not be processed. Please try again or contact support."。

步骤4.4 — 发出测试拆分支付订单

创建低于$100的购物车,输入现金/商店信用拆分,然后下订单。 在Commerce Admin中,确认:

  • 订单状态为pending_payment

  • 订单上会显示来自App Builder的两条评论:

    1. "Cash payment of $X.XX pending. Awaiting admin confirmation."
    2. "Split payment orchestration completed. Order awaiting cash confirmation."

如果未出现App Builder注释,请检查包含aio app logs的日志后再继续。

步骤4.5 — 通过模拟脚本测试接受

# Find your order's entity_id
node commerce-backend-ui-1/scripts/simulate-split-payment.mjs list

# Accept the payment
node commerce-backend-ui-1/scripts/simulate-split-payment.mjs accept <entity_id>

在Commerce Admin中,确认:

  • 订单状态已更改为processing
  • 历史记录注释: "Cash payment of $X.XX received."
  • 在“发票”标签上显示的现金发票
  • 在“发运”标签中显示的发运(如果适用)

步骤4.6 — 通过模拟脚本拒绝测试

再下达一次测试订单,然后:

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

确认订单状态为canceled,split_cash_status为declined。

步骤4.7 — 测试演示仪表板

打开步骤3.2中的功能板URL。 系统中有挂起的订单:

  1. 确认订单显示在待处理列表中
  2. 单击​ 接受 ​并确认在Commerce中将订单移至processing
  3. 下新订单,返回到仪表板,然后单击​拒绝 — 确认取消

阶段5(可选) — 添加Experience Cloud UI扩展

此阶段将操作员仪表板嵌入到Commerce Admin shell中,而不是使用独立的demo-dashboard。 如果独立仪表板满足您的需求,请跳过此阶段。

步骤5.1 — 查看先决条件

除了OAuth集成值之外,Experience Cloud UI扩展还需要IMS凭据。 请阅读Experience Cloud UI扩展AI提示页,然后再运行该提示,并注意OAUTH_CLIENT_ID和相关IMS变量。

步骤5.2 — 运行UI扩展提示

将完整的提示从​ PROMPT START ​复制到​End of prompt,然后从commerce-checkout-starter-kit/目录运行它。

步骤5.3 — 部署

cd commerce-checkout-starter-kit
npm install
cp .env.dist .env
# Fill in IMS credentials and COMMERCE_INTEGRATION_* credentials
aio app deploy

快速疑难解答参考

症状首先要检查的事项
结账时未显示拆分付款字段浏览器控制台中出现RequireJS错误;同时运行bin/magento cache:flush
下单"Payment could not be processed"PlaceOrderPlugin或BalanceManagementInterface — 在PlaceOrderPlugin中添加临时调试日志记录
订单上没有App Builder备注运行aio app logs以查看是否触发了事件以及返回了什么操作
App Builder中Commerce REST的403Fastly IP列入允许列表 — 首先使用模拟脚本进行测试;如果可行,则问题在于出口IP阻塞
来自Commerce的"The signature is invalid"确认COMMERCE_BASE_URL没有尾随斜杠;确认集成已激活
订单未显示在演示仪表板中检查extension_attributes.split_cash_status是否出现在直接GET /rest/V1/orders响应中

有关完整的疑难解答详细信息,请参阅测试和验证指南。

此系列中的所有资源

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.