【发布时间】:2016-08-21 18:42:13
【问题描述】:
我似乎无法在 Rails 4 中对卡进行收费然后动态创建客户。
def charge
token = params[:stripeToken] # can only be used once.
begin
charge = Stripe::Charge.create(
:amount => 5000,
:currency => "gbp",
:source => token,
:description => "Example charge"
)
rescue Stripe::CardError => e
# The card has been declined
end
if current_user.stripeid == nil
customer = Stripe::Customer.create(card: token, ...)
current_user.stripeid = customer.id
current_user.save
end
end
I have looked at this 但没有token.id 这样的东西,因为token 只是一个String。
【问题讨论】:
-
而且您没有在 JS 代码的任何地方提交令牌(即创建费用)?
-
我正在使用 Checkout.js。
标签: ruby-on-rails stripe-payments