lib/ll_pay.rb in ll_pay-0.4.0 vs lib/ll_pay.rb in ll_pay-0.5.0
- old
+ new
@@ -2,10 +2,11 @@
require 'll_pay/sign'
require 'll_pay/sign/md5'
require 'll_pay/sign/rsa'
require 'll_pay/notify'
require 'll_pay/query_order'
+require 'll_pay/refund_order'
require 'll_pay/service'
require 'll_pay/utils'
module LlPay
# 银通公钥
@@ -22,7 +23,34 @@
class << self
attr_accessor :oid_partner # 商户编号
attr_accessor :rsa_pri_key # 私钥
attr_accessor :md5_key # md5
attr_accessor :sign_type
+
+ include QueryOrder
+ include RefundOrder
+ include Service
+ include Notify
+ end
+
+ def self.request(verb, url, params = {})
+ case verb.to_sym
+ when :post
+ @http_response = HTTP.post(url, json: params)
+ when :get
+ @http_response = HTTP.get(url)
+ end
+ response_hash = JSON.parse(@http_response.body.to_s)
+
+ if @http_response.code == 200
+ if response_hash['ret_code'] == 0000
+ if LlPay::Sign.verify?(response_hash)
+ return response_hash
+ else
+ return { ret_msg: '签名验证错误' }
+ end
+ else
+ return response_hash
+ end
+ end
end
end