下面是我用的验证公钥的方法,但是在服务器上面运行的时候出现错误
def notify
status = 400
#判断请求是否有ping++的签名信息
if request.headers['x-pingplusplus-signature'].blank?
status = 401
logger.debug '【报哪家】:======付款回调请求来源错误!!!!!'
return
end
#获取签名信息
raw_data = request.body.read
if request.headers['x-pingplusplus-signature'].is_a?(Array)
signature = request.headers['x-pingplusplus-signature'][0].to_s
else
signature = request.headers['x-pingplusplus-signature'].to_s
end
# 获取「Webhooks 验证公钥」
pub_key_path ="#{Rails.root}/config/rsa_public_key.pem"
if verify_signature(raw_data, signature, pub_key_path)
#处理接收的结果
event = JSON.parse(raw_data)
#付款成功
if event["type"] == 'charge.succeeded'
# 开发者在此处加入对支付异步通知的处理代码
order_no = event['data']['object']['order_no']
order = Order.where(order_no: order_no).first
order_from = order.status
if order.present?
#更新字段
order.paid = event['data']['object']['paid']
if order.save
status = 200
else
status = 500
end
else
logger.debug '数据库没有该条记录!'
end
#退款成功
elsif event['type'] == 'refund.succeeded'
# 开发者在此处加入对退款异步通知的处理代码
order_no = event['data']['object']['order_no']
order = Order.where(order_no: order_no).first
if order.present?
#更新字段
order.time_refunded = Time.at(event['data']['object']['time_succeed'])
if order.save
status = 200
else
status = 500
end
else
logger.debug '数据库没有该条记录!'
end
else
logger.debug '付款回调返回未知操作!'
end
else
logger.debug '付款回调请求来源错误!'
status = 403
end
render :nothing => true, :status => status
end
提示错误如下:
NoMethodError (undefined method `verify_signature' for #<PaymentsController:0x007fcf547c6f70>):
app/controllers/payments_controller.rb:32:in `notify'
lib/middleware/security.rb:11:in `call'
求大神帮忙解答