# Setup Intents API

支払い方法を保存するための Setup Intents API についてご紹介します。

*Setup Intents API* (The Setup Intents API lets you build dynamic flows for collecting payment method details for future payments. It tracks the lifecycle of a payment setup flow and can trigger additional authentication steps if required by law or by the payment method) を使用し、将来の支払いに使用する支払い方法を設定します。支払いと類似していますが、請求は作成されません。[今すぐ将来の支払い用に備えて、支払い方法を設定しましょう](https://docs.stripe.com/payments/save-and-reuse.md)。

The goal is to have payment credentials saved and optimized for future payments, meaning the payment method is configured correctly for any scenario. When setting up a card, for example, it might be necessary to authenticate the customer or check the card’s validity with the customer’s bank. Stripe updates the `SetupIntent` object throughout that process.

## 支払い方法を保存して再利用する

Setup Intents API は、以下のような、顧客をアカウント登録してもすぐには請求が発生しないビジネスで使用すると便利です。

- 顧客がレンタカーを借りる前に支払い方法の詳細を収集し、レンタル期間が終了してからカードに請求するレンタカー会社
- カードの詳細を収集しておき、キャンペーンが一定額に達した場合にのみ、実際の請求を行うクラウドファンディングのウェブサイト
- 使用量に基づいて月ごとに請求金額が異なり、最初の月の支払いの前に SEPA 支払いの詳細を収集する公共事業会社

> 決済手段は、[Checkout](https://docs.stripe.com/payments/save-and-reuse.md?platform=checkout) 時に請求する際に、将来使用できるように設定することもできます。

#### 始める

- [当初の支払いなしでカードを保存する](https://docs.stripe.com/payments/save-and-reuse.md)
- [SEPA ダイレクトデビット支払い用の銀行詳細を保存する](https://docs.stripe.com/payments/sepa-debit/set-up-payment.md)
- [BECS ダイレクトデビット支払い用の銀行詳細を保存する](https://docs.stripe.com/payments/au-becs-debit/set-up-payment.md)

## 決済手段を保存する許可を得る

顧客の決済情報を保存する場合、適用されるすべての法律、規制、ネットワーク規則を遵守する責任があります。

### 将来のオンセッションでの使用

将来の決済画面に決済手段を表示するなど、将来の *オンセッション* 決済に備えて決済手段を設定する場合は、この特定の使用について顧客から明示的に同意を収集する必要があります。たとえば、同意を収集するには、「決済手段を将来の使用のために保存する」チェックボックスを含めます。

オフラインでの使用のみのために保存された決済手段と、将来の *オンセッション* の購入で顧客に提示できる決済手段を区別する必要がある場合は、PaymentMethod オブジェクトの [allow_redisplay](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-allow_redisplay) パラメータを使用できます。

### 将来のオフセッションでの使用

将来の*オフセッション* (A payment is described as off-session if it occurs without the direct involvement of the customer, using previously-collected payment information)支払いの支払い方法を設定する場合は、許可が必要です。あらかじめ契約 (「同意書」とも呼ばれます) を作成しておくことで、顧客がお客様のウェブサイトやアプリを能動的に使用していないときでも請求できるようになります。

Add terms to your website or app that state how you plan to process payments, and let customers opt in. At a minimum, make sure that your terms cover the following:

- 顧客の代理として単独の支払いまたは一連の支払いを開始することを許可する、顧客からお客様への許可
- 予測される支払い頻度 (1 回限り、継続など)
- 支払い金額の決定方法

[カードの保存](https://docs.stripe.com/payments/save-and-reuse.md?platform=web&ui=elements&payment-ui=elements#collect-payment-details)または[SEPA 口座情報の保存](https://docs.stripe.com/payments/sepa-debit/set-up-payment.md)に関して推奨される同意書のテキストをご覧ください。

*SCA* (Strong Customer Authentication (SCA) is a regulatory requirement in effect as of September 14, 2019, that impacts many European online payments. It requires customers to use two-factor authentication like 3D Secure to verify their purchase) の影響を受けるユーザーは、この契約を使用することで、支払いを中断なく成功させることが可能になります。カードが適切に保存されるように組み込みを設定すると、Stripe は、その後のオフセッション支払いを*加盟店が開始した取引* (A payment made off-session with a properly authenticated saved card, can qualify as merchant-initiated transaction and be exempt from SCA) (MIT) としてマークし、顧客がオンラインに戻って認証する必要をなくします。加盟店が開始した取引には、お客様と顧客間の契約が必要です。

## 使用目的を指定して成功率を向上させる

[usage](https://docs.stripe.com/api/setup_intents/object.md#setup_intent_object-usage) パラメーターによって、後で決済手段の詳細をどのように使用する予定かが Stripe に伝わります。一部の決済手段では、Stripe が `usage` 設定を利用して顧客にとって最もスムーズなフローを選択できるため、支払いの成功数を増やすことができます。

For example, credit and debit cards under European *SCA* (Strong Customer Authentication (SCA) is a regulatory requirement in effect as of September 14, 2019, that impacts many European online payments. It requires customers to use two-factor authentication like 3D Secure to verify their purchase) regulation might require the customer to authenticate the card during the saving process. Setting `usage` to `off_session` properly authenticates a credit or debit card for off-session payments so that your customer doesn’t have to come back online and re-authenticate. So although it creates initial friction in the setup flow, setting `usage` to `off_session` can reduce customer intervention in later off-session payments.

ただし、顧客が購入する際にのみカードを使用する予定の場合は、`usage` を `on_session` に設定します。これにより、顧客が認証できる場合に限り、そのカードを使用することを銀行に知らせることができます。これにより、カード詳細の認証をその時点まで延ばし、事前の負担を避けることができます。

| カードの使用計画 | 使用する Usage 列挙値 |
| --- | --- |
| *オンセッション* (A payment is described as on-session if it occurs while the customer is actively in your checkout flow and able to authenticate the payment method)支払いのみ | `on_session` |
| *オフセッション* (A payment is described as off-session if it occurs without the direct involvement of the customer, using previously-collected payment information)支払いのみ | `off_session` (デフォルト) |
| オンセッション支払いとオフセッション支払いの両方 | `off_session` (デフォルト) |

`Usage` は最適化の 1 つです。オンセッション用に設定されたカードをオフセッション支払いに使用することもできますが、銀行がオフセッション支払いを拒否し、顧客に認証を求める確率が高くなります。いずれの場合も、後で認証が必要になる可能性があるため、アプリには[リカバリプロセスを構築](https://docs.stripe.com/billing/revenue-recovery.md)します。オフセッションのカード支払いで認証が要求される場合は、顧客をオンラインに戻して支払いを完了します。

指定がない場合、`usage` はデフォルトで `off_session` になります。サーバー上で SetupIntent を作成し、`usage` を指定する方法をご覧ください。

```curl
curl https://api.stripe.com/v1/setup_intents \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d usage=on_session
```

> Follow the guidance on this page to make sure your integration handles cards that require *Strong Customer Authentication* (Strong Customer Authentication (SCA) is a regulatory requirement in effect as of September 14, 2019, that impacts many European online payments. It requires customers to use two-factor authentication like 3D Secure to verify their purchase). Correctly flagging transactions allows Stripe to claim correct SCA exemptions on your behalf to minimize the need for authentication with each payment.
