将条带支付网关添加到rails应用程序

时间:2016-03-07 00:45:05

标签: ruby-on-rails ruby-on-rails-4 e-commerce stripe-payments

我目前正在尝试将条带支付网关添加到我的rails应用程序中,但是当我查看付款详细信息时,我收到了错误消息。该错误无法找到Shoppe :: Order with' id' ='

应用程序/控制器/ orders_controller.rb:

def payment
 @order = Shoppe::Order.find(session[:current_order_id])
  if request.post?
    if @order.accept_stripe_token(params[:stripe_token])
      redirect_to checkout_confirmation_path`enter code here`
    else
      flash.now[:notice] = "Could not exchange Stripe token. Please try again."
    end
  end
end

我按照专柜网站http://tryshoppe.com/docs/payment-gateways/stripe上的教程文档进行操作。 rails应用程序说上面代码的第2行是问题,我认为它与' current_order_id'有关。对此的任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

您可以使用我最近制作的Ruby on Rails的Stripe支付的简单示例。在这里查看GitHub上的代码:https://github.com/ab00zar/StripePayment-example

使用您的测试键运行服务器,例如:PUBLISHABLE_KEY = pk_test_g0XSu8r2ugAETksVJQXJjU30 SECRET_KEY = sk_test_A3rwGLOMNxEKDkaJOTgi4frd rails s

答案 1 :(得分:0)

付款方式,我的解决方案想法:

#comment out first line.
#@order = Shoppe::Order.find(session[:current_order_id])

#Add line from below:
@order = Shoppe::Order.find(current_order.id)

适合我。