口座を収集して、データを活用する商品を構築する
Financial Connections lets your users securely share their financial data by linking their external financial accounts to your business. You can use Financial Connections to access user-permissioned financial data such as tokenized account and routing numbers, account balances, account owner information, and historical transactions.
以下は、Financial Connections をユーザーの製品の操作性の改善に使用する一般的な例です。
- 銀行口座名義人の名前や住所などの口座の所有権情報を確認することで、顧客またはビジネスのアカウント登録時の不正利用を減らします。
- 取引データによって、ユーザーによる経費の追跡、請求書の処理、財務の管理、財務状況の制御を支援します。
- リスク評価を迅速化して、取引と残高のデータを使用するクレジットやその他の金融サービスへのアクセスを向上させることができます。
ユーザーがより少ないステップで自身のアカウントを Link に関連付け、Stripe のすべての加盟店に銀行口座の詳細を保存して、素早く再利用できるようにします。
口座名義人を作成または取得するサーバー側
Create a Customer object when users create an account with your business. By providing an email address, Financial Connections can optimize the authentication flow by dynamically showing a streamlined user interface, for returning Link users.
curl https://api.stripe.com/v1/customers \ -u "
:" \ -d email={{CUSTOMER_EMAIL}} \ -d name={{CUSTOMER_NAME}}sk_test_4eC39HqLyjWDarjtT1zdp7dc
Financial Connections Session を作成するサーバー側
Financial Connections を使用してユーザーの銀行口座からデータを取得するには、ユーザーが認証フローでその口座を認証する必要があります。
ユーザーは、口座をサイトまたはアプリケーションに関連付けるときに認証フローを開始します。ユーザーが口座を関連付けられるようにするボタン (銀行口座を関連付けるなど) またはリンクをサイトやアプリケーションに挿入します。
/v1/financial_connections/sessions
に送信することで、Financial Connections Session を作成します。
curl https://api.stripe.com/v1/financial_connections/sessions \ -u "
:" \ -d "account_holder[type]"=customer \ -d "account_holder[customer]"=sk_test_4eC39HqLyjWDarjtT1zdp7dc\ -d "permissions[]"=balances \ -d "permissions[]"=ownership \ -d "permissions[]"=payment_method \ -d "permissions[]"=transactions{{CUSTOMER_ID}}
- Set
account_holder[customer]
to the Customerid
. - Set the data
permissions
parameter to include the data required to fulfill your use case. - 「オプション」: アカウント作成時にデータを取得するために
prefetch
パラメーターを設定します。
The permissions parameter controls which account data you can access. You must request at least one permission. When completing the authentication flow, your user can see the data you’ve requested access to, and provide their consent to share it.
Consider the data required to fulfill your use case and request permission to access only the data you need. Requesting permissions that go well beyond your application’s scope might erode your users’ trust in how you use their data. For example, if you’re building a personal financial management application or a lending product, you might request transactions
data. If you’re mitigating fraud such as account takeovers, you might want to request ownership
details.
After your user authenticates their account, you can expand data permissions only by creating a new Financial Connections Session and specifying a new value for the permissions
parameter. Your user must complete the authentication flow again, where they’ll see the additional data you’ve requested permission to access, and provide consent to share their data.
The optional prefetch parameter controls which data you retrieve immediately after the user connects their account. Use this option if you know you always want a certain type of data. It removes the need to make an extra API call to initiate a data refresh.
To preserve the option to accept ACH Direct Debit payments, request the payment_method
permission.
Financial Connections アカウントを収集するクライアント側
返された client_secret
を Stripe.js で使用して、ユーザーが口座を関連付けられるようにします。client_secret
により、クライアント側の Stripe SDK は Financial Connections Session を変更できます。これは、保存したり、ログに記録したり、URL に埋め込んだり、当該エンドユーザー以外の人に公開したりしないでください。client secret が含まれるすべてのページで TLS を有効化するのを忘れないでください。
Use collectFinancialConnectionsAccounts to collect an account.
const stripe = new Stripe(
) const financialConnectionsSessionResult = await stripe.collectFinancialConnectionsAccounts({ clientSecret: "{{SESSION_CLIENT_SECRET}}", });'pk_test_TYooMQauvdEDq54NiTphI7jx'
This method loads the authentication flow, the client-side Stripe.js UI that helps your users link their financial accounts to you and Stripe.
stripe.collectFinancialConnectionsAccounts
の戻り値は Promise です。ユーザーが認証フローを完了すると、Promise は、連結アカウントのリストを含むオブジェクトで解決されます。
{ "financialConnectionsSession": { "id": "fcsess_123", "accounts": [ { "id": "fca_456", "object": "financial_connections.account", "category": "Checking", "display_name": "Premium Checking", "institution_name": "Test Bank", "last4": "4242" } ] } }
If the user connects no accounts, or exits the authentication flow early, the response contains an empty accounts
array.
Successful completion of the authentication flow also sends one financial_connections.account.created
webhook per account connected.