PaymentIntents と SetupIntents の仕組み
決済フローで PaymentIntents と SetupIntents がどのように機能するかをご紹介します。
The main difference between the Payment Intents API and Setup Intents API is their purpose:
- Payment Intents API: Used to collect payment and charge a customer immediately. It creates a charge and processes a transaction to collect funds.
- Setup Intents API: Used to collect and save payment method details for future use without creating a charge. Sets up payment credentials without processing any payment.
Payment Intent API | Setup Intents API |
---|---|
Creates an immediate charge | Creates no charge |
Tracks a payment’s lifecycle | Tracks the progress of setting up a payment method |
Uses 3D secure to authenticate the customer for the applicable transaction | Uses 3D secure to authenticate a payment method without charging it, and creates a mandate or agreement for future charges |
Asynchronous payments can be challenging to manage because they can depend on customer actions that happen outside of your application. For example, a user might need to confirm a payment using 3D Secure.
To simplify payment management, Stripe uses a state machine that allows you to track the state of a payment flow. To learn the states for each API, select the applicable tab below:
PaymentIntent が作成されると、支払い方法が関連付けられるまで、ステータスは requires_
1 になります。
請求金額が分かり次第、PaymentIntent を作成することをお勧めします。これにより、支払いの試行をすべて Stripe で記録することができます。
顧客が支払い情報を入力したら、PaymentIntent を確定できます。
通常、組み込みでは支払い方法の情報が支払いの確定と同時に送信されるため、この状態はスキップされます。
3D セキュアでの認証など、支払いに追加アクションが必要な場合、PaymentIntent のステータスは requires_
1 になります。
口座引き落としなどの非同期の支払い方法の場合、必要なアクションの処理が終わると、PaymentIntent は processing
に移行します。このようなタイプの支払い方法では、処理に最大で数日かかることがあります。カードなど他の支払い方法の場合は処理がスピーディーで、processing
ステータスにはなりません。
売上のオーソリとキャプチャーを個別に行っている場合は、代わりに PaymentIntent を requires_
に移行できます。その場合、売上のキャプチャーを試行すると、ステータスは processing
に移行します。
PaymentIntent のステータスが succeeded の場合は、その決済フローが完了していることを意味します。
売上がお客様のアカウントに入金されていることを確認できたため、確信を持って注文のフルフィルメントを実行できます。顧客に返金する必要がある場合は、Refunds API を使用できます。
支払い処理が失敗した場合 (支払い拒否など)、支払いを再試行できるように PaymentIntent のステータスは requires_
に戻ります。
PaymentIntent は、processing
2 または succeeded
ステータスより前の任意の時点でキャンセルできます。キャンセルすると、今後の支払い処理で PaymentIntent は無効になり、これを取り消すことはできません。売上が保留されている場合は、キャンセルすると売上はリリースされます。
PaymentIntent は、過剰な回数が確定されると自動的に canceled
ステータスに移行する場合もあります。
1 2019-02-11 以前の API のバージョンでは、requires_
の代わりに requires_
、requires_
の代わりに requires_
が表示されます。
2 関連付けられている支払い方法がアメリカの銀行口座であるときは、processing
ステータスの PaymentIntent をキャンセルできます。ただし、キャンセル期間は限定的かつ多様なため、キャンセルが失敗することもあります。