Class: FraudlabsproRuby::Api::Order
- Inherits:
-
Object
- Object
- FraudlabsproRuby::Api::Order
- Defined in:
- lib/fraudlabspro_ruby/api/order.rb
Constant Summary collapse
- APPROVE =
Order statuses.
'APPROVE'- REJECT =
'REJECT'- REJECT_BLACKLIST =
'REJECT_BLACKLIST'- CREDIT_CARD =
Payment methods.
'CREDITCARD'- PAYPAL =
'PAYPAL'- GOOGLE_CHECKOUT =
'GOOGLECHECKOUT'- CASH_ON_DELIVERY =
'COD'- MONEY_ORDER =
'MONEYORDER'- WIRE_TRANSFER =
'WIRED'- BANK_DEPOSIT =
'BANKDEPOSIT'- BITCOIN =
'BITCOIN'- OTHERS =
'OTHERS'- FLP_ID =
ID types.
'fraudlabspro_id'- ORDER_ID =
'user_order_id'
Class Method Summary collapse
-
.do_hash(value) ⇒ Object
Hashes a string to protect its real value.
-
.feedback(params = {}) ⇒ Object
Sends feedback back to FraudLabs Pro.
-
.getTransaction(params = {}) ⇒ Object
Gets transaction result.
-
.validate(params = {}) ⇒ Object
Validate order for possible fraud.
Class Method Details
.do_hash(value) ⇒ Object
Hashes a string to protect its real value.
156 157 158 159 160 161 162 |
# File 'lib/fraudlabspro_ruby/api/order.rb', line 156 def self.do_hash(value) hash = 'fraudlabspro_' + value.to_s for i in 0..65536 hash = Digest::SHA1.hexdigest('fraudlabspro_' + hash) end return hash end |
.feedback(params = {}) ⇒ Object
Sends feedback back to FraudLabs Pro.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/fraudlabspro_ruby/api/order.rb', line 109 def self.feedback(params = {}) uri = URI.parse("https://api.fraudlabspro.com/v1/order/feedback") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data({ 'key' => FraudlabsproRuby::Configuration.api_key, 'format' => params[:format] || 'xml', 'id' => params[:transaction_id], 'action' => params[:status] || '', 'note' => params[:note] || '' }) response = http.request(request) if response == nil return false else return response end end |
.getTransaction(params = {}) ⇒ Object
Gets transaction result.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/fraudlabspro_ruby/api/order.rb', line 132 def self.getTransaction(params = {}) if params[:format] == nil params[:format] = 'xml' end if params[:id_type] == nil params[:id_type] = '' end uri = URI.parse("https://api.fraudlabspro.com/v1/order/result?key=" + FraudlabsproRuby::Configuration.api_key + "&format=" + params[:format] + "&id=" + params[:transaction_id] + "&id_type=" + params[:id_type]) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) if response == nil return false else return response end end |
.validate(params = {}) ⇒ Object
Validate order for possible fraud.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fraudlabspro_ruby/api/order.rb', line 33 def self.validate(params = {}) if params[:email] != nil email_domain = params[:email][(params[:email].index('@') + 1)..-1] end if params[:phone] != nil params[:phone] = params[:phone].scan(/\d/).join('') end if params[:amount] != nil params[:amount] = '%.2f' % params[:amount] end if params[:card_number] != nil params[:card_number] = params[:card_number][0..5] end uri = URI.parse("https://api.fraudlabspro.com/v1/order/screen") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data({ 'key' => FraudlabsproRuby::Configuration.api_key, 'format' => params[:format] || 'json', 'source' => 'FraudLabsPro Ruby SDK', 'source_version' => FraudlabsproRuby::VERSION, 'flp_checksum' => params[:flp_checksum] || '', # Billing information. 'ip' => params[:ip], 'first_name' => params[:first_name] || '', 'last_name' => params[:last_name] || '', 'username_hash' => do_hash(params[:username]) || '', 'password_hash' => do_hash(params[:password]) || '', 'email' => params[:email] || '', 'email_domain' => email_domain || '', 'user_phone' => params[:phone] || '', 'bill_addr' => params[:bill_addr] || '', 'bill_city' => params[:bill_city] || '', 'bill_state' => params[:bill_state] || '', 'bill_zip_code' => params[:bill_zip_code] || '', 'bill_country' => params[:bill_country] || '', # Order information. 'user_order_id' => params[:user_order_id] || '', 'user_order_memo' => params[:user_order_memo] || '', 'amount' => params[:amount] || 0, 'quantity' => params[:quantity] || 1, 'currency' => params[:currency] || 'USD', 'department' => params[:department] || '', 'payment_mode' => params[:payment_mode] || '', # Credit card information. 'bin_no' => params[:card_number] || '', 'card_hash' => do_hash(params[:card_number]) || '', 'avs_result' => params[:card_avs] || '', 'cvv_result' => params[:card_cvv] || '', # Shipping information. 'ship_addr' => params[:ship_addr] || '', 'ship_city' => params[:ship_city] || '', 'ship_state' => params[:ship_state] || '', 'ship_zip_code' => params[:ship_zip_code] || '', 'ship_country' => params[:ship_country] || '' }) response = http.request(request) if response == nil return false else return response end end |