【问题标题】:Error in cart checkout in railsRails 中的购物车结账错误
【发布时间】:2013-01-23 21:45:41
【问题描述】:

我不确定我错过了什么,我正在尝试将 Stripe Payments 与购物车结账系统一起使用。我不断收到以下错误:

/Users/dave/rails_projects/testapp/app/controllers/calendars_controller.rb:78: 语法错误,意外的keyword_end,期待$end

表单中的操作

 def create
    @cart = current_cart
    @calendar = Calendar.new(params[:calendar])
    @calendar.add_line_items_from_cart(current_cart)
    if @calendar.save
      Cart.destroy(session[:cart_id])
      session[:cart_id] = nil
      redirect_to calendar_path, notice: 'Your order is done.' 
    end
    # Amount in cents
    @amount = @cart.total_price
    customer = Stripe::Customer.create(
      :email => 'example@stripe.com',
      :card  => params[:stripeToken]
    )

    charge = Stripe::Charge.create(
      :customer    => customer.id,
      :amount      => @amount,
      :description => 'EquiptMe Gear Rental',
      :currency    => 'usd'
    )

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

  end

观点

<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
          data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
          data-description="A month's subscription"
          data-amount="500">
</script>

【问题讨论】:

  • 你能把你的 calendars_controller.rb 贴在这里吗,因为你的 create 方法看起来不错。还有你的第 78 行是哪一行?

标签: ruby-on-rails forms shopping-cart stripe-payments


【解决方案1】:

你的结局太多了。删除最后一个“结束”,它应该可以工作

【讨论】:

    猜你喜欢
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-16
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多