# Salesforce 注文 Management 用の Stripe アプリをインストールする Stripe アプリを設定して設定します。 ## Salesforce 注文管理アプリをインストールする前に 1. アプリをインストールしてマッピングする Salesforce インスタンス内の組織と B2C コマースストアを指定します。 1. インストールを処理する前に、エンタイトルメントと[前提条件](https://docs.stripe.com/use-stripe-apps/salesforce-order-management.md)を確認します。 1. 以下の連携制限にご注意ください。 1. B2C ストアフロントは 1 つのみサポート 1. 1 回限りの手動キャプチャーにのみ対応 1. オーバーキャプチャーやマルチキャプチャーなどの複雑なシナリオは対応不可 ## インストール Salesforce Order Management との連携の詳細については、[Stripe サポート](https://support.stripe.com)のフォームからお問い合わせください。 **Install for Admins Only (管理者のみにインストール)** が選択されていることを確認してから、**Install (インストール)** をクリックします。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-install.a95bc450897ae2c8fec49837590ce099.png) サードパーティーのウェブサイトとの間のアクセスを承認します。Grant Access (アクセス権を付与) チェックボックスを選択して、**Continue (続行)** をクリックします。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-3p-access.fea0d91a0e164d00b01c288cbe51475e.png) インストールに時間がかかる場合は、パッケージがインストールされたことを知らせるメールが届きます。 確認するには、**設定 > アプリ > パッケージング > Installed Packages (インストールされたパッケージ)** に移動し、パッケージがインストールされていることを確認します。 ## 設定 以降のセクションでは、実装を設定する方法を説明します。 ### Stripe Synchronous Payment Gateway Adapter を設定する 1. [Set Up a Synchronous Payment Gateway Adapter in Salesforce](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_commercepayments_sync_adapter_setup.htm) (日本語ページ: Salesforce での同期支払ゲートウェイアダプタの設定: https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_commercepayments_sync_adapter_setup.htm) のステップ 3 の手順に従い、Payment Gateway Provider を作成します。ペイロードとして推奨する値は以下のとおりです。 ```json { "ApexAdapterId": "Output of this Query: SELECT Id FROM ApexClass WHERE Name IN ('StripeAdapter')", "DeveloperName": "StripeProvider", "MasterLabel": " StripeProvider", "IdempotencySupported": "No", "Comments": "Stripe Synchronous Payment Gateway Adapter" } ``` 1. [Set Up a Synchronous Payment Gateway Adapter in Salesforce](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_commercepayments_sync_adapter_setup.htm) (日本語ページ: Salesforce での同期支払ゲートウェイアダプタの設定: https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_commercepayments_sync_adapter_setup.htm) のステップ 4 の手順に従い、Payment Gateway レコードを作成します。 推奨値: | フィールドのラベル | 値 | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | 名前 | SALESFORCE_PAYMENTS | | Merchant Credential ID (加盟店認証情報 ID) | このクエリの出力: `SELECT Id FROM NamedCredential WHERE DeveloperName = 'StripeAPI'` | | Payment Gateway Provider | クエリの出力 (Stripe Synchronous Payment Gateway Provider が ‘StripeProvider’ 以外である場合はクエリを変更します): `SELECT Id FROM PaymentGatewayProvider WHERE DeveloperName ='StripeProvider'` | | ステータス | 有効 | ### Stripe Asynchronous Payment Gateway Adapter を設定する 1. [Set Up an Asynchronous Payment Gateway Adapter in Salesforce](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_commercepayments_async_adapter_setup.htm) (日本語ページ: Salesforce での非同期支払ゲートウェイアダプタの設定: https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_commercepayments_async_adapter_setup.htm) の手順に従い、Stripe Asynchronous Payment Gateway Adapter を設定します (Stripe Synchronous Payment Gateway Adapter ですでに同じ手順を実行している場合は、ステップ 2 と 3 をスキップします)。非同期の Payment Gateway Provider を作成するには、上記のリンクの手順のステップ 4 を実行します。ペイロードとして推奨する値は以下のとおりです。 ```json { "ApexAdapterId": "Output of this Query: SELECT Id FROM ApexClass WHERE Name IN (‘StripeAsyncAdapter’)", "DeveloperName": "StripeAsyncAdapter", "MasterLabel": " StripeAsyncAdapterProvider ", "IdempotencySupported": "No", "Comments": "Stripe Asynchronous Payment Gateway Adapter" } ``` 1. [Set Up an Asynchronous Payment Gateway Adapter in Salesforce](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_commercepayments_async_adapter_setup.htm) (日本語ページ: Salesforce での非同期支払ゲートウェイアダプタの設定: https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_commercepayments_async_adapter_setup.htm) のステップ 5 (支払ゲートウェイレコードを作成します) の手順に従い、Stripe Asynchronous Payment Gateway レコードを Salesforce に登録します。 挿入 (初めてゲートウェイレコードを作成する場合) または更新 (Synchronous ペイメントゲートウェイアダプターの設定時にすでにゲートウェイレコードを作成した場合) するフィールドに推奨される値は以下のとおりです。 | フィールドのラベル | 値 | | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 名前 | SALESFORCE_PAYMENTS | | Merchant Credential ID (加盟店認証情報 ID) | このクエリの出力: `SELECT Id FROM NamedCredential WHERE DeveloperName = 'StripeAPI'` | | Payment Gateway Provider | クエリの出力 (Stripe Synchronous Payment Gateway Provider が ‘StripeProvider’ 以外である場合はクエリを変更します): `SELECT Id FROM PaymentGatewayProvider WHERE DeveloperName ='StripeAsyncAdapter'.` | | ステータス | 有効 | 1. ステップ 6 の手順に従い、Stripe 用の Webhook URL を設定します。Webhook URL の通常の形式は、一般にアクセス可能な HTTPS URL です。例: https://mydomainname.my.salesforce-sites.com/subdomain/services/data/v[Replace_ME_version]/commerce/payments/notify%20?provider= ```sql SELECT Id FROM PaymentGatewayProvider WHERE DeveloperName = ‘StripeAsyncAdapter’ ``` 組織の API バージョン 49.0 以降と[Replace_ME_version] 1. 以下のステップに従って Stripe に Webhook URL を登録します。 1. [Stripe ダッシュボード](https://dashboard.stripe.com/dashboard)にログインします。 1. ワークベンチの [Webhook](https://dashboard.stripe.com/webhooks) タブに移動します。 1. **新しいエンドポイントを作成する**をクリックします。 1. `charge.refunded`、`charge.succeeded`、`charge.captured` のイベントタイプを追加して、**続行**をクリックします。 1. Webhook URL を入力してから、**送信先を作成する**をクリックします。 1. Webhook 署名シークレットをコピーし、以降の使用に備えて保存します。![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-stripe-copy-wh-secret.6520c64215f84d4053a8bf9c927d8796.png) ## Stripe OM Setup を使用して設定を完了する 以降のセクションでは、実装の設定を完了する方法を説明します。 ### Stripe アカウントで Stripe OMS アプリをオーソリする Salesforce Order Management org で、Stripe Setup アシスタントを実行し、組織を Stripe アカウントに連結します。 1. アプリケーションランチャーをクリックして、**View All (すべて表示)**をクリックします。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-launch-app-launcher.abb6c08a1cde704115918ebaddfe3ff4.png) 1. **Stripe OM Setup** をクリックします。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-launch-om-setup.d84d6c532e02356ab40073b2bec20f14.png) 1. \**Get Started (始める)**をクリックします。 1. 本番環境に切り替えます。本番データに影響を与えずに Stripe の実装をテストするには、本番環境を無効のままにして、Stripe Payment Gateway で実際の取引処理を開始する準備が整ったら、本番環境を有効にすることをお勧めします。テスト環境と本番環境の間で切り替えるには、このステップに戻って接続を再認証します。本番環境を使用していて、テスト環境に戻す場合には、再認証は必要ありません。 1. \**Authorize (承認する)**をクリックします。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-authorize.d4883cff2b90cce49e6054a05daa9079.png) これにより、Salesforce が Stripe データにアクセスできるようになるため、決済のキャプチャーと返金が可能になります。Stripe のウェブサイトが開き、認証プロセスを完了できます。このとき、ログイン情報の入力や Stripe アカウントの設定が必要になる場合があります。完了すると、このページにリダイレクトされ、設定プロセスを完了できます。認証が正常に完了すると、次のメッセージが表示されます。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-authorize-complete.8ff6523255d2652a3dacaa56304c0090.png) Stripe Asynchronous Payment 処理用に Webhook 署名シークレットを保存します。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-store-wh-secret.9918a70a19d3886755228a68102c1979.png) 1. Webhook 署名シークレット値を**署名シークレット**に追加します。 1. **更新**をクリックします。 1. 挿入の成功を確認するメッセージが上部に表示されます。**Finish (完了)**をクリックします。 ### 既存の注文管理フローを変更する Stripe での認証には OAuth が使用され、Stripe が OAuth プロバイダーとなります。Salesforce は、Stripe を OAuth プロバイダーとしてサポートしていません。このため、OAuth トークンは、呼び出し可能なアクション **getAccesToken** を利用するカスタム導入を使用して取得されます。これは、Stripe OM アプリ Managed Package の一部としてパッケージ化されています。 Stripe への支払い/返金を開始するフローを特定し、フロー内の **Ensure Funds (売上を確保する)** アクションの直前のアクションに呼び出し可能メソッド **getAccessToken** を含めます (以下の例を参照)。変更が必要となるフローは、次の例に示すものとは異なります。 1. **Setup (設定) > Process Automation (プロセスの自動化) > Flows (フロー)** に移動します。 1. 資金のキャプチャーに使用する有効**フロー**を選択します。 1. 呼び出し可能なメソッド `getAccessToken` を呼び出す新しい**アクション**を作成します。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-generate-token.4e707e9311288fd5e7f6e93a47dc638d.png) 1. **Get Access Token (アクセストークンの取得)** アクションが **Capture Funds (売上のキャプチャー)** アクションより前に行われていることを確認します。完了したら、この新しいバージョンの **Flow (フロー)** を保存して、プロセスで新しいバージョンが使用されるようにします。 ![](https://b.stripecdn.com/docs-statics-srv/assets/sfom-flowbuilder.22b239ea431eca499ef4cddd690ade94.png) 1. これで、Order Management org で支払い方法として Stripe Payment を使用できるようになりました。Salesforce B2C Commerce Cloud から注文を行い、Salesforce Commerce Payments に関連付けられている支払い方法の取引のキャプチャーや返金などを実行できます。 ## 次のステップ - [運用とメンテナンス](https://docs.stripe.com/use-stripe-apps/salesforce-order-management/operations-and-maintenance.md) - [テスト](https://docs.stripe.com/use-stripe-apps/salesforce-order-management/testing.md)