在 Stripe.com 中,一个客户对象可以有许多卡片。现有卡如何收费?
我已经尝试了一些东西,但是由于某种原因,stripe api 使何时获取旧客户 token 和新卡 token 而不仅仅是在该客户上创建新卡。所以我走的路线是检索所有客户的卡,然后通过单选按钮选择一张,然后将所选卡的 token 提交到费用中
charge = Stripe::Charge.create(
:amount => "#{@subscription.price}",
:currency => "usd",
:card => params[:existing_card_id],
:description => "Subscription for #{current_user.email}"
)
但我得到了错误
Stripe::InvalidRequestError: Invalid token id: card_24j3i2390s9df
最佳答案
我想通了。
使用现有的卡 token ,您还必须发送客户 token
charge = Stripe::Charge.create(
:amount => "#{@subscription.price}",
:currency => "usd",
:customer => current_user.stripe_customer_id,
:card => params[:existing_card_id],
:description => "Subscription for #{current_user.email}"
)
关于ruby-on-rails - 如何使用 Stripe.com 向客户的特定卡收费,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20246335/