Class: Minfraud::Transaction
- Inherits:
-
Object
- Object
- Minfraud::Transaction
- Defined in:
- lib/minfraud/transaction.rb
Overview
This is the container for the data you’re sending to MaxMind. A transaction holds data like name, address, IP, order amount, etc.
Instance Attribute Summary collapse
-
#accept_language ⇒ Object
Transaction linking attribute (optional).
-
#amount ⇒ Object
Transaction attribute (optional).
-
#avs_result ⇒ Object
Credit card result attribute (optional).
-
#bin ⇒ Object
Credit card attribute (optional).
-
#city ⇒ Object
Required attribute.
-
#country ⇒ Object
Required attribute.
-
#currency ⇒ Object
Transaction attribute (optional).
-
#cvv_result ⇒ Object
Credit card result attribute (optional).
-
#email ⇒ Object
User attribute (optional).
-
#forwarded_ip ⇒ Object
Miscellaneous attribute (optional).
-
#ip ⇒ Object
Required attribute.
-
#phone ⇒ Object
User attribute (optional).
-
#postal ⇒ Object
Required attribute.
-
#requested_type ⇒ String?
Uses the requested_type set on the instance, or if not present, the requested_type set during configuration.
-
#session_id ⇒ Object
Transaction linking attribute (optional).
-
#ship_addr ⇒ Object
Shipping address attribute (optional).
-
#ship_city ⇒ Object
Shipping address attribute (optional).
-
#ship_country ⇒ Object
Shipping address attribute (optional).
-
#ship_postal ⇒ Object
Shipping address attribute (optional).
-
#ship_state ⇒ Object
Shipping address attribute (optional).
-
#state ⇒ Object
Required attribute.
-
#txn_id ⇒ Object
Transaction attribute (optional).
-
#txn_type ⇒ Object
Transaction attribute (optional).
-
#user_agent ⇒ Object
Transaction linking attribute (optional).
Instance Method Summary collapse
-
#attributes ⇒ Hash
Hash of attributes that have been set.
-
#initialize {|_self| ... } ⇒ Transaction
constructor
A new instance of Transaction.
-
#risk_score ⇒ Float
Retrieves the risk score from MaxMind.
Constructor Details
#initialize {|_self| ... } ⇒ Transaction
Returns a new instance of Transaction.
33 34 35 36 37 38 39 |
# File 'lib/minfraud/transaction.rb', line 33 def initialize yield self unless has_required_attributes? raise TransactionError, 'You did not set all the required transaction attributes.' end validate_attributes end |
Instance Attribute Details
#accept_language ⇒ Object
Transaction linking attribute (optional)
22 23 24 |
# File 'lib/minfraud/transaction.rb', line 22 def accept_language @accept_language end |
#amount ⇒ Object
Transaction attribute (optional)
25 26 27 |
# File 'lib/minfraud/transaction.rb', line 25 def amount @amount end |
#avs_result ⇒ Object
Credit card result attribute (optional)
28 29 30 |
# File 'lib/minfraud/transaction.rb', line 28 def avs_result @avs_result end |
#bin ⇒ Object
Credit card attribute (optional)
19 20 21 |
# File 'lib/minfraud/transaction.rb', line 19 def bin @bin end |
#city ⇒ Object
Required attribute
10 11 12 |
# File 'lib/minfraud/transaction.rb', line 10 def city @city end |
#country ⇒ Object
Required attribute
10 11 12 |
# File 'lib/minfraud/transaction.rb', line 10 def country @country end |
#currency ⇒ Object
Transaction attribute (optional)
25 26 27 |
# File 'lib/minfraud/transaction.rb', line 25 def currency @currency end |
#cvv_result ⇒ Object
Credit card result attribute (optional)
28 29 30 |
# File 'lib/minfraud/transaction.rb', line 28 def cvv_result @cvv_result end |
#email ⇒ Object
User attribute (optional)
16 17 18 |
# File 'lib/minfraud/transaction.rb', line 16 def email @email end |
#forwarded_ip ⇒ Object
Miscellaneous attribute (optional)
31 32 33 |
# File 'lib/minfraud/transaction.rb', line 31 def forwarded_ip @forwarded_ip end |
#ip ⇒ Object
Required attribute
10 11 12 |
# File 'lib/minfraud/transaction.rb', line 10 def ip @ip end |
#phone ⇒ Object
User attribute (optional)
16 17 18 |
# File 'lib/minfraud/transaction.rb', line 16 def phone @phone end |
#postal ⇒ Object
Required attribute
10 11 12 |
# File 'lib/minfraud/transaction.rb', line 10 def postal @postal end |
#requested_type ⇒ String?
Uses the requested_type set on the instance, or if not present, the requested_type set during configuration
31 32 33 |
# File 'lib/minfraud/transaction.rb', line 31 def requested_type @requested_type end |
#session_id ⇒ Object
Transaction linking attribute (optional)
22 23 24 |
# File 'lib/minfraud/transaction.rb', line 22 def session_id @session_id end |
#ship_addr ⇒ Object
Shipping address attribute (optional)
13 14 15 |
# File 'lib/minfraud/transaction.rb', line 13 def ship_addr @ship_addr end |
#ship_city ⇒ Object
Shipping address attribute (optional)
13 14 15 |
# File 'lib/minfraud/transaction.rb', line 13 def ship_city @ship_city end |
#ship_country ⇒ Object
Shipping address attribute (optional)
13 14 15 |
# File 'lib/minfraud/transaction.rb', line 13 def ship_country @ship_country end |
#ship_postal ⇒ Object
Shipping address attribute (optional)
13 14 15 |
# File 'lib/minfraud/transaction.rb', line 13 def ship_postal @ship_postal end |
#ship_state ⇒ Object
Shipping address attribute (optional)
13 14 15 |
# File 'lib/minfraud/transaction.rb', line 13 def ship_state @ship_state end |
#state ⇒ Object
Required attribute
10 11 12 |
# File 'lib/minfraud/transaction.rb', line 10 def state @state end |
#txn_id ⇒ Object
Transaction attribute (optional)
25 26 27 |
# File 'lib/minfraud/transaction.rb', line 25 def txn_id @txn_id end |
#txn_type ⇒ Object
Transaction attribute (optional)
25 26 27 |
# File 'lib/minfraud/transaction.rb', line 25 def txn_type @txn_type end |
#user_agent ⇒ Object
Transaction linking attribute (optional)
22 23 24 |
# File 'lib/minfraud/transaction.rb', line 22 def user_agent @user_agent end |
Instance Method Details
#attributes ⇒ Hash
Hash of attributes that have been set
51 52 53 54 55 56 57 |
# File 'lib/minfraud/transaction.rb', line 51 def attributes attrs = [:ip, :city, :state, :postal, :country, :license_key, :ship_addr, :ship_city, :ship_state, :ship_postal, :ship_country, :email_domain, :email_md5, :phone, :bin, :session_id, :user_agent, :accept_language, :txn_id, :amount, :currency, :txn_type, :avs_result, :cvv_result, :requested_type, :forwarded_ip] attrs.map! do |a| [a, send(a)] end Hash[attrs] end |
#risk_score ⇒ Float
Retrieves the risk score from MaxMind. A higher score indicates a higher risk of fraud. For example, a score of 20 indicates a 20% chance that a transaction is fraudulent.
45 46 47 |
# File 'lib/minfraud/transaction.rb', line 45 def risk_score results.risk_score end |