简体   繁体   English

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

[英]Adding stripe payment gateway to rails application

I'm currently trying to add stripe payment gateway to my rails application but I'm getting an error as I get to the payment details. 我目前正在尝试将条形支付网关添加到我的Rails应用程序中,但是在获取付款详细信息时出现错误。 The error is 'Couldn't find Shoppe::Order with 'id'=' 错误为“找不到'id'='的Shoppe :: Order”

app/controllers/orders_controller.rb: 应用程序/控制器/ 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

i'm following the tutorial documentation on the shoppe website http://tryshoppe.com/docs/payment-gateways/stripe . 我正在关注shoppe网站http://tryshoppe.com/docs/payment-gateways/stripe上的教程文档。 The rails app is saying line 2 of the code above is the issue, I think its something to do with the 'current_order_id'. Rails应用程序说上面代码的第2行就是问题,我认为这与'current_order_id'有关。 Any help with this would be greatly appreciated. 任何有关这方面的帮助将不胜感激。

You can use a simple example of Stripe payment for Ruby on Rails I've made recently. 您可以使用我最近制作的Ruby on Rails的Stripe付款简单示例。 Check the code on GitHub here: https://github.com/ab00zar/StripePayment-example 在此处查看GitHub上的代码: https//github.com/ab00zar/StripePayment-example

Run the server using your test keys like: PUBLISHABLE_KEY=pk_test_g0XSu8r2ugAETksVJQXJjU30 SECRET_KEY=sk_test_A3rwGLOMNxEKDkaJOTgi4frd rails s 使用如下测试密钥运行服务器:PUBLISHABLE_KEY = pk_test_g0XSu8r2ugAETksVJQXJjU30 SECRET_KEY = sk_test_A3rwGLOMNxEKDkaJOTgi4frd rails

in payment method, my solution idea: 在付款方式中,我的解决方案是:

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

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

works for me. 适合我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM