在测试模式下,当我创建新客户并尝试付款时,出现此错误。
Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID tok_17Kp8GAwLkQPB7OqrrM73VVI
我正在使用卡号:4242424242424242 exp_month :12 exp_year 2016
返回响应是,
Array
(
[charge_status] =>
[error_info] => Array
(
[type] => invalid_request_error
[message] => Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID tok_17Kp8GAwLkQPB7OqrrM73VVI.
[param] => card
[code] => missing
)
[message] => Customer cus_7Zz2BCnybIZLGw does not have a linked card with ID tok_17Kp8GAwLkQPB7OqrrM73VVI.
)
输入费用数据是,
$customer = Stripe_Customer::create(array(
'account_balance' => 100,
'source' => $token,
'email' => strip_tags(trim($email))
)
);
$customer_id = $customer->id;
$charge = array(
'card' => 4242424242424242,
'amount' => 100,
'currency' => 'cad',
'receipt_email' => test@test.com,
'description' => 'my payment',
'customer' => $customer_id
);
最佳答案
create a charge 有三种不同的方法:
仅带有
source
参数。在这种情况下,source
需要是 token或 source ID(由 Checkout 或 Stripe.js 创建),即以tok_
或src_
开头的字符串。仅带有
customer
参数。在这种情况下,customer
需要是 customer ID,即以cus_
开头的字符串。将向客户的默认付款来源收取费用。同时带有
customer
和source
参数。在这种情况下,customer
需要像前一种情况一样是客户 ID,但source
应该是已经附加到客户的付款来源的 ID。付款来源可以是cards (ID 以card_
开头),bank accounts (ID 以ba_
开头)或 sources (ID 以src_
开头)。
在您的情况下,您将在 source
参数中传递 token ID 以及在 customer
参数中传递客户 ID。
如果这是一张新卡,你应该先使用 token 到create a card在客户上,然后使用卡 ID 创建费用。如果卡已经为该客户保存,那么您不需要再次收集卡信息(因此根本不需要创建 token )。
关于javascript - Stripe 支付 : Getting Error as Customer cus_***** does not have a linked card with ID tok_*****,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34415987/