Sha256: 013a53ed8ef7502d403bd3d21e42867c5fd044b55073901c69d266d7c7e46f0f
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'uri' require 'net/http' require 'json' API_URL = 'https://khalti.com/api/merchant-transaction' module Khalti class Transaction def self.find(idx) secret_key = ENV['KHALTI_SECRET_KEY'] #test_secret_key_f59e8b7d18b4499ca40f68195a846e9b headers = { Authorization: "Key #{secret_key}" } uri = URI.parse("#{API_URL}/#{idx}/") puts uri https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri, headers) response = https.request(request) JSON.parse(response.body) || {} end def self.all secret_key = ENV['KHALTI_SECRET_KEY'] #test_secret_key_f59e8b7d18b4499ca40f68195a846e9b headers = { Authorization: "Key #{secret_key}" } uri = URI.parse("#{API_URL}/") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri, headers) response = https.request(request) JSON.parse(response.body) || {} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
khalti-0.1.4 | lib/khalti/transaction.rb |
khalti-0.1.2 | lib/khalti/transaction.rb |
khalti-0.1.1 | lib/khalti/transaction.rb |