# Billing API について Billing API オブジェクトの連携方法を理解します。 Connect プラットフォームが [customer-configured Accounts](https://docs.stripe.com/api/v2/core/accounts/create.md#v2_create_accounts-configuration-customer) を使用している場合は、Stripe の [ガイド](https://docs.stripe.com/connect/use-accounts-as-customers.md)をご確認の上、コード内の `Customer` およびイベント参照を同等の Accounts v2 API リファレンスに置き換えてください。 *サブスクリプション* (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)は*請求書* (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)と *Payment Intents* (API object that represents your intent to collect payment from a customer, tracking charge attempts and payment state changes throughout the process) を自動的に作成します。サブスクリプションには、以下のパーツが含まれています。 - 販売対象をモデル化する*商品* (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)。 - 毎回の継続支払いの実行に使用される*支払い方法* (PaymentMethods represent your customer's payment instruments, used with the Payment Intents or Setup Intents APIs)を格納する*顧客* (Customer objects represent customers of your business. They let you reuse payment methods and give you the ability to track multiple payments)。 一般的な Billing オブジェクトとその関係を示した図 (See full diagram at https://docs.stripe.com/billing/billing-apis) ## API オブジェクトの定義 | リソース | 定義 | | ----------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [Customer (顧客)](https://docs.stripe.com/api/customers.md) | サブスクリプションを購入する顧客を表します。サブスクリプションに関連付けられた Customer オブジェクトを使用して、継続支払いを作成して追跡し、顧客が登録する商品を管理します。 | | [Entitlement (エンタイトルメント)](https://docs.stripe.com/api/entitlements/active-entitlement.md) | 顧客が登録したサービス商品に含まれる機能への顧客のアクセスを表します。顧客の商品の継続購入のサブスクリプションを作成すると、その商品に関連付けられた機能ごとに、有効な権利が自動的に作成されます。顧客がサービスにアクセスするときに、その有効な資格を使用して、サブスクリプションに含まれる機能を有効にします。 | | [Feature (機能)](https://docs.stripe.com/api/entitlements/feature.md) | 顧客がサービス商品に登録すると利用できる機能や機能を表します。ProductFeatures を作成することで、商品に機能を含めることができます。 | | [Invoice (請求書)](https://docs.stripe.com/api/invoices.md) | 顧客が支払うべき金額の明細書であり、下書きから支払い済み、またはその他の方法で確定された支払いステータスを追跡します。サブスクリプションでは請求書が自動的に生成されます。 | | [PaymentIntent](https://docs.stripe.com/api/payment_intents.md) | 動的な支払いフローを構築する方法です。Payment Intent は、顧客の決済フローのライフサイクルを追跡し、規制で必須とされる同意書、Radar のカスタムの不正利用ルール、またはリダイレクトベースの支払い方法によって要求されたときに、追加の認証ステップを開始します。Payment Intent は、請求書によって自動的に作成されます。 | | [PaymentMethod](https://docs.stripe.com/api/payment_methods.md) | 顧客が商品の支払いに使用する決済手段。たとえば、クレジットカードを Customer オブジェクトに保存して、その顧客の継続支払いに使用できます。通常、Payment Intents API または Setup Intents API とともに使用されます。 | | [Price (価格)](https://docs.stripe.com/api/prices.md) | 商品の単価、通貨、請求期間を定義します。 | | [Product (商品)](https://docs.stripe.com/api/products.md) | お客様のビジネスが販売する商品またはサービス。サービス商品には 1 つ以上の機能を含めることができます。 | | [ProductFeature](https://docs.stripe.com/api/product-feature.md) | 1 つの商品に 1 つの機能が含まれることを表します。各商品は、含まれる各機能の ProductFeature に関連付けられ、各機能は、それを含む各商品の ProductFeature に関連付けられます。 | | [Subscription (サブスクリプション)](https://docs.stripe.com/api/subscriptions.md) | 顧客の商品の継続的な購入を表します。サブスクリプションを使用して、支払いを回収し、商品の繰り返し提供や継続的なアクセスを提供します。 | 製品、機能、利用権がどのように連携するかの例をご紹介します。例えば、基本機能を提供する標準プランと、拡張機能を追加した上位プランの 2 つのプランを持つ定期サービスを設定するとします。 1. `basic_features` と `extended_features` の 2 つの機能を作成します。 1. `standard_product` と `advanced_product` の 2 つの商品を作成します。 1. 標準商品の場合、`basic_features` を `standard_product` に関連付ける ProductFeature を 1 つ作成します。 1. 高度な商品の場合、2 つの ProductFeatures を作成します。1 つは `basic_features` を `advanced_product` に関連付け、もう 1 つは `extended_features` を `advanced_product` に関連付けます。 顧客の `first_customer` は、標準商品に登録します。サブスクリプションを作成すると、Stripe は、`first_customer` を `basic_features` に関連付けるエンタイトルメントを自動的に作成します。 別の顧客no `second_customer` は高度な商品に登録します。 サブスクリプションを作成すると、Stripe は自動的に 2 つのエンタイトルメントを作成します。1 つは `second_customer` を `basic_features` に関連付け、もう 1 つは `second_customer` を `extended_features` に関連付けます。 [有効なエンタイトルメントを取得するか、有効なエンタイトルメントのサマリーイベントをリッスンする](https://docs.stripe.com/billing/entitlements.md#entitlements)ことで、顧客に提供する機能を決定できます。顧客のサブスクリプション、商品、機能を取得する必要はありません。