Class: Kount::Client
- Inherits:
-
Object
- Object
- Kount::Client
- Defined in:
- lib/kount/client.rb
Overview
This class is where the primary interaction with the merchant integration will take place.
Constant Summary collapse
- RESPONSE_FORMAT =
Tells the RIS server to respond in JSON instead of key/value pairs This cannot be overridden.
'JSON'
- DEFAULT_VERSION =
RIS Version. Can be overridden my merchant if required.
'0630'
- ENDPOINT_PROD =
Default endpoint for production. Used by the DEFAULT_OPTIONS
'https://risk.kount.net'
- ENDPOINT_TEST =
Default endpoint for test. Used by the TEST_DEFAULT_OPTIONS
'https://risk.test.kount.net'
- PROD_DEFAULT_OPTIONS =
Default params for production
{ endpoint: ENDPOINT_PROD, version: DEFAULT_VERSION, is_test: false }
- TEST_DEFAULT_OPTIONS =
Default params for test if is_test is TRUE
{ endpoint: ENDPOINT_TEST, version: DEFAULT_VERSION }
Instance Method Summary collapse
-
#endpoint ⇒ Object
RIS Endpoint URL.
-
#get_response(request) ⇒ Hash
Makes the call to the Kount RIS server.
-
#initialize(params = {}) ⇒ Client
constructor
Initialize a client object.
-
#key ⇒ Object
Merchant API for RIS acess.
-
#ksalt ⇒ Object
Secret Kount salt for KHASH.
-
#merchant_id ⇒ Object
Kount Merchant ID.
-
#prepare_request_params(request) ⇒ Object
Give the request object what it needs to know to process the params to send to RIS.
-
#test? ⇒ Boolean
Is test or production setting.
-
#version ⇒ Object
RIS Interface Version.
Constructor Details
#initialize(params = {}) ⇒ Client
Initialize a client object
Example usage
{:merchant_id => "123456", :key => "trhvihsrihsta7ftadk6edkre7y8..."}
other optional params
49 50 51 52 53 54 55 56 57 |
# File 'lib/kount/client.rb', line 49 def initialize(params = {}) @options = {} if params[:is_test] @options.merge!(TEST_DEFAULT_OPTIONS) else @options.merge!(PROD_DEFAULT_OPTIONS) end @options.merge!(params) end |
Instance Method Details
#endpoint ⇒ Object
RIS Endpoint URL
95 96 97 |
# File 'lib/kount/client.rb', line 95 def endpoint @options[:endpoint] end |
#get_response(request) ⇒ Hash
Makes the call to the Kount RIS server
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/kount/client.rb', line 63 def get_response(request) params = prepare_request_params(request) response = {} begin response = RestClient::Resource.new( endpoint, verify_ssl: verify_ssl_option, timeout: 1).post params, x_kount_api_key: key JSON.parse(response) rescue # RIS errors do not come back as JSON, so just pass them along raw. response end end |
#key ⇒ Object
Merchant API for RIS acess
100 101 102 |
# File 'lib/kount/client.rb', line 100 def key @options[:key] end |
#ksalt ⇒ Object
Secret Kount salt for KHASH
105 106 107 |
# File 'lib/kount/client.rb', line 105 def ksalt @options[:ksalt] end |
#merchant_id ⇒ Object
Kount Merchant ID
85 86 87 |
# File 'lib/kount/client.rb', line 85 def merchant_id @options[:merchant_id] end |
#prepare_request_params(request) ⇒ Object
Give the request object what it needs to know to process the params to send to RIS.
80 81 82 |
# File 'lib/kount/client.rb', line 80 def prepare_request_params(request) request.prepare_params(version, merchant_id, RESPONSE_FORMAT, ksalt) end |
#test? ⇒ Boolean
Is test or production setting
110 111 112 |
# File 'lib/kount/client.rb', line 110 def test? @options[:is_test] end |
#version ⇒ Object
RIS Interface Version
90 91 92 |
# File 'lib/kount/client.rb', line 90 def version @options[:version] end |