カテゴリー:
documentation
閲覧数:292 配信日:2019-04-25 09:09
docs
Payments > PREPARING FOR SCA > Payment Intents > Usage > Payment Methods API
・Payment Methods Overview
・Payment Methods API
API
・PaymentMethods
Payment Methods API への移行
新しいPayment Methods API
・既存の「Tokens」および「Sources API」に代わる新しい「Payment Methods API」が 、システムによる支払い情報の収集および保存のための推奨方法になった
・これは「Payment Intents API」と連携して、幅広い支払い方法の支払いを作成する
「Payment Methods API」と「Sources API」の主な違い
・Sourceがstatusプロパティを通じてトランザクションの状態を記述することだ。つまり、各Sourceオブジェクトは、支払いに使用する前にchargeable状態に移行する必要がある
・対照的に、PaymentMethodsはステートレスで、特定の支払いの取引状態を表すためにPaymentIntentオブジェクトに依存している
Stripeは最終的にすべての支払い方法を「Payment Methods API」でサポートする予定だ
・それまでの間、Sources APIは、特定の支払い方法が「Payment Methods API」でまだサポートされていない場合に適している
FLOWS | PAYMENT METHODS WITH PAYMENT INTENTS API | TOKENS OR SOURCES WITH CHARGES API |
---|---|---|
Cards | サポート | トークンでサポート ソースにはお勧めできない |
・Stripe: 決済手段ガイド
ソースとカードとの互換性
以前にカードまたは情報源を使用してStripeで顧客カードの詳細を収集したことがある場合は
・支払い情報を移行せずに直ちにPayment Methods APIを使用し始めることができる
!この互換性はカードとカードソースにのみ適用され、一般に既存のすべてのソースタイプには適用されない
!他のタイプのソースと統合している場合は、すぐにそれらのソースでPayment Intents APIを使用できる
顧客に保存されているすべてのカードとすべてのカードソースは
・PaymentMethodオブジェクトを受け入れるすべてのAPIで使用できる
・例えば、PaymentIntentを作成するときに、保存したカードをPaymentMethodとして使用できる
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_xxxx");
StripePaymentIntent::create([
"payment_method_types" => ["card"],
"amount" => 1099,
"currency" => "jpy",
"customer" => "cus_EuDxccEWADyPip",
"payment_method" => "card_1ESZCTJiXAQvfxv33qy49u11",
]);
・オブジェクトをPaymentIntentに添付するときは、カードまたはカードソースが保存されている顧客を忘れずに指定してくれ
保存されたすべてのカードとカードソースは、PaymentMethod APIを介して取得することも出来る
・従来のcardオブジェクト
{
"id": "card_1EBXBSDuWL9wT9brGOaALeD2",
"object": "card",
"address_city": "San Francisco",
"address_country": "US",
"address_line1": "1234 Fake Street",
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"customer": "#{customer_id}",
"cvc_check": null,
"dynamic_last4": null,
"exp_month": 8,
"exp_year": 2024,
"fingerprint": "53v265akSHAnIk1X",
"funding": "credit",
"last4": "4242",
"metadata": {
},
"name": null,
"tokenization_method": null
}
・PaymentMethod APIを介して取得したカード
{
"id": "card_1EBXBSDuWL9wT9brGOaALeD2",
"object": "payment_method",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": null,
"state": null
},
"name": null,
"phone": null,
"email": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": null
},
"country": "US",
"exp_month": 8,
"exp_year": 2024,
"fingerprint": "53v265akSHAnIk1X",
"funding": "credit",
"last4": "4242",
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 123456789,
"customer": "cus_EepWxEKrgMaywv",
"livemode": false,
"metadata": {
},
"type": "card"
}
・従来のsourceオブジェクト
{
"id": "src_1AhIN74iJb0CbkEwmbRYPsd4",
"object": "source",
"amount": null,
"client_secret": "src_client_secret_xxxx",
"created": 1500471469,
"currency": null,
"flow": "none",
"livemode": false,
"metadata": {
},
"owner": {
"address": {
"city": "Berlin",
"country": "DE",
"line1": "Nollendorfstraße 27",
"line2": null,
"postal_code": "10777",
"state": null
},
"email": "jenny.rosen@example.com",
"name": "Jenny Rosen",
"phone": null,
"verified_address": null,
"verified_email": null,
"verified_name": null,
"verified_phone": null
},
"status": "chargeable",
"type": "card",
"usage": "reusable",
"card": {
"exp_month": 4,
"exp_year": 2024,
"address_line1_check": "unchecked",
"address_zip_check": "unchecked",
"brand": "Visa",
"country": "US",
"cvc_check": "unchecked",
"funding": "credit",
"last4": "4242",
"three_d_secure": "optional",
"tokenization_method": null,
"dynamic_last4": null
}
}
・PaymentMethod APIを介して取得したsource
{
"id": "card_1EBXBSDuWL9wT9brGOaALeD2",
"object": "payment_method",
"billing_details": {
"address": {
"city": "Berlin",
"country": "DE",
"line1": "Nollendorfstraße 27",
"line2": null,
"postal_code": "10777",
"state": null
},
"name": "Jenny Rosen",
"phone": null,
"email": "jenny.rosen@example.com"
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": null
},
"country": "US",
"exp_month": 4,
"exp_year": 2024,
"fingerprint": "53v265akSHAnIk1X",
"funding": "credit",
"last4": "4242",
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1500471469,
"customer": "#{customer_id}",
"livemode": false,
"metadata": {
},
"type": "card"
}
この互換性により、新しいオブジェクトは作成されない
・PaymentMethod API は、同じ基礎となるオブジェクトに対して異なるビューを提供する
・例えば、Payment Methods API を介したカードまたはカードソースへの更新は、ソースAPIを介して表示され、またその逆も同様だ