在rails中构建应用程序,使用条带作为其支付/结账系统 . 我有充电控制器,new.html.erb和所有必要的宝石,但出于某种原因,每当我使用我的信用卡测试条纹与真实付款(收费只有2美元,所以它不会伤害到测试)它在我的日志中显示为v1 /令牌而不是v1 / charge,并且不会显示在付款部分中 . 我已经广泛研究了从令牌到收费的转换,并找到了指向同一解决方案的多个答案(创建了一个将令牌变成我所收费的开始方法)但是在实现它时对我不起作用 . 这是我目前的收费控制器:

require "stripe"

class ChargesController < ApplicationController
  def new
    # this will remain empty unless you need to set some instance variables to pass on
  end

  def create

  # Amount in cents
  @amount = 200

  # Set your secret key: remember to change this to your live secret key in production
  # See your keys here https://dashboard.stripe.com/account/apikeys
  Stripe.api_key = "pk_live_z....." //taken out for security reasons

  # Get the credit card details submitted by the form
  token = params[:stripeToken]

  # Create the charge on Stripe's servers - this will charge the user's card
  begin
      charge = Stripe::Charge.create(
      :amount => @amount, # amount in cents, again
      :currency => "usd",
      :source => token,
      :description => "Example charge"
    )

  rescue Stripe::CardError => e
    flash[:error] = e.message
    redirect_to new_charge_path
  end
end

end