分割払いPOC:前提条件と環境の設定

ビルドプロンプトを実行する前に、このチュートリアルのすべての手順を完了してください。 1つのステップが見つからない場合は、チュートリアルの途中でフローが壊れる最も一般的な理由です。

​1. Adobe Commerceの要件

  • Adobe Commerce 2.4.5以降 (オンプレミスまたはCommerce Cloud)
  • Commerce プロジェクトへのGit アクセス(app/code/の下にモジュールを追加した場合)
  • Commerce Admin​へのアクセス

Commerce Cloudのみ:I/O イベントを有効にする

モジュールを追加する前に、以下を.magento.env.yamlに追加してデプロイします。

stage:
  global:
    ENABLE_EVENTING: true

警告:​このデプロイは、I/O イベントモジュールの依存関係を解決する前に正常に終了する必要があります。

​2. Commerce管理者設定

他の何よりも前にこれらのステップを実施しましょう。 チェックアウト JavaScriptは、正確な文字列の一致に応じて異なります。

2a. 正確なタイトルで代金引換を有効にする

Stores > Configuration > Sales > Payment Methods > Cash On Delivery Payment

  • Enabled: はい
  • Title: Cash (この正確な文字列は、チェックアウト JavaScriptと一致します)

注: ストアで別の代金引換(COD)実装またはタイトルを使用している場合は、Commerce モジュールでpayment-method-helper.jsを調整します。

2b. ストアクレジットを有効にする

Stores > Configuration > Customers > Customer Configuration > Store Credit Options

  • Enable Store Credit Functionality: はい

2c. テスト顧客にストアクレジットを追加する

Customers > All Customers > [テスト用のお客様] > Store Credit > Update Balance

店舗クレジットに少なくとも​ $50 ​を追加してください。 合計100 ドル未満の注文でテストします。

2d. Commerceとの連携の構築

System > Integrations > Add New Integration

  • Name: Split Payment App Builder (または任意の名前)

  • API」タブで、少なくとも次の権限を付与します。

    • Magento_Sales::actionscash-received エンドポイントに必要)
    • Magento_Sales::cancelcash-decline エンドポイントに必要)
    • 見積もりまたはカートの管理(全部または関連するサブセット)
    • Customer balance (完全または関連するサブセット)

Save」、「Activate」の順に選択します。

4つの値をすべてコピーします。これらは1回のみ表示されます:

環境変数
Consumer Key
COMMERCE_CONSUMER_KEY
Consumer Secret
COMMERCE_CONSUMER_SECRET
アクセストークン
COMMERCE_ACCESS_TOKEN
アクセストークン秘密鍵
COMMERCE_ACCESS_TOKEN_SECRET

これらの値を安全に保存します。 App Builder .env ファイルごとに必要です。

​3. Adobe Developer ConsoleとApp Builder

  • Adobe Developer Console組織へのアクセス
  • App Builder プロジェクト (新規または再利用したもの)
  • ワークスペースが設定されました。プロンプトは​ Stage ​と仮定します
  • Adobe I/O Events​がワークスペースにサービスとして追加されました
  • Commerce​がワークスペースのイベントプロバイダーとして接続されました

概念実証で使用されるイベント コード:com.adobe.commerce.observer.sales_order_place_before

Commerceをイベントプロバイダーとして接続していない場合は、Commerce拡張ガイドの「CommerceでAdobe I/Oにイベントを出力するように設定」を参照してください。

​4. ローカル開発環境

# Required versions
node --version    # 18.x or later
npm --version     # any recent version

# Adobe I/O CLI
npm install -g @adobe/aio-cli

# Authenticate
aio login

# Select your project and workspace
aio app use
# Confirm the org, project, and workspace shown are correct

​5. 知っておくべき2つのプロジェクトディレクトリ

このチュートリアルでは、2つの別々のディレクトリルートを使用します。 分離する:

Commerce プロジェクトのルート (Magento Git リポジトリ):

<commerce-root>/
└── app/code/Client/SplitPayment/   ← Module goes here

App Builder プロジェクトのルート (ソースパッケージのsplit-payment-orchestrator フォルダー、または作成した新しいプロジェクト):

split-payment-orchestrator/
├── app.config.yaml
├── package.json
├── .env                            ← Copy from .env.example, then fill in
└── actions/

​6. entity_idとincrement_idの比較

REST呼び出しでは、常にincrement_idではなくentity_id (数値データベース ID)を使用します(例:000000042)。

Commerce Admin​注文URLからentity_idを検索:

/admin/sales/order/view/order_id/42/   →   entity_id = 42

またはシミュレーションスクリプトから:

node scripts/simulate-split-payment.mjs show 42

​7. 100 ドルの閾値

分割された支払いUIとしきい値ガード ターゲット注文​$100.00以下。 フローは次のように動作します。

  • 100 ドル以下:​の分割支払いUIが表示されます。お客様は現金と店舗のクレジット分割を設定できます
  • $100を超える: CheckoutPluginは、支払い手順でエラーをスローします

テストするには、小計、送料、税金が​100 ドル以下のカートを作成します(例えば、$90未満の商品は、送料と税金がキャップの下に収まります)。

しきい値は次の場所に保存されます。

  • Commerce設定:split_payment/general/threshold (デフォルト:100etc/config.xml
  • App Builder環境:PAYMENT_THRESHOLD=100 (Commerceと一致する必要があります)

​8. Fastly (Commerce Cloudのみ)

App Builder actions call Commerce over REST (/rest/V1/split-payment/orders/...). If your Commerce Cloud project uses Fastly with IP allowlisting, the App Builder runtime egress IP addresses must be allowlisted.

How to check: Run the simulation script first (direct curl with OAuth signing). If that works but the App Builder action returns 403, Fastly is likely blocking the request.

Use Adobe’s current documentation for App Builder egress IP ranges and add them to your Fastly configuration as needed.

Verification checklist

Before you start the build prompts, confirm the following:

  • [ ] Commerce version is 2.4.5 or later
  • [ ] I/O eventing is enabled (Commerce Cloud) and deployed
  • [ ] Cash on delivery is enabled with the title set exactly to Cash
  • [ ] Store credit is enabled
  • [ ] The test customer has at least $50 store credit
  • [ ] The Commerce integration is created and activated, and all four OAuth values are saved
  • [ ] The App Builder project has the I/O Events service and the Commerce event provider configured
  • [ ] aio login is complete and the correct workspace is selected with aio app use
  • [ ] Node.js 18 or later is installed and the aio CLI is installed
  • [ ] .env files are prepared per Split payment POC: environment variables reference (and your source package, if you use one)

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

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