def authenticate
begin
url = URI.parse("https://sandbox.api.mxmerchant.com/checkout/v3/merchant/#{@merchant_id}")
req = Net::HTTP::Get.new(url)
@encoded_string = Base64.encode64("#{@merchant_key}:#{@merchant_secret}")
req['Authorization'] = "Basic "+ @encoded_string
req['Content-Type'] = 'application/json'
req_options = {
use_ssl: url.scheme == "https",
}
res = Net::HTTP.start(url.host, url.port,req_options) {|http|
http.request(req)
}
return JSON.parse(res.body)
rescue Exception => e
end
end
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.