module OffsitePayments::Integrations::Coinbase
Public Class Methods
notification(post, options = {})
click to toggle source
options should be { credential1: “your API key”, credential2: “your API secret” }
# File lib/offsite_payments/integrations/coinbase.rb, line 14 def self.notification(post, options = {}) Notification.new(post, options) end
return(query_string, options = {})
click to toggle source
# File lib/offsite_payments/integrations/coinbase.rb, line 18 def self.return(query_string, options = {}) Return.new(query_string, options) end
Protected Class Methods
do_request(uri, api_key, api_secret, post_body = nil)
click to toggle source
# File lib/offsite_payments/integrations/coinbase.rb, line 149 def self.do_request(uri, api_key, api_secret, post_body = nil) nonce = (Time.now.to_f * 1e6).to_i hmac_message = nonce.to_s + uri.to_s if post_body request = Net::HTTP::Post.new(uri.request_uri) request.body = post_body hmac_message = hmac_message + request.body else request = Net::HTTP::Get.new(uri.path) end http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request['ACCESS_KEY'] = api_key request['ACCESS_SIGNATURE'] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_secret, hmac_message) request['ACCESS_NONCE'] = nonce.to_s http.request(request).body end