在rails中的购物车结帐时出错

时间:2013-02-08 06:56:51

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

我不确定我缺少什么,我正在尝试使用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>

1 个答案:

答案 0 :(得分:1)

你有太多的结局。删除最后一个'结束',它应该工作