Pay by Bank payments招待のみ
Learn how to accept Pay by Bank payments.
注意
We recommend that you follow the Accept a payment guide unless you need to use manual server-side confirmation, or your integration requires presenting payment methods separately. If you’ve already integrated with Elements, see the Payment Element migration guide.
Pay by Bank is a single use payment method where customers must authenticate their payment. Pay by Bank redirects customers from your website, authorizes the payment, and returns them to your website. You receive notification of whether a payment succeeded or failed within a few seconds.
注
Pay by Bank は遅延通知型の支払い方法であるため、支払い後すぐには売上が利用可能になりません。通常、支払いがお客様のアカウントに入金されるまでに 5 seconds かかります。
Set up StripeServer-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
PaymentIntent を作成するServer-side
A PaymentIntent is an object that represents your intent to collect payment from a customer and tracks the lifecycle of the payment process through each stage.
First, create a PaymentIntent
on your server and specify the amount to collect and the gbp
currency (Pay by Bank doesn’t support other currencies). If you already have an integration using the Payment Intents API, add pay_by_bank
to the list of payment method types for your PaymentIntent
. Stripe enables the functionality that automatic_payment_methods
provides by default in the latest version of the API.
- You can either use the automatic_payment_methods attribute or add
pay_by_bank
to payment method types. - いずれのオプションを選択する場合でも、必ず Pay by Bank を
- ダッシュボードの決済手段の設定ページで有効にしてください。
You can manage payment methods from the Dashboard. Stripe handles the return of eligible payment methods based on factors such as the transaction’s amount, currency, and payment flow. Make sure to enable Pay by Bank on the payment methods settings page in the Dashboard. To manually specify payment method types, add pay_by_bank
to payment method types.
要件
- 最低金額は 0.50 GBP、最高金額は 10,000 GBP です (上限の増額を希望する場合は、Stripe にお問い合わせください)。
- Enter a
statement_descriptor
(optional). This is the merchant name shown on the customer’s bank statement. It has a limit of 18 characters and consists only of alphanumeric values and spaces. If this field is left blank, a shortened version of the Stripe statement descriptors appears on the bank statement.
client secret を取得する
PaymentIntent には、client secret が含まれています。これは、支払いプロセスを安全に完了するためにクライアント側で使用されます。client secret をクライアント側に渡す際は、いくつかの方法を使用できます。
Stripe に支払いを送信するクライアント側
When a customer clicks to pay with Pay by Bank, use Stripe.js to submit the payment to Stripe. Stripe.js is the foundational JavaScript library for building payment flows. It automatically handles complexities like the redirect described below, and enables you to extend your integration to other payment methods. Include the Stripe.js script on your checkout page by adding it to the head
of your HTML file.
<head> <title>Checkout</title> <script src="https://js.stripe.com/v3/"></script> </head>
決済ページで以下の JavaScript を使用して、Stripe.js のインスタンスを作成します。
また、Stripe.js で Pay by Bank を使用するには、ベータフラグ pay_by_bank_beta_1
を指定する必要もあります。
// Set your publishable key. Remember to change this to your live publishable key in production! // See your keys here: https://dashboard.stripe.com/apikeys const stripe = Stripe(
, {betas: ['pay_by_bank_beta_1']} );'pk_test_TYooMQauvdEDq54NiTphI7jx'
Stripe.js で確定する
Rather than sending the entire PaymentIntent object to the client, use its client secret from step 2. This is different from your API keys that authenticate Stripe API requests.
client secret は支払いを確定できるため、慎重に取り扱う必要があります。記録したり、URL に埋め込んだり、当該の顧客以外に公開されることがないようにしてください。
Use stripe.confirmPayByBankPayment to handle the redirect away from your page and to complete the payment. Add a return_url
to this function to instruct Stripe where to redirect the user after they complete the payment.
const {error} = await stripe.confirmPayByBankPayment( '{{PAYMENT_INTENT_CLIENT_SECRET}}', { return_url: 'https://example.com/checkout/complete', } );
顧客が支払いを送信すると、Stripe は顧客を return_url
にリダイレクトし、以下の URL クエリーパラメーターを含めます。返品ページでは、これらを使用して PaymentIntent のステータスを取得し、顧客に支払いステータスを表示できます。
return_url
を指定する際に、返品ページで使用する独自のクエリパラメーターを追加することもできます。
パラメーター | 説明 |
---|---|
payment_intent | PaymentIntent の一意の識別子。 |
payment_intent_client_secret | The client secret of the PaymentIntent object. |
顧客が自社のサイトにリダイレクトされたら、payment_intent_client_secret
を使用して PaymentIntent をクエリし、顧客に取引ステータスを表示できます。
組み込みをテストする
When using your test API keys, you’re redirected to a test page with options to authorize or fail the payment.
- Authorize test payment (テスト支払いをオーソリする) をクリックして、支払い成功のケースをテストします。PaymentIntent が
requires_action
からsucceeded
に変わります。 - Fail test payment (テスト支払いを失敗させる) をクリックして、顧客の認証失敗のケースをテストします。PaymentIntent が
requires_action
からrequires_payment_method
に変わります。
Handle post-payment events
Stripe sends a payment_intent.succeeded event when the payment completes. Use the Dashboard, a custom webhook, or a partner solution to receive these events and run actions, like sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.
クライアントからのコールバックを待つのではなく、これらのイベントをリッスンします。クライアントでは、コールバックが実行される前に顧客がブラウザーのウィンドウを閉じたり、アプリを終了することがあり、また悪意を持つクライアントがレスポンスを不正操作することもあります。非同期型のイベントをリッスンするよう実装を設定することで、これ以降はより多くの決済手段を簡単に受け付けられるようになります。サポートされているすべての決済手段の相違点については、決済手段ガイドをご確認ください。
手動
Stripe ダッシュボードは、すべての Stripe 支払いの確認、メールでの領収書の送信、入金処理、または失敗した支払いの再試行に使用できます。
カスタムコード
Webhook ハンドラを作成してイベントをリッスンし、カスタムの非同期決済フローを作成します。Stripe CLI を使用し、ローカルで Webhook 組み込みのテストとデバッグを行います。
事前構築のアプリ
オートメーションやマーケティングとセールスなどの一般的なビジネスイベントを、パートナーアプリケーションとの連携によって処理します。
Fulfill the orderServer-side
Use a method such as webhooks to handle order fulfillment. When a customer completes payment, the PaymentIntent
transitions to succeeded
and emits the payment_intent.succeeded webhook event.
You can find details about the bank account the customer used to complete the payment on the resulting Charge under the payment_method_details property.
{ "charges": { "data": [ { "payment_method_details": { "pay_by_bank": { "bank_account_details_type": "sort_code", "sort_code": { "account_holder_name": "John Doe", "account_number_last4": "1820", "sort_code": "040004" } }, "type": "pay_by_bank" },
If a customer cancels the payment flow, the PaymentIntent
emits the payment_intent.payment_failed webhook event and returns to a status of requires_payment_method
.