生成するファイル構造

commerce-checkout-starter-kit/commerce-backend-ui-1/
├── ext.config.yaml
├── README.md
├── .env.simulation.example
├── actions/
│   ├── utils.js
│   ├── commerce/
│   │   └── index.js           ← IMS-based Commerce REST (order listing)
│   ├── payment-accept/
│   │   ├── commerce-client.js ← OAuth 1.0a (accept/decline)
│   │   └── index.js
│   ├── payment-decline/
│   │   └── index.js
│   └── registration/
│       └── index.js
├── scripts/
│   ├── README.md
│   └── simulate-split-payment.mjs
└── web-src/
    ├── index.html
    ├── package.json
    ├── .parcelrc
    └── src/
        ├── index.jsx
        ├── index.css
        ├── utils.js
        ├── exc-runtime.js
        ├── config.json
        ├── constants/
        │   └── extension.js
        ├── components/
        │   ├── App.jsx
        │   ├── ExtensionRegistration.jsx
        │   ├── MainPage.jsx
        │   ├── SplitPaymentDashboard.jsx
        │   └── SplitPaymentOrderDetail.jsx
        └── hooks/
            └── useSplitPaymentOrders.js

バックエンド操作

actions/commerce/index.js — IMS認証のCommerce REST

  • 管理者UI SDK コンテキストによって提供されるIMS トークンを使用して、Commerce RESTを呼び出します
  • split_cash_status フィルターを含む注文リストを取得します
  • 注文リストをJSONとして返します

actions/payment-accept/commerce-client.js — OAuth 1.0a クライアント

  • split-payment-orchestrator/actions/payment-orchestrator/commerce-client.jsと同じ実装
  • 接頭辞が付いたCOMMERCE_INTEGRATION_*個の環境変数を使用します(IMS資格情報と区別するため)

actions/payment-accept/index.js — アクションを承認

  • split-payment-orchestrator/actions/payment-accept/index.jsと同じロジック
  • OAuth 1.0a経由でPOST /V1/split-payment/orders/:orderId/cash-receivedを呼び出す

actions/payment-decline/index.js — アクションを辞退

  • POST /V1/split-payment/orders/:orderId/cash-declineを呼び出します

actions/registration/index.js – 管理者UI SDKの登録

  • 拡張機能をCommerce管理シェルに登録します
  • 分割支払いダッシュボードの「注文」の下にメニュー項目を追加します

React フロントエンドコンポーネント

SplitPaymentDashboard.jsx

  • Spectrum スタイルのテーブルに、保留中の分割支払い注文を一覧表示します
  • 列:注文番号(increment_id)、日付、顧客、支払期限、店舗クレジット、ステータス
  • 1行あたりのボタンの受け入れと拒否
  • web-src/src/utils.js件のフェッチ ヘルパーを介してバックエンド アクションを呼び出す
  • 読み込み/エラー状態を表示します。アクションの完了時に更新されます

SplitPaymentOrderDetail.jsx

  • 1つの注文の分割支払の詳細を表示します
  • 表示:キャッシュ金額、ストアクレジット金額、現在のsplit_cash_status

useSplitPaymentOrders.js — React フック

  • actions/commerce/index.jsからの分割支払い注文を取得します
  • { orders, loading, error, refresh }を返します

シミュレーションスクリプト

scripts/simulate-split-payment.mjs

Commerce REST呼び出しを直接テストするためのNode.js ESM スクリプト(App Builderを経由しない)。 App Builder アクションと同じOAuth 1.0a署名を使用します。

コマンド:

  • node simulate-split-payment.mjs help – 使用状況を表示
  • node simulate-split-payment.mjs list – 分割支払いデータを使用した最近の注文のリスト
  • node simulate-split-payment.mjs show <orderId> – 特定の注文の分割支払いフィールドを表示します(entity_id)
  • node simulate-split-payment.mjs accept <orderId> — cash-received エンドポイントの呼び出し
  • node simulate-split-payment.mjs decline <orderId> — cash-decline エンドポイントの呼び出し

commerce-backend-ui-1/.env.simulationから資格情報を読み取ります(.env.simulation.exampleからコピー)。

.env.simulation.example:

COMMERCE_BASE_URL=https://your-store.example.com
COMMERCE_CONSUMER_KEY=
COMMERCE_CONSUMER_SECRET=
COMMERCE_ACCESS_TOKEN=
COMMERCE_ACCESS_TOKEN_SECRET=

ext.config.yaml

拡張機能を次の場所で設定します。

  • commerce-backend-ui-1拡張機能タイプ
  • 4つのバックエンドアクション (commerce、payment-accept、payment-decline、registration)
  • registrationを除くすべてのアクションのrequire-adobe-auth: true
  • 環境からCOMMERCE_INTEGRATION_*資格情報のバインディングを入力

ファイルの生成後

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

プロンプトの終了

このシリーズのすべてのリソース

リファレンスリソース

自動翻訳
言語セレクターを使用して、このページの英語版を表示します。
翻訳は役に立ちましたか?

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.