# 銀行振込によるサブスクリプションを設定する 銀行振込を使用したサブスクリプションの作成と請求の方法をご紹介します。 このガイドを参照して、支払い方法に[銀行振込](https://docs.stripe.com/payments/bank-transfers.md)を使用する*サブスクリプション* (A Subscription represents the product details associated with the plan that your customer subscribes to. Allows you to charge the customer on a recurring basis)を設定します。 ## 商品と価格を作成する [ダッシュボード] [サーバー側] *商品* (Products represent what your business sells—whether that's a good or a service)と*価格* (Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the interval if the price is for subscriptions)は、サブスクリプションのコアリソースです。[商品と継続価格を作成](https://docs.stripe.com/products-prices/manage-prices.md#create-product)します。価格 ID は、このガイドの後半で必要になりますので、保存しておきます。 ## 顧客を作成または取得する [サーバー側] まず、有効なメールアドレスを持つ顧客 ([Account](https://docs.stripe.com/api/v2/core/accounts/object.md#v2_account_object-configuration-customer) オブジェクト (顧客設定) または [Customer](https://docs.stripe.com/api/customers/object.md) オブジェクト) がまだ存在しない場合は、作成します。有効なメールアドレスがあれば、送信した請求書を顧客が受け取ることができます。 #### Accounts v2 銀行振込による資金は顧客の [cash balance](https://docs.stripe.com/payments/customer-balance.md) に保持されるため、各銀行振込サブスクリプションに顧客を関連付ける必要があります。顧客設定の `Account` の現金残高を管理するには、アカウント ID をパスパラメータとして Customers API エンドポイントを使用します。たとえば、`v1/customers/acct_xxxxx/cash_balances` です。 ```curl curl -X POST https://api.stripe.com/v2/core/accounts \ -H "Authorization: Bearer <>" \ -H "Stripe-Version: $latestPreviewApiVersion" \ --json '{ "contact_email": "jenny.rosen@example.com", "display_name": "Jenny Rosen", "configuration": { "customer": {} }, "include": [ "configuration.customer" ] }' ``` #### Customers v1 銀行振込による資金は顧客の [cash balance](https://docs.stripe.com/payments/customer-balance.md) に保持されるため、各銀行振込サブスクリプションに [Customer](https://docs.stripe.com/api/customers.md) オブジェクトを関連付ける必要があります。 ```curl curl https://api.stripe.com/v1/customers \ -u "<>:" \ -d "name=Jenny Rosen" \ --data-urlencode "email=jenny.rosen@example.com" ``` ## サブスクリプションを作成する [サーバー側] 前のステップの顧客 ID と料金 ID を使用してサブスクリプションを[作成](https://docs.stripe.com/api/subscriptions/create.md)します。 - [collection_method](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-collection_method) を `send_invoice` に設定します。 - [days_until_due](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-days_until_due) を設定して、顧客が*請求書* (Invoices are statements of amounts owed by a customer. They track the status of payments from draft through paid or otherwise finalized. Subscriptions automatically generate invoices, or you can manually create a one-off invoice)を支払うまでの日数を指定します。 #### Accounts v2 ```curl curl https://api.stripe.com/v1/subscriptions \ -u "<>:" \ -d customer_account={{CUSTOMER_ACCOUNT_ID}} \ -d "items[0][price]={{PRICE_ID}}" \ -d collection_method=send_invoice \ -d days_until_due=30 \ -d "payment_settings[payment_method_types][0]=customer_balance" ``` #### Customers v1 ```curl curl https://api.stripe.com/v1/subscriptions \ -u "<>:" \ -d customer={{CUSTOMER_ID}} \ -d "items[0][price]={{PRICE_ID}}" \ -d collection_method=send_invoice \ -d days_until_due=30 \ -d "payment_settings[payment_method_types][0]=customer_balance" ``` Subscription の支払い期日になると、顧客に請求書が送信されます。顧客の[現金残高](https://docs.stripe.com/payments/customer-balance.md)に十分な資金がある場合、請求書は支払い済みとしてマークされます。十分な資金がない場合、顧客が銀行口座から振り込むために必要な情報が表示されます。この請求書には、[オンライン請求書ページ](https://docs.stripe.com/invoicing/hosted-invoice-page.md)へのリンクも記載されています。以降の請求書は、最初のステップで作成された料金を使用します。 [銀行振込請求](https://docs.stripe.com/invoicing/bank-transfer.md)についてご紹介します。 ## Optional: サブスクリプションのスケジュールを作成する [サーバー側] このサブスクリプションの変更をスケジュールするには、[サブスクリプションスケジュール](https://docs.stripe.com/billing/subscriptions/subscription-schedules.md)を[作成](https://docs.stripe.com/api/subscription_schedules/create.md)します。 [from_subscription](https://docs.stripe.com/api/subscription_schedules/create.md#create_subscription_schedule-from_subscription) に、前のステップのサブスクリプション ID を設定します。 ```curl curl https://api.stripe.com/v1/subscription_schedules \ -u "<>:" \ -d from_subscription={{SUBSCRIPTION_ID}} ``` ## 組み込みをテストする Stripe ダッシュボードまたは CLI を使用して[売上のインバウンド送金](https://docs.stripe.com/payments/bank-transfers/accept-a-payment.md#test-your-integration)をシミュレートします。 お客様が売上を受け取り次第、Stripe は請求書の[自動](https://docs.stripe.com/invoicing/bank-transfer.md#automatic-transfer-reconciliation)または[手動](https://docs.stripe.com/invoicing/bank-transfer.md#manual-reconciliation)消し込みを実行します。