class SoPaid::Hop
Public Class Methods
encode_hop(data, key)
click to toggle source
# File lib/so_paid/hop.rb, line 37 def self.encode_hop(data, key) mac = HMAC::SHA256.new(key) mac.update data Base64.encode64(mac.digest).gsub "\n", '' end
get_isotime()
click to toggle source
# File lib/so_paid/hop.rb, line 33 def self.get_isotime Time.now.utc.iso8601 end
merge_defaults(main_hash, defaults_hash)
click to toggle source
# File lib/so_paid/hop.rb, line 62 def self.merge_defaults(main_hash, defaults_hash) target = main_hash.dup (defaults_hash.keys + main_hash.keys).uniq.each do |key| if defaults_hash[key].is_a? Hash and main_hash[key].is_a? Hash target[key] = merge_defaults(target[key], defaults_hash[key]) next end #target[key] = hash[key] # if the defaults_hash value is an array, make sure just to # append new uniq values, not overwrite default target.update(defaults_hash) do |key, tv, dv| ntv = tv.is_a?(Array) ? tv.clone : tv dv.is_a?(Array) ? (dv.clone << ntv ).flatten.uniq : ntv end end target end
new(order, pv_options={}, config_options={})
click to toggle source
# File lib/so_paid/hop.rb, line 44 def initialize(order, pv_options={}, config_options={}) @pv_order_params = {}.with_indifferent_access @pv_options = self.merge_defaults(pv_options, @@pv_defaults) @config_options = self.merge_defaults(config_options, @@config_defaults) @order = order @current_user_email = @config_options[:current_user_email] || @config_options[:current_user].try(:email) || ( @order.respond_to?(:user) and @order.user.try(:email)) generate_params return self end
payment_options(pv_options={}, config_options={})
click to toggle source
# File lib/so_paid/hop.rb, line 26 def self.payment_options(pv_options={}, config_options={}) @@pv_defaults = self.merge_defaults(pv_options, @@pv_defaults) @@config_defaults = self.merge_defaults(config_options, @@config_defaults) return self end
Public Instance Methods
merge_defaults(opts={}, default_opts={})
click to toggle source
# File lib/so_paid/hop.rb, line 56 def merge_defaults(opts={}, default_opts={}) SoPaid::Hop.merge_defaults(opts, default_opts) end