Sha256: ead562b7314518e95afb53d90018578e85e6b06765a6a3f1cc30ffcbc9ce611b
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'net/http' module Minfraud class Request FIELD_MAP = { ip: 'i', city: 'city', state: 'region', postal: 'postal', country: 'country', license_key: 'license_key', ship_addr: 'shipAddr', ship_city: 'shipCity', ship_state: 'shipRegion', ship_postal: 'shipPostal', ship_country: 'shipCountry', email_domain: 'domain', email_md5: 'emailMD5', phone: 'custPhone', bin: 'bin', session_id: 'sessionID', user_agent: 'user_agent', accept_language: 'accept_language', txn_id: 'txnID', amount: 'order_amount', currency: 'order_currency', txn_type: 'txn_type', avs_result: 'avs_result', cvv_result: 'cvv_result', requested_type: 'requested_type', forwarded_ip: 'forwardedIP' } # @param trans [Transaction] transaction to be sent to MaxMind def initialize(trans) @transaction = trans end # Sends transaction to MaxMind and gives raw response to Response for handling # @return [Response] wrapper for minFraud response def get Response.new(send_get_request) end # (see #get) # @param trans [Transaction] transaction to get to MaxMind def self.get(trans) new(trans).get end private # Transforms Transaction object into a hash for Net::HTTP::Get # @return [Hash] keys are strings with minFraud field names def encoded_query Hash[@transaction.attributes.map { |k, v| [FIELD_MAP[k], v] }] end # @return [Net::HTTPResponse] def send_get_request uri = Minfraud.uri uri.query = URI.encode_www_form(encoded_query) Net::HTTP.get_response(uri) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minfraud-ruby-0.1.0 | lib/minfraud/request.rb |