# Stripe app for Salesforce Platform の呼び出し このガイドではすぐに使用できるコード例を用いて、Stripe の顧客の作成、Checkout セッションの開始、既存の顧客のリッスンといった重要な作業をすべて Salesforce から直接実行する手順を説明します。Salesforce の管理者、開発者、そして Stripe と Salesforce のシームレスな連携に関心をお持ちの方を対象としています。これらの例では、Stripe API コールを使用したクラスベースの呼び出しに、カスタム Apex クラスを用いています。新たな EC ストアソリューションを構築している場合でも、決済ワークフローを構築している場合でも、このガイドは Salesforce での効率的な Stripe 操作に必要なツールを提供します。 ## Stripe で顧客を作成する 次のコード例では、`name`、`email`、`metadata` を設定して Stripe の[顧客](https://docs.stripe.com/api/customers.md)を作成します。 #### Java ```java // Step 1: Initialize an instance of the stripeGC.v01_CreateCustomers.V1 class stripeGC.CreateCustomers.V1 params = new stripeGC.CreateCustomers.V1(); List paramsCollection = new List{ params }; // Step 2: Set the accountRecordId parameter to the record ID of the Stripe Account you wish to connect to params.accountRecordId = 'a028B0000029RhlQAE'; // Step 3: Set the metadata field stripeGC.Metadata metadata = new stripeGC.Metadata(); metadata.listAdditionalStringField = new List{ new stripeGC.AdditionalString('AccountID', 'abc123') }; params.metadata = metadata; // Step 4: Set the name field params.name = 'Tim Smith'; // Step 5: Set the email field params.email = 'example@example.com'; // Step 6: Call the stripeGC.v01_PostCustomers.postCustomers_2022_11_15 method List customers = stripeGC.v01_CreateCustomers.createCustomers_2022_11_15(paramsCollection); ``` ## Checkout セッションを作成する 次のコード例は Stripe で Checkout セッションを作成します。 #### Java ```java // Step 1: Initialize an instance of the stripeGC.v01_CreateCheckoutSessions.V1 class stripeGC.CreateCheckoutSessions.V1 params = new stripeGC.CreateCheckoutSessions.V1(); List paramsCollection = new List{ params }; // Step 2: Set the accountRecordId parameter to the record ID of the Stripe Account you wish to connect to params.accountRecordId = 'a028B0000029RhlQAE'; // Step 3: Set the checkout line items stripeGC.CreateCheckoutSessionsReqLineItem cliparams = new stripeGC.CreateCheckoutSessionsReqLineItem(); cliparams.price = 'price_1NhcVkBSPQ8HL343ZNsBp'; //price id from Stripe. cliparams.quantity = 1; List cliparamlist = new List(); cliparamlist.add(cliparams); params.lineItems = cliparamlist; // Step 4: Set mode,successurl,client ref fields params.mode = 'payment'; params.successUrl = 'https://stripe.com'; params.clientReferenceId = 'abcd123'; // Step 5: Call the stripeGC.v01_CreateCheckoutSessions.CreateCheckoutSessions_2022_11_15 method List results = stripeGC.v01_CreateCheckoutSessions.createCheckoutSessions_2022_11_15(paramsCollection); ``` ### 顧客をリストに表示する 次のコード例は、Stripe に保存されているすべての顧客をリストに表示します。 ```java // Step 1: Initialize an instance of the stripeGC.v01_ListCustomers.V1 class stripeGC.ListCustomers.V1 params = new stripeGC.ListCustomers.V1(); List paramsCollection = new List{ params }; // Step 2: Set the accountRecordId parameter to the record ID of the Stripe Account you wish to connect to params.accountRecordId = 'a028B0000029RhlQAE'; // Step 3: Call the stripeGC.v01_ListCustomers.listCustomers_2022_11_15 method List results = stripeGC.v01_ListCustomers.listCustomers_2022_11_15(paramsCollection); System.debug(results[0]); ``` ## See also - [インストールガイド](https://docs.stripe.com/use-stripe-apps/stripe-app-for-salesforce/installation-guide.md) - [イネーブルメントビデオ](https://docs.stripe.com/use-stripe-apps/stripe-app-for-salesforce/training.md) - [イベントを設定](https://docs.stripe.com/use-stripe-apps/stripe-app-for-salesforce/configure-events.md)