Stripe with Rails 4:此客户没有附加的付款来源

时间:2015-02-21 18:38:18

标签: javascript ruby ruby-on-rails-4 stripe-payments

使用带有条带4的Stripe(测试模式)时是否有任何人遇到此错误:“此客户没有附加付款来源”?它在我的user.rb模型中触发line(customer =):

attr_accessor :stripe_card_token

def save_with_payment
  if valid?
    customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)
    self.stripe_customer_token = customer.id
    save!
  end
end

我已经重新检查了我的表单和我的users.js,我没有看错;拼写是完美的。我的rails版本是4.2.0;红宝石:2.1.3p242

1 个答案:

答案 0 :(得分:3)

请尝试以下代码:(只需更换"卡片:stripe_card_token" =>"来源:stripe_card_token")

attr_accessor :stripe_card_token

def save_with_payment
  if valid?
    customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token)
    self.stripe_customer_token = customer.id
    save!
  end
end