ruby 轨道7|验证控制器::InvalidAuthenticityToken后,验证全额付款

olmpazwi  于 12个月前  发布在  Ruby
关注(0)|答案(1)|浏览(120)

我已经通过Easebuzz集成了一个支付网关,到目前为止一切顺利,成功的URL是一个POST请求订单#successE(ControllerName#MethodName),成功支付后,当它调用successE POST请求,我得到:

这是代码:

def payE
                @payment_response = Easebuzz::Payment.initiate({
                  "txnid" => "#{@order.id}",
                  "amount" => amount.to_f,
                  "firstname" => current_user.name,
                  "email" => current_user.email,
                  "phone" => current_user.phone_number,
                  "surl" => "http://localhost:3000/orders/#{@order.id}/successE",
                  "furl" => "http://localhost:3000/response.php",
                  "address1" => address,
                  "country" => "India",
                  #"zipcode" => "123123"
                })
        
                if @payment_response['status'] == 1
                  data = @payment_response['data']
                  redirect_to("https://testpay.easebuzz.in/pay/#{data}", allow_other_host: true, status: 303)
                end
end

如何解决这个问题?:')
有人能简单地解释一下发生了什么吗?它是否尝试验证CSRF令牌,但由于返回null而无法验证?请在我的大脑中插入一些新的知识:-)我真的很感激!

axr492tv

axr492tv1#

Ruby on Rails无法验证此控制器方法上的真实性令牌,因为来自外部应用程序的回调不支持并且不发送预期的令牌。
要仅在此特定控制器方法上禁用真实性令牌,请将以下代码添加到控制器:

skip_before_action :verify_authenticity_token, only: [:successE]

阅读更多关于Rails' RequestForgeryProtection

相关问题