创建Stripe客户时,没有附加的付款来源错误

时间:2018-08-19 22:36:00

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

我正在尝试遵循一些教程,遇到了一些错误。希望有人可以帮助我。

Stripe::InvalidRequestError in Users::RegistrationsController#create

This customer has no attached payment source

代码:

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

1 个答案:

答案 0 :(得分:0)

您的请求存在的问题是,在创建客户时,您输入的参数错误。

应该是

Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token)

选中here