# Charges API と PaymentIntents API

Stripe の 2 つの主要な支払い API の違いと、それぞれを使用するタイミングは以下のとおりです。

## Stripe の支払いのための API について

現在 Stripe で支払いを受け付けるには、3 通りの方法があります。

- *Stripe Checkout* (A low-code payment integration that creates a customizable form for collecting payments. You can embed Checkout directly in your website, redirect customers to a Stripe-hosted payment page, or create a customized checkout page with Stripe Elements)
- *Payment Intents API* (The Payment Intents API tracks the lifecycle of a customer checkout flow and triggers additional authentication steps when required by regulatory mandates, custom Radar fraud rules, or redirect-based payment methods)
- Charges API (決済の作成用としては非推奨)

[Stripe Checkout](https://docs.stripe.com/payments/checkout.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)を簡単にするために顧客をこのページにリダイレクトできます。Apple Pay、Google Pay、国際化、フォーム検証など、多くの機能を提供します。

[Payment Intents API](https://docs.stripe.com/payments/payment-intents.md) は、すべての Stripe プロダクトと決済手段を統合する API です。カスタムの決済フローとエクスペリエンスを構築できます。新機能は Payment Intents API でのみ利用可能です。

> #### Deprecated
> 
> Stripe では、カード決済を作成するための Charges API の使用が非推奨になり、サポートの終了が予定されています。代わりに [Checkout](https://docs.stripe.com/payments/checkout.md) または [Payment Intents API](https://docs.stripe.com/payments/payment-intents.md) を使用してください。新しい実装では、Charges API を使用した決済の作成には対応していません。
> 
> Charges API は、以下の機能をサポートしていません。これらの多くはクレジットカードのコンプライアンスのために必要となります。
> 
> - インドに拠点を置く事業者
> - [カード認証に関する銀行のリクエスト](https://docs.stripe.com/payments/cards/overview.md)
> - [強力な顧客認証 (SCA)](https://docs.stripe.com/strong-customer-authentication.md)

## 支払いから読み取るコードを移行する

アプリケーションに複数の決済フローがあり、それらを Charges API から Payment Intents API に段階的に移行する場合は、まず [Charge](https://docs.stripe.com/api/charges.md) オブジェクトから読み取るコードを更新してください。この移行を容易にするため、Charge オブジェクトには [payment_method_details](https://docs.stripe.com/api/charges/object.md#charge_object-payment_method_details) および [billing_details](https://docs.stripe.com/api/charges/object.md#charge_object-billing_details) という 2 つの追加プロパティが用意されており、決済に使用された決済手段の詳細を読み取るための一貫したインターフェイスが提供されています。

これらのフィールドは、すべての API バージョン、および Charges API と Payment Intents API の両方で作成された支払いオブジェクトで使用できます。

次の表は、支払いで通常使用されるプロパティと、追加プロパティを使用して同じ情報にアクセスする方法を示しています。

#### カードと銀行口座

| 説明 | 前 | 後 |
| --- | --- | --- |
| 支払いの作成時に使用された支払い方法の詳細 | `charge.source` | `charge.payment_method_details` |
| 支払いに使用された支払い方法の ID | `charge.source.id` | `charge.payment_method` |
| 使用される支払い方法タイプ | `charge.source.object` (`card`、`bank_account` など) | `charge.payment_method_details.type` |
| 支払いの請求先情報 (請求先の郵便番号など) | `charge.source.address_zip` | `charge.billing_details.address.postal_code` |
| カード保有者の名前 | `charge.source.name` | `charge.billing_details.name` |
| 使用されたカードの末尾 4 桁 | `charge.source.last4` | `charge.payment_method_details.card.last4` |
| カードのフィンガープリント | `charge.source.fingerprint` | `charge.payment_method_details.card.fingerprint` |
| セキュリティコード確認ステータス | `charge.source.cvc_check` | `charge.payment_method_details.card.checks.cvc_check` |
| カードブランド値 | `charge.source.brand` は、`American Express`、`Diners Club`、`Discover`、`JCB`、`MasterCard`、`UnionPay`、`Visa` のいずれか | `charge.payment_method_details.card.brand` は、`amex`、`diners`、`discover`、`jcb`、`mastercard`、`unionpay`、`visa` のいずれか |
| Google Pay の enum 値 | `charge.source.tokenization_method` は `android_pay` | `charge.payment_method_details` 内の `card.wallet.type` は `google_pay` |

#### Sources

| 説明 | 前 | 後 |
| --- | --- | --- |
| 支払いの作成時に使用された支払い方法の詳細 | `charge.source` | `charge.payment_method_details` |
| 支払いに使用された支払い方法の ID | `charge.source.id` (3D セキュアが使用される場合には `charge.source.three_d_secure.card`) | `charge.payment_method` |
| 使用される支払い方法タイプ | `charge.source.object == 'source' && charge.source.type` (`charge.source.type` が `three_d_secure` の場合を除く) | `charge.payment_method_details.type` |
| 支払いの請求先情報 (請求先の郵便番号など) | `charge.source.owner.address.postal_code` | `charge.billing_details.address.postal_code` |
| カード保有者の名前 | `charge.source.owner.name` | `charge.billing_details.name` |
| 使用されたカードの末尾 4 桁 | `charge.source.card.last4` `charge.source.three_d_secure.last4` | `charge.payment_method_details.card.last4` |
| 3D セキュアが成功したかどうか | `charge.source.object == 'source' && charge.source.type == 'three_d_secure'` | `charge.payment_method_details.card.three_d_secure.succeeded` |
| カードのフィンガープリント | `charge.source.card.fingerprint` | `charge.payment_method_details.card.fingerprint` |
| セキュリティコード確認ステータス | `charge.source.card.cvc_check` | `charge.payment_method_details.card.checks.cvc_check` |
| カードブランド値 | `charge.source.card.brand` は、`American Express`、`Diners Club`、`Discover`、`JCB`、`MasterCard`、`UnionPay`、`Visa` のいずれか | `charge.payment_method_details.card.brand` は、`amex`、`diners`、`discover`、`jcb`、`mastercard`、`unionpay`、`visa` のいずれか |
| Google Pay の enum 値 | `charge.source.card.tokenization_method` は `android_pay` | `charge.payment_method_details` 内の `card.wallet.type` は `google_pay` |

## See also

- [Payment Intents への移行](https://docs.stripe.com/payments/payment-intents/migration.md)
