Stripe Q25。Why is it an error to use “token_xxxx” not associated with a Customer object for payment?

StripeQA

目次一覧

 状態:-  閲覧数:639  投稿日:2019-03-18  更新日:2019-03-21  
質問履歴25 / A

最初に結論 / 質問履歴25 / A

 閲覧数:382 投稿日:2019-03-18 更新日:2019-03-19 

最初に結論


Chargeオブジェクトをcreateする際
・下記パラメータの組み合わせは不可
'customer' => 'cus_xxxx',
'source' => 'tok_xxxx',

Chargeオブジェクトをcreateする際、可能なパラメータ組み合わせ例は2
・パラメータ組み合わせ例1
・この場合'source'パラメータは、Customerオブジェクトの'default_source'プロパティ値となる
'customer' => 'cus_xxxx',

・パラメータ組み合わせ例2
'customer' => 'cus_xxxx',
'source' => 'src_xxxx',


質問履歴25


Why is it an error to use “token_xxxx” not associated with a Customer object for payment?
・2019/3/18

In the following PHP code, token_xxxx is associated with the Customer object
\Stripe\Stripe::setApiKey("sk_test_xxxx");
\Stripe\Customer::create([
 "description" => "hoge",
 "source" => "tok_amex"
]);


In the PHP code below, "token_xxxx" not associated with the Customer object is used for payment
\Stripe\Stripe::setApiKey('sk_test_xxxx');
$charge = \Stripe\Charge::create([
 "amount" => 888,
 "currency" => "USD",
 "customer" => "cus_xxxx",
 'source' => 'tok_visa',
]);


・An error occurred
Customer cus_xxxx does not have a linked source with ID tok_xxxx

Customerオブジェクトに関連付けていない「token_xxxx」を、支払いに使用するとエラーになるのはなぜですか?
下記コードでは、token_xxxxをCustomerオブジェクトに関連付けている
\Stripe\Stripe::setApiKey("sk_test_xxxx");
\Stripe\Customer::create([
 "description" => "hoge",
 "source" => "tok_amex"
]);


下記コードでは、Customerオブジェクトに関連付けていない「token_xxxx」を、支払いに使用している
\Stripe\Stripe::setApiKey('sk_test_xxxx');
$charge = \Stripe\Charge::create([
 "amount" => 888,
 "currency" => "USD",
 "customer" => "cus_xxxx",
 'source' => 'tok_visa',
]);


・エラーが発生した
Customer cus_xxxx does not have a linked source with ID tok_xxxx


Why is it an error to use "token_xxxx" not associated with a Customer object for payment?

A


Stripe APIでは
・sourceは基本的に、保存された支払い方法(クレジットカードなど)である

「customer」パラメータでchargeを作成する場合
・2つのオプションがある

1)sourceパラメータなしで作成する
・この場合、顧客のデフォルトのソース(デフォルトの保存カード)が使用される

2)"source"パラメータを使って作成する
・この場合、提供されたsourceが顧客に保存されたカードであることを確認する必要がある

tok_visaは、どの顧客にも保存されていない単なるストライプテストトークンなので、 "Customer"と一緒に使用することはできない
・そのため、エラーが発生する


Stripe Q24。After attaching the source to the customer object, how do I check from the customer object?

Stripe Q26。If you only accept credit card payments, are there any functions that can not be done with src_xxxx but only with tok_xxxx?

コメント投稿(ログインが必要)



類似度ページランキング
順位 ページタイトル抜粋
1 Stripe Q25。Why is it an error to use “token_xxxx” not associated with a Customer object for payment? 33
2 Stripe Q20。「webhook」と「synchronous」と「Checkout beta version」について 27
3 Stripe Q9。Checkout beta version で、webhookを受け取ると、client_reference_idがNULL 27
4 Stripe Q8。Stripe Checkout public beta version について 25
5 Stripe Q38。Difference between “paymentIntent.status === 'succeeded'” and “payment_intent.succeeded event of Webhook” 25
6 Stripe Q24。After attaching the source to the customer object, how do I check from the customer object? 25
7 Stripe Q51.Connect Standard アカウント連結後の返り値で、"refresh_token”も保存した方が良いですか? 25
8 Stripe Q48。「Checkout\Session - server」「Charge」「PaymentIntent」の使い分け方 24
9 Stripe Q62.Webhook::constructEventで、SignatureVerificationエラーになるのですが… 24
10 Stripe Q30。Checkout (new) の「Checkout Server Quickstart」の「Step 2: Add Checkout to your website」について 23
11 Stripe Payments > COLLECTING PAYMENT DETAILS > Checkout 23
12 Stripe Q26。If you only accept credit card payments, are there any functions that can not be done with src_xxxx but only with tok_xxxx? 23
13 Stripe Payments > Quickstart / クイックスタート 23
14 Stripe Q29。日本で、Connect Customアカウント を導入している事例について 23
15 Stripe Q60. Checkout\SessionオブジェクトとPaymentIntentオブジェクトの関係性は1対1ですか? 23
16 Stripe Q56. 作成したCheckout\Sessionオブジェクトが破棄されるタイミングは? 23
17 Stripe Q21。新規顧客作成時に新規ソースオブジェクトを添付したいのですが、No such token: src_xxxxとなります 22
18 Stripe Q73.CheckoutのSessionオブジェクトをcreateする際、'payment_intent_data'内の'metadata'として渡したデータを、webhookで受け取る件について 22
19 Stripe Q52.Checkout\Sessionで1回限りの決済終了した際、添付メール自動送信することはできますか? 22
20 Stripe Q46。Direct Charges で手数料聴取する場合、'payment_intent_data'の「有り」「無し」の違いは? 22
2025/1/16 21:48 更新
週間人気ページランキング / 1-9 → 1-15
順位 ページタイトル抜粋 アクセス数
1 Stripe Q16。PaymentIntentの支払いで郵便番号入力を求められる。Radar rules の ZIP code を無効にしているのに | QA(Stripe) 4
1 その他エントリー(Stripe) カテゴリー 4
1 Stripe Q74.「お客様のビジネスの詳細」とは何ですか? | Stripe 4
2 Twitch | ゲーム実況配信サービス(課金販売できるプラットフォーム) 2
2 カテゴリ一覧 2
2 決済用語 2
2 Stripe Q15。PaymentIntent でエラー。カード番号に不備があります。 | QA(Stripe) 2
2 Stripe Payments > PREPARING FOR SCA > Payment Intents | documentation(Stripe) 2
3 EMV / EMV とは? / EMV 仕様 1
3 Gumroadとは?/ 特徴 / Link 1
3 日本で、Connect Standardアカウント を導入している(と思われる)事例 | その他エントリー(Stripe) 1
3 資金決済に関する法律(資金決済法)とは?/(1)前払式支払手段 /(2)資金移動業 1
3 Stripe Q32。Webhook のエンドポイントから適切な値を返さなかったときの停止措置について | QA(Stripe) 1
3 初めに カテゴリー 1
3 Stripe Q20。「webhook」と「synchronous」と「Checkout beta version」について | QA(Stripe) 1
3 新 Stripe 学習の流れを体系化 | その他エントリー(Stripe) 1
3 Stripeアカウントへログインする際、モバイル端末で受信したコード入力を求められる理由は? | その他エントリー(Stripe) 1
3 Stripe Q11。テストAPIで、実際のカード番号を入力したらどうなりますか? | QA(Stripe) 1
3 トークン決済 | セキュリティ 1
3 Stripe Q1。Stripeにおける個人事業主の定義 | QA(Stripe) 1
2025/1/16 1:02 更新