我正在尝试创建客户并使用Rails和Stripe为该客户收费。客户正在Stripe中创建,但在尝试执行收费时,我一直收到错误Cannot charge a customer that has no active card
。条纹:无法为没有活动卡的客户收费
我跟随作为Rails初学者的条纹教程,所以我不知道该从哪里出发。任何帮助将不胜感激。
Rails代码:
def process_payment
customer = Stripe::Customer.create email: email,
card: card_token
Stripe::Charge.create customer: customer.id,
amount: level.price*100,
description: level.name,
card: card_token,
currency: 'usd'
end
def create
@registration = Registration.new registration_params.merge(email: stripe_params["stripeEmail"],
card_token: stripe_params["stripeToken"])
raise "Please, check registration errors" unless @registration.valid?
@registration.process_payment
@registration.save
redirect_to @registration, notice: 'Registration was successfully created.'
end
感谢您的帮助!尽管从充电电话中移除卡片令牌并没有帮助。我附上了测试数据错误的截图。往上看。 –
我认为Stripe可能已经改变了客户API,因此'card'现在是'source'(请参阅https://stripe.com/docs/api#create_customer)。试试看看是否有帮助。 – mysmallidea
仍然有同样的错误... –