ruby-on-rails - 如何使用 Stripe.com 向客户的特定卡收费

标签 ruby-on-rails stripe-payments

在 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/

相关文章:

ruby-on-rails - Heroku:预编译 Assets 失败

paypal - 地址验证系统 (AVS) ) 检查电子商务

java.lang.NoClassDefFoundError : Failed resolution of: Lcom/stripe/android/stripe3ds2/service/StripeThreeDs2ServiceImpl;

wordpress - 根据主机名强制 Stripe WooCommerce 插件进入测试模式

ruby-on-rails - my_object.save(false) 并没有真正跳过我的 Active Record 验证

ruby-on-rails - 覆盖渲染 :json in no model object Rails 4

api - 无法让 Stripe 收件人通过 API 进行验证

php - 如何通过 API 清除 Stripe 中的测试数据?

ruby-on-rails - SQLite3::BusyException

ruby-on-rails - 未定义的方法 `click' 用于 "2":String, 使用 Mechanize 时出现 Rails 错误