lib/khipu/khipu_service.rb in khipu-1.3.0 vs lib/khipu/khipu_service.rb in khipu-1.3.3
- old
+ new
@@ -10,12 +10,12 @@
def initialize(receiver_id, secret)
@receiver_id = receiver_id
@secret = secret
end
- def post(endpoint, params, json_response = true)
- uri = URI(Khipu::API_URL + endpoint)
+ def post(endpoint, params, json_response = true, base_url = Khipu::API_URL)
+ uri = URI(base_url + endpoint)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
if Khipu::DEBUG
http.set_debug_output(Khipu::debug_stream)
end
@@ -56,11 +56,11 @@
end
end
end
def hmac_sha256(secret, data)
- OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), secret, data).unpack('H*').first
+ OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), secret, data).unpack('H*').first
end
def concatenated(params)
params.collect { |k, v| k.to_s + '=' + v.to_s }.join('&')
end
@@ -71,6 +71,6 @@
pkey = cert.public_key
pkey.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(signature), concatenated(params))
end
end
-end
\ No newline at end of file
+end