Class: Minfraud::Transaction

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Transaction

Returns a new instance of Transaction.

Yields:

  • (_self)

Yield Parameters:


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_languageObject

Transaction linking attribute (optional)


22
23
24
# File 'lib/minfraud/transaction.rb', line 22

def accept_language
  @accept_language
end

#amountObject

Transaction attribute (optional)


25
26
27
# File 'lib/minfraud/transaction.rb', line 25

def amount
  @amount
end

#avs_resultObject

Credit card result attribute (optional)


28
29
30
# File 'lib/minfraud/transaction.rb', line 28

def avs_result
  @avs_result
end

#binObject

Credit card attribute (optional)


19
20
21
# File 'lib/minfraud/transaction.rb', line 19

def bin
  @bin
end

#cityObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def city
  @city
end

#countryObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def country
  @country
end

#currencyObject

Transaction attribute (optional)


25
26
27
# File 'lib/minfraud/transaction.rb', line 25

def currency
  @currency
end

#cvv_resultObject

Credit card result attribute (optional)


28
29
30
# File 'lib/minfraud/transaction.rb', line 28

def cvv_result
  @cvv_result
end

#emailObject

User attribute (optional)


16
17
18
# File 'lib/minfraud/transaction.rb', line 16

def email
  @email
end

#forwarded_ipObject

Miscellaneous attribute (optional)


31
32
33
# File 'lib/minfraud/transaction.rb', line 31

def forwarded_ip
  @forwarded_ip
end

#ipObject

Required attribute


10
11
12
# File 'lib/minfraud/transaction.rb', line 10

def ip
  @ip
end

#phoneObject

User attribute (optional)


16
17
18
# File 'lib/minfraud/transaction.rb', line 16

def phone
  @phone
end

#postalObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def postal
  @postal
end

#requested_typeString?

Uses the requested_type set on the instance, or if not present, the requested_type set during configuration

Returns:

  • (String, nil)

    requested type


31
32
33
# File 'lib/minfraud/transaction.rb', line 31

def requested_type
  @requested_type
end

#session_idObject

Transaction linking attribute (optional)


22
23
24
# File 'lib/minfraud/transaction.rb', line 22

def session_id
  @session_id
end

#ship_addrObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def ship_addr
  @ship_addr
end

#ship_cityObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def ship_city
  @ship_city
end

#ship_countryObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def ship_country
  @ship_country
end

#ship_postalObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def ship_postal
  @ship_postal
end

#ship_stateObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def ship_state
  @ship_state
end

#stateObject

Shipping address attribute (optional)


13
14
15
# File 'lib/minfraud/transaction.rb', line 13

def state
  @state
end

#txn_idObject

Transaction attribute (optional)


25
26
27
# File 'lib/minfraud/transaction.rb', line 25

def txn_id
  @txn_id
end

#txn_typeObject

Transaction attribute (optional)


25
26
27
# File 'lib/minfraud/transaction.rb', line 25

def txn_type
  @txn_type
end

#user_agentObject

Transaction linking attribute (optional)


22
23
24
# File 'lib/minfraud/transaction.rb', line 22

def user_agent
  @user_agent
end

Instance Method Details

#anonymous_proxyObject


97
98
99
# File 'lib/minfraud/transaction.rb', line 97

def anonymous_proxy
  results.anonymous_proxy
end

#attributesHash

Hash of attributes that have been set

Returns:

  • (Hash)

    present attributes


107
108
109
110
111
112
113
# File 'lib/minfraud/transaction.rb', line 107

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

#corporate_proxyObject


101
102
103
# File 'lib/minfraud/transaction.rb', line 101

def corporate_proxy
  results.ip_corporate_proxy
end

#country_codeObject


53
54
55
# File 'lib/minfraud/transaction.rb', line 53

def country_code
  results.country_code
end

#distanceObject


49
50
51
# File 'lib/minfraud/transaction.rb', line 49

def distance
  results.distance
end

#high_risk_countryObject


73
74
75
# File 'lib/minfraud/transaction.rb', line 73

def high_risk_country
  results.high_risk_country
end

#ip_accuracy_radiusObject


81
82
83
# File 'lib/minfraud/transaction.rb', line 81

def ip_accuracy_radius
  results.ip_accuracy_radius
end

#ip_area_codeObject


85
86
87
# File 'lib/minfraud/transaction.rb', line 85

def ip_area_code
  results.ip_area_code
end

#ip_cityObject


61
62
63
# File 'lib/minfraud/transaction.rb', line 61

def ip_city
  results.ip_city
end

#ip_country_nameObject


93
94
95
# File 'lib/minfraud/transaction.rb', line 93

def ip_country_name
  results.ip_country_name
end

#ip_latitudeObject


65
66
67
# File 'lib/minfraud/transaction.rb', line 65

def ip_latitude
  results.ip_latitude
end

#ip_longitudeObject


69
70
71
# File 'lib/minfraud/transaction.rb', line 69

def ip_longitude
  results.ip_longitude
end

#ip_postal_codeObject


77
78
79
# File 'lib/minfraud/transaction.rb', line 77

def ip_postal_code
  results.ip_postal_code
end

#ip_regionObject


57
58
59
# File 'lib/minfraud/transaction.rb', line 57

def ip_region
  results.ip_region
end

#ip_region_nameObject


89
90
91
# File 'lib/minfraud/transaction.rb', line 89

def ip_region_name
  results.ip_region_name
end

#risk_scoreFloat

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.

Returns:

  • (Float)

    0.01 - 100.0


45
46
47
# File 'lib/minfraud/transaction.rb', line 45

def risk_score
  results.risk_score
end