我似乎無法充電,然後卡在導軌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。 – Sylar