kount_api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +31 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +12 -0
- data/lib/kount/abstract_response.rb +17 -0
- data/lib/kount/adapters/redis_adapter.rb +32 -0
- data/lib/kount/client.rb +140 -0
- data/lib/kount/error.rb +23 -0
- data/lib/kount/response.rb +92 -0
- data/lib/kount/version.rb +5 -0
- data/lib/kount.rb +12 -0
- data/order.json +32 -0
- data/sig/kount.rbs +4 -0
- metadata +197 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d0859a3d3181e0dd182f2fdda602c494772e0c6db9b0c5797595e0b5d591881
|
4
|
+
data.tar.gz: aa5f444fbed0e349f746bcd97d456be28137f78fbadfd897ae772c94ba35aa21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25ccbff830d3acf079a1faf18536a3e9a354e7e0c6a0c9b281c0b0799686cff5a577724e78bce8c7b69d06c5c2bab051e754e010188cc3820fd1d78c945ab6c5
|
7
|
+
data.tar.gz: 88e5428abbda09c87878d0a79386aed399d6bcf4a51ea07bd74b9b44455afe51849a4c9dae899cb0d691d71eceb52f812e1aa4be15f9285b8b712c77e116da31
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.1
|
3
|
+
|
4
|
+
Layout/LineLength:
|
5
|
+
Max: 120
|
6
|
+
|
7
|
+
Lint/MissingSuper:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/StringLiterals:
|
11
|
+
Enabled: true
|
12
|
+
EnforcedStyle: double_quotes
|
13
|
+
|
14
|
+
Style/StringLiteralsInInterpolation:
|
15
|
+
Enabled: true
|
16
|
+
EnforcedStyle: double_quotes
|
17
|
+
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Metrics/BlockLength:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/AbcSize:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Metrics/ClassLength:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Metrics/MethodLength:
|
31
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Nicholas Palaniuk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Kount
|
2
|
+
> Ruby interface to the Kount Orders API
|
3
|
+
|
4
|
+
## Configuration
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
require "kount"
|
8
|
+
require "kount/adapters/redis_adapter" # Optional adapter – ensure the 'redis' gem is in your Gemfile.
|
9
|
+
|
10
|
+
redis_adapter = Kount::Adapters::RedisAdapter.new(Redis.new)
|
11
|
+
|
12
|
+
client = Kount::Client.new(
|
13
|
+
api_key: "your_api_key",
|
14
|
+
auth_url: "https://login.kount.com/oauth2/your_auth_endpoint",
|
15
|
+
api_domain: "https://api-sandbox.kount.com",
|
16
|
+
token_storage_adapter: redis_adapter
|
17
|
+
)
|
18
|
+
```
|
19
|
+
|
20
|
+
## Methods
|
21
|
+
|
22
|
+
```
|
23
|
+
#create_order -> Kount::Response
|
24
|
+
#update_order -> Kount::Response
|
25
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kount
|
4
|
+
module Adapters
|
5
|
+
class RedisAdapter
|
6
|
+
def initialize(redis_client = nil)
|
7
|
+
@redis = redis_client
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_token(api_key:, client:)
|
11
|
+
key = token_key(api_key, client)
|
12
|
+
json = @redis.get(key)
|
13
|
+
return nil unless json
|
14
|
+
|
15
|
+
JSON.parse(json, symbolize_names: true)
|
16
|
+
end
|
17
|
+
|
18
|
+
def store_token(api_key:, client:, token:, expires_in:)
|
19
|
+
key = token_key(api_key, client)
|
20
|
+
expiry = Time.now.to_i + expires_in
|
21
|
+
data = { token: token, expiry: expiry }
|
22
|
+
@redis.set(key, data.to_json, ex: expires_in)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def token_key(api_key, client)
|
28
|
+
"kount:token:#{client}:#{api_key}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/kount/client.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kount
|
4
|
+
class Client
|
5
|
+
attr_accessor :api_key,
|
6
|
+
:client,
|
7
|
+
:auth_url,
|
8
|
+
:host,
|
9
|
+
:bearer_token,
|
10
|
+
:token_storage_adapter
|
11
|
+
|
12
|
+
def initialize(opts)
|
13
|
+
@api_key = opts[:api_key]
|
14
|
+
@client = opts[:client]
|
15
|
+
@auth_url = opts[:auth_url]
|
16
|
+
@host = opts[:host]
|
17
|
+
@token_storage_adapter = opts[:token_storage_adapter]
|
18
|
+
@bearer_token = nil
|
19
|
+
@token_expiry = nil
|
20
|
+
|
21
|
+
if token_storage_adapter &&
|
22
|
+
!(token_storage_adapter.respond_to?(:get_token) && token_storage_adapter.respond_to?(:store_token))
|
23
|
+
raise ArgumentError, "Token storage adapter must implement get_token and store_token methods"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_order(order, risk_inquiry: true)
|
28
|
+
response_handler do
|
29
|
+
post_order(order, risk_inquiry)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def update_order(order_id, order)
|
34
|
+
response_handler do
|
35
|
+
patch_order(order_id, order)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def authenticate
|
42
|
+
if token_storage_adapter
|
43
|
+
cached = token_storage_adapter.get_token(api_key: api_key, client: client)
|
44
|
+
if cached && !token_expired?(cached)
|
45
|
+
@bearer_token = cached[:token]
|
46
|
+
@token_expiry = cached[:expiry]
|
47
|
+
return @bearer_token
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
uri = URI.parse(auth_url)
|
52
|
+
request = Net::HTTP::Post.new(uri)
|
53
|
+
request["Authorization"] = "Basic #{api_key}"
|
54
|
+
request["Content-Type"] = "application/x-www-form-urlencoded"
|
55
|
+
|
56
|
+
form_data = URI.encode_www_form(
|
57
|
+
grant_type: "client_credentials",
|
58
|
+
scope: "k1_integration_api"
|
59
|
+
)
|
60
|
+
request.body = form_data
|
61
|
+
|
62
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
63
|
+
http.request(request)
|
64
|
+
end
|
65
|
+
|
66
|
+
raise "Authentication failed (#{response.code}): #{response.body}" unless response.code.to_i == 200
|
67
|
+
|
68
|
+
data = JSON.parse(response.body)
|
69
|
+
@bearer_token = data["access_token"]
|
70
|
+
|
71
|
+
# Subtract a safety margin (e.g. 120 seconds) so we re-authenticate early.
|
72
|
+
expires_in = data["expires_in"] || 3600
|
73
|
+
effective_expires_in = expires_in - 120
|
74
|
+
@token_expiry = Time.now.to_i + effective_expires_in
|
75
|
+
|
76
|
+
token_storage_adapter&.store_token(
|
77
|
+
api_key: api_key,
|
78
|
+
client: client,
|
79
|
+
token: @bearer_token,
|
80
|
+
expires_in: effective_expires_in
|
81
|
+
)
|
82
|
+
|
83
|
+
@bearer_token
|
84
|
+
end
|
85
|
+
|
86
|
+
def response_handler
|
87
|
+
response = yield
|
88
|
+
body = JSON.parse(response.body)
|
89
|
+
body.deep_transform_keys!(&:underscore)
|
90
|
+
|
91
|
+
if response.code == "200"
|
92
|
+
Response.new(body)
|
93
|
+
else
|
94
|
+
Error.new(body)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def post_order(order, risk_inquiry)
|
99
|
+
ensure_authenticated
|
100
|
+
uri = URI.parse("#{host}/commerce/v2/orders?riskInquiry=#{risk_inquiry}")
|
101
|
+
headers = {
|
102
|
+
"Authorization" => "Bearer #{bearer_token}",
|
103
|
+
"Content-Type" => "application/json"
|
104
|
+
}
|
105
|
+
transformed_order = order.deep_transform_keys { |k| k.to_s.camelize(:lower) }
|
106
|
+
send_request(Net::HTTP::Post, uri, headers, transformed_order.to_json)
|
107
|
+
end
|
108
|
+
|
109
|
+
def patch_order(order_id, order)
|
110
|
+
ensure_authenticated
|
111
|
+
uri = URI.parse("#{host}/commerce/v2/orders/#{order_id}")
|
112
|
+
headers = {
|
113
|
+
"Authorization" => "Bearer #{bearer_token}",
|
114
|
+
"Content-Type" => "application/json"
|
115
|
+
}
|
116
|
+
transformed_order = order.deep_transform_keys { |k| k.to_s.camelize(:lower) }
|
117
|
+
send_request(Net::HTTP::Patch, uri, headers, transformed_order.to_json)
|
118
|
+
end
|
119
|
+
|
120
|
+
def ensure_authenticated
|
121
|
+
return unless bearer_token.nil? || (@token_expiry && Time.now.to_i >= @token_expiry)
|
122
|
+
|
123
|
+
authenticate
|
124
|
+
end
|
125
|
+
|
126
|
+
def token_expired?(cached_token)
|
127
|
+
expiry = cached_token[:expiry]
|
128
|
+
Time.now.to_i >= expiry
|
129
|
+
end
|
130
|
+
|
131
|
+
def send_request(http_method_class, uri, headers = {}, body = nil)
|
132
|
+
request = http_method_class.new(uri)
|
133
|
+
headers.each { |key, value| request[key] = value }
|
134
|
+
request.body = body if body
|
135
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
|
136
|
+
http.request(request)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/lib/kount/error.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kount
|
4
|
+
class Error < AbstractResponse
|
5
|
+
attr_reader :data
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@data = data
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_hash
|
12
|
+
@data
|
13
|
+
end
|
14
|
+
|
15
|
+
def ok?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def approved?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kount
|
4
|
+
class Response < AbstractResponse
|
5
|
+
attr_accessor :order_id, :merchant_order_id, :channel,
|
6
|
+
:device_session_id, :creation_date_time,
|
7
|
+
:risk_inquiry, :transactions, :fulfillment
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
|
12
|
+
if (order = @data["order"])
|
13
|
+
@order_id = order["order_id"]
|
14
|
+
@merchant_order_id = order["merchant_order_id"]
|
15
|
+
@channel = order["channel"]
|
16
|
+
@device_session_id = order["device_session_id"]
|
17
|
+
@creation_date_time = order["creation_date_time"]
|
18
|
+
@risk_inquiry = RiskInquiry.new(order["risk_inquiry"] || {})
|
19
|
+
@transactions = (order["transactions"] || []).map { |t| Transaction.new(t) }
|
20
|
+
else
|
21
|
+
@data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_hash
|
26
|
+
@data
|
27
|
+
end
|
28
|
+
|
29
|
+
def ok?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def approved?
|
34
|
+
!!@risk_inquiry&.approved?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class RiskInquiry
|
39
|
+
attr_accessor :decision, :omniscore, :persona, :device, :segment_executed
|
40
|
+
|
41
|
+
def initialize(attrs = {})
|
42
|
+
@decision = attrs["decision"]
|
43
|
+
@omniscore = attrs["omniscore"]
|
44
|
+
@persona = Persona.new(attrs["persona"] || {})
|
45
|
+
@device = attrs["device"]
|
46
|
+
@segment_executed = SegmentExecuted.new(attrs["segment_executed"] || {})
|
47
|
+
end
|
48
|
+
|
49
|
+
def approved?
|
50
|
+
@decision == "APPROVE"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Persona
|
55
|
+
attr_accessor :unique_cards, :unique_devices, :unique_emails
|
56
|
+
|
57
|
+
def initialize(attrs = {})
|
58
|
+
@unique_cards = attrs["unique_cards"]
|
59
|
+
@unique_devices = attrs["unique_devices"]
|
60
|
+
@unique_emails = attrs["unique_emails"]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class SegmentExecuted
|
65
|
+
attr_accessor :segment, :policies_executed, :tags
|
66
|
+
|
67
|
+
def initialize(attrs = {})
|
68
|
+
@segment = Segment.new(attrs["segment"] || {})
|
69
|
+
@policies_executed = attrs["policies_executed"] || []
|
70
|
+
@tags = attrs["tags"] || []
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Segment
|
75
|
+
attr_accessor :id, :name, :priority
|
76
|
+
|
77
|
+
def initialize(attrs = {})
|
78
|
+
@id = attrs["id"]
|
79
|
+
@name = attrs["name"]
|
80
|
+
@priority = attrs["priority"]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Transaction
|
85
|
+
attr_accessor :transaction_id, :merchant_transaction_id
|
86
|
+
|
87
|
+
def initialize(attrs = {})
|
88
|
+
@transaction_id = attrs["transaction_id"]
|
89
|
+
@merchant_transaction_id = attrs["merchant_transaction_id"]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/kount.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
require "uri"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
require "active_support/core_ext/string"
|
8
|
+
require "kount/version"
|
9
|
+
require "kount/abstract_response"
|
10
|
+
require "kount/response"
|
11
|
+
require "kount/error"
|
12
|
+
require "kount/client"
|
data/order.json
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
merchantOrderId: "myOrderId",
|
3
|
+
deviceSessionId: "mySess1",
|
4
|
+
creationDateTime: "2024-03-21T10:46:22Z",
|
5
|
+
userIp: "163.116.253.48",
|
6
|
+
transactions: [{
|
7
|
+
payment: {
|
8
|
+
type: "CREDIT_CARD",
|
9
|
+
bin: "483312",
|
10
|
+
last4: "1111"
|
11
|
+
},
|
12
|
+
orderTotal: 100,
|
13
|
+
currency: "USD",
|
14
|
+
billedPerson: {
|
15
|
+
name: {
|
16
|
+
first: "Jimmy",
|
17
|
+
last: "Jazz"
|
18
|
+
},
|
19
|
+
emailAddress: "jjazz@kount.com",
|
20
|
+
phoneNumber: "+15551234567",
|
21
|
+
address: {
|
22
|
+
addressType: "BILLING",
|
23
|
+
line1: "1010 Main street",
|
24
|
+
line2: "string",
|
25
|
+
city: "Boise",
|
26
|
+
region: "ID",
|
27
|
+
postalCode: "83701",
|
28
|
+
countryCode: "US"
|
29
|
+
}},
|
30
|
+
transactionStatus: "PENDING"
|
31
|
+
}]
|
32
|
+
}
|
data/sig/kount.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kount_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicholas Palaniuk
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-05-13 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: activesupport
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: addressable
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.8.5
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 2.8.5
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: net-sftp
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: faker
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: pry-byebug
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rake
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: rspec
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rubocop
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: rubocop-rspec
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: webmock
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
description: Ruby interface to Kount Orders API
|
153
|
+
email:
|
154
|
+
- npalaniuk+github@gmail.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- ".rspec"
|
160
|
+
- ".rubocop.yml"
|
161
|
+
- CHANGELOG.md
|
162
|
+
- CODE_OF_CONDUCT.md
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.md
|
165
|
+
- Rakefile
|
166
|
+
- lib/kount.rb
|
167
|
+
- lib/kount/abstract_response.rb
|
168
|
+
- lib/kount/adapters/redis_adapter.rb
|
169
|
+
- lib/kount/client.rb
|
170
|
+
- lib/kount/error.rb
|
171
|
+
- lib/kount/response.rb
|
172
|
+
- lib/kount/version.rb
|
173
|
+
- order.json
|
174
|
+
- sig/kount.rbs
|
175
|
+
homepage: https://github.com/subfico/kount
|
176
|
+
licenses:
|
177
|
+
- MIT
|
178
|
+
metadata:
|
179
|
+
homepage_uri: https://github.com/subfico/kount
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 3.1.0
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubygems_version: 3.6.5
|
195
|
+
specification_version: 4
|
196
|
+
summary: Ruby interface to Kount Orders API
|
197
|
+
test_files: []
|