# 顧客の電話番号を収集する 顧客が支払いを行うときに、配送や請求処理のために電話番号を収集します。 # ホスト型ページ > This is a ホスト型ページ for when payment-ui is stripe-hosted. View the full page at https://docs.stripe.com/payments/checkout/phone-numbers?payment-ui=stripe-hosted. 電話番号の収集は、`payment` および `subscription` [モード](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-mode) セッションのすべてで有効にできます(`setup` モードでは、電話番号の収集はサポートされていません)。電話番号は取引に必要な場合のみ収集します。 ## 電話番号の収集を有効にする 電話番号の収集を有効にするには、Checkout セッションを作成する際に、[phone_number_collection[enabled]](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-phone_number_collection-enabled) を `true` に設定します。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price_data][unit_amount]=1000" \ -d "line_items[0][price_data][product_data][name]=T-shirt" \ -d "line_items[0][price_data][currency]=eur" \ -d "line_items[0][quantity]=2" \ -d "phone_number_collection[enabled]=true" \ -d mode=payment \ --data-urlencode "success_url=https://example.com/success" ``` 電話番号の収集が有効になっている場合、Checkout は、支払いフォームに「必須の」電話番号フィールドを追加します。配送先住所を収集する場合には、住所フィールドの下に電話番号フィールドが表示されます。それ以外の場合には、Checkout はメールアドレスの入力フィールドの下に電話番号のフィールドを表示します。顧客は 1 回のセッションで電話番号を 1 件のみ入力できます。 ## 電話番号を取得する 顧客が [Apple Pay](https://docs.stripe.com/apple-pay.md) や [Google Pay](https://docs.stripe.com/google-pay.md) などのサードパーティーのウォレットで決済する場合、これらのプラットフォームの制限により、電話番号の形式は一定ではなくなります。サードパーティーのウォレットから提供された電話番号の値が返されます。 顧客が[ウォレット決済](https://docs.stripe.com/payments/wallets.md)を使用しない場合、電話番号は必ず [E.164](https://en.wikipedia.org/wiki/E.164) 形式になります。 セッション後、*Customer* (Customer objects represent customers of your business. They let you reuse payment methods and give you the ability to track multiple payments) オブジェクトまたは *Checkout Session* (A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout. After a successful payment, the Checkout Session contains a reference to the Customer, and either the successful PaymentIntent or an active Subscription) オブジェクトから顧客の電話番号を取得できます。 - [Customer の動作](https://docs.stripe.com/api/customers.md):Checkout は、収集された電話番号を Customer オブジェクトの [phone](https://docs.stripe.com/api/customers/object.md#customer_object-phone) プロパティに保存します。これは、[API](https://docs.stripe.com/api/customers/retrieve.md) で Customer オブジェクトを直接取得してプログラムでアクセスするか、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) で [customer.created](https://docs.stripe.com/api/events/types.md#event_types-customer.created) イベントをリッスンして取得できます。顧客の電話番号は、[ダッシュボード](https://dashboard.stripe.com/customers)で確認することもできます。 - [Checkout Session の動作](https://docs.stripe.com/api/checkout/sessions.md):顧客の電話番号は、Checkout Session オブジェクトの [customer_details](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-customer_details) ハッシュの [customer_details.phone](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-customer_details-phone) にも保存されます。Checkout セッションが成功すると毎回、Stripe は Checkout Session オブジェクト (および電話番号) が含まれた [checkout.session.completed](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.completed) イベントを送信します。これは、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) でリッスンできます。 ## 既存の顧客の電話番号を収集する [phone](https://docs.stripe.com/api/customers/object.md#customer_object-phone) プロパティが入力された既存の [Customer (顧客)](https://docs.stripe.com/api/customers.md) を [Checkout Session (Checkout セッション)](https://docs.stripe.com/api/checkout/sessions.md) に渡すと、電話番号フィールドが事前入力されます。 顧客が電話番号を更新した場合、更新された値は [Customer オブジェクト](https://docs.stripe.com/api/customers.md) の [phone](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-phone) プロパティに保持され、以前に保存された電話番号はすべて上書きされます。 ### カスタマーポータルで電話番号を更新する カスタマーポータルでは、顧客自らアカウントを管理させることができます ([電話番号の更新](https://docs.stripe.com/api/customer_portal/configurations/create.md#create_portal_configuration-features-customer_update-allowed_updates)など)。 ## See also - [カスタマーポータルを実装する](https://docs.stripe.com/customer-management.md) # 埋め込み型ページ > This is a 埋め込み型ページ for when payment-ui is embedded-form. View the full page at https://docs.stripe.com/payments/checkout/phone-numbers?payment-ui=embedded-form. 電話番号の収集は、`payment` および `subscription` [モード](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-mode) セッションのすべてで有効にできます(`setup` モードでは、電話番号の収集はサポートされていません)。電話番号は取引に必要な場合のみ収集します。 ## 電話番号の収集を有効にする 電話番号の収集を有効にするには、Checkout セッションを作成する際に、[phone_number_collection[enabled]](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-phone_number_collection-enabled) を `true` に設定します。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d "line_items[0][price_data][unit_amount]=1000" \ -d "line_items[0][price_data][product_data][name]=T-shirt" \ -d "line_items[0][price_data][currency]=eur" \ -d "line_items[0][quantity]=2" \ -d "phone_number_collection[enabled]=true" \ -d mode=payment \ -d ui_mode=embedded_page \ --data-urlencode "return_url=https://example.com/return" ``` 電話番号の収集が有効になっている場合、Checkout は、支払いフォームに「必須の」電話番号フィールドを追加します。配送先住所を収集する場合には、住所フィールドの下に電話番号フィールドが表示されます。それ以外の場合には、Checkout はメールアドレスの入力フィールドの下に電話番号のフィールドを表示します。顧客は 1 回のセッションで電話番号を 1 件のみ入力できます。 ## 電話番号を取得する 顧客が [Apple Pay](https://docs.stripe.com/apple-pay.md) や [Google Pay](https://docs.stripe.com/google-pay.md) などのサードパーティーのウォレットで決済する場合、これらのプラットフォームの制限により、電話番号の形式は一定ではなくなります。サードパーティーのウォレットから提供された電話番号の値が返されます。 顧客が[ウォレット決済](https://docs.stripe.com/payments/wallets.md)を使用しない場合、電話番号は必ず [E.164](https://en.wikipedia.org/wiki/E.164) 形式になります。 セッション後、*Customer* (Customer objects represent customers of your business. They let you reuse payment methods and give you the ability to track multiple payments) オブジェクトまたは *Checkout Session* (A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout. After a successful payment, the Checkout Session contains a reference to the Customer, and either the successful PaymentIntent or an active Subscription) オブジェクトから顧客の電話番号を取得できます。 - [Customer の動作](https://docs.stripe.com/api/customers.md):Checkout は、収集された電話番号を Customer オブジェクトの [phone](https://docs.stripe.com/api/customers/object.md#customer_object-phone) プロパティに保存します。これは、[API](https://docs.stripe.com/api/customers/retrieve.md) で Customer オブジェクトを直接取得してプログラムでアクセスするか、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) で [customer.created](https://docs.stripe.com/api/events/types.md#event_types-customer.created) イベントをリッスンして取得できます。顧客の電話番号は、[ダッシュボード](https://dashboard.stripe.com/customers)で確認することもできます。 - [Checkout Session の動作](https://docs.stripe.com/api/checkout/sessions.md):顧客の電話番号は、Checkout Session オブジェクトの [customer_details](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-customer_details) ハッシュの [customer_details.phone](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-customer_details-phone) にも保存されます。Checkout セッションが成功すると毎回、Stripe は Checkout Session オブジェクト (および電話番号) が含まれた [checkout.session.completed](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.completed) イベントを送信します。これは、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) でリッスンできます。 ## 既存の顧客の電話番号を収集する [phone](https://docs.stripe.com/api/customers/object.md#customer_object-phone) プロパティが入力された既存の [Customer (顧客)](https://docs.stripe.com/api/customers.md) を [Checkout Session (Checkout セッション)](https://docs.stripe.com/api/checkout/sessions.md) に渡すと、電話番号フィールドが事前入力されます。 顧客が電話番号を更新した場合、更新された値は [Customer オブジェクト](https://docs.stripe.com/api/customers.md) の [phone](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-phone) プロパティに保持され、以前に保存された電話番号はすべて上書きされます。 ### カスタマーポータルで電話番号を更新する カスタマーポータルでは、顧客自らアカウントを管理させることができます ([電話番号の更新](https://docs.stripe.com/api/customer_portal/configurations/create.md#create_portal_configuration-features-customer_update-allowed_updates)など)。 ## See also - [カスタマーポータルを実装する](https://docs.stripe.com/customer-management.md)