fraudlabspro_ruby 3.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/Gemfile +6 -0
- data/Gemfile.lock +17 -0
- data/LICENSE.txt +21 -0
- data/README.md +223 -0
- data/Rakefile +2 -0
- data/fraudlabspro_ruby.gemspec +37 -0
- data/lib/fraudlabspro_ruby.rb +8 -0
- data/lib/fraudlabspro_ruby/api.rb +4 -0
- data/lib/fraudlabspro_ruby/api/order.rb +166 -0
- data/lib/fraudlabspro_ruby/api/smsverification.rb +59 -0
- data/lib/fraudlabspro_ruby/configuration.rb +9 -0
- data/lib/fraudlabspro_ruby/version.rb +3 -0
- data/spec/fraudlabspro_ruby_spec.rb +23 -0
- data/spec/spec_helper.rb +13 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f13a8ceb0b3dc2ba34d874840930ea3870916dc9
|
4
|
+
data.tar.gz: be08a9cee073918594434fb3671e7ccf547c8110
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9f992402e754102073961be160817bb026ac98915472277e62221e07939b954d8bcafb35d1dfec7a57c877c99f1390d6995b0c781632d8d95515742041801dc
|
7
|
+
data.tar.gz: 0b9acee02577d286db3cf48562044de137a6920104cf118a5eeda61b0e212b5902c6f8122b1bfffcb9a33827d7e76f59fd4ce5ad2e0db38f3bae2182fbdbd644
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 FraudLabsPro.com
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
FraudLabs Pro Ruby SDK
|
2
|
+
========================
|
3
|
+
This Ruby module enables user to easily implement fraud detection feature into their solution using the API from https://www.fraudlabspro.com.
|
4
|
+
|
5
|
+
Below are the features of this PHP module:
|
6
|
+
- Fraud analysis and scoring
|
7
|
+
- IP address geolocation & proxy validation
|
8
|
+
- Email address validation
|
9
|
+
- Credit card issuing bank validation
|
10
|
+
- Transaction velocity validation
|
11
|
+
- Device transaction validation
|
12
|
+
- Blacklist validation
|
13
|
+
- Custom rules trigger
|
14
|
+
- Email notification of fraud orders
|
15
|
+
- Mobile app notification of fraud orders
|
16
|
+
|
17
|
+
This module requires API key to function. You may subscribe a free API key at https://www.fraudlabspro.com
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Usage Example
|
23
|
+
============
|
24
|
+
### Validate Order
|
25
|
+
|
26
|
+
#### Object Properties
|
27
|
+
|
28
|
+
| Property Name | Property Type | Description |
|
29
|
+
| ------------------- | ------------- | ------------------------------------------------------------ |
|
30
|
+
| ip | string | IP address of online transaction. It supports both IPv4 and IPv6 address format. |
|
31
|
+
| first_name | string | User's first name. |
|
32
|
+
| last_name | string | User's last name. |
|
33
|
+
| username | string | User's username. |
|
34
|
+
| password | string | User's password. |
|
35
|
+
| email | string | User's email address. |
|
36
|
+
| phone | string | User's phone number. |
|
37
|
+
| bill_addr | string | Street address of billing address. |
|
38
|
+
| bill_city | string | City of billing address. |
|
39
|
+
| bill_state | string | State of billing address. It supports state codes, e.g. NY (New York), for state or province of United States or Canada. Please refer to [State & Province Codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes) for complete list. |
|
40
|
+
| bill_zip_code | string | Postal or ZIP code of billing address. |
|
41
|
+
| bill_country | string | Country of billing address. It requires the input of ISO-3166 alpha-2 country code, e.g. US for United States. Please refer to [Country Codes](https://www.fraudlabspro.com/developer/reference/country-codes) for complete list. |
|
42
|
+
| user_order_id | string | Merchant identifier to uniquely identify a transaction. It supports maximum of 15 characters user order id input. |
|
43
|
+
| user_order_memo | string | Merchant description of an order transaction. It supports maximum of 200 characters. |
|
44
|
+
| amount | float | Amount of the transaction. |
|
45
|
+
| quantity | integer | Total quantity of the transaction. |
|
46
|
+
| currency | string | Currency code used in the transaction. It requires the input of ISO-4217 (3 characters) currency code, e.g. USD for US Dollar. Please refer to [Currency Codes](https://www.fraudlabspro.com/developer/reference/currency-codes) for complete list. |
|
47
|
+
| department | string | Merchant identifier to uniquely identify a product or service department. |
|
48
|
+
| payment_mode | string | Payment mode of transaction. Please see [reference section](#payment-method). |
|
49
|
+
| card_number | string | Billing credit card number or BIN number. |
|
50
|
+
| card_avs | string | The single character AVS result returned by the credit card processor. Please refer to [AVS & CVV2 Response Codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes) for details. |
|
51
|
+
| card_cvv | string | The single character CVV2 result returned by the credit card processor. Please refer to [AVS & CVV2 Response Codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes) for details. |
|
52
|
+
| ship_addr | string | Street address of shipping address. |
|
53
|
+
| ship_city | string | City of shipping address. |
|
54
|
+
| ship_state | string | State of shipping address. It supports state codes, e.g. NY - New York, for state or province of United States or Canada. Please refer to [State & Province Codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes) for complete list. |
|
55
|
+
| ship_zip_code | string | Postal or ZIP code of shipping address. |
|
56
|
+
| ship_country | string | Country of shipping address. It requires the input of ISO-3166 alpha-2 country code, e.g. US for United States. Please refer to [Country Codes](https://www.fraudlabspro.com/developer/reference/country-codes) for complete list. |
|
57
|
+
|
58
|
+
|
59
|
+
```
|
60
|
+
require 'fraudlabspro_ruby'
|
61
|
+
|
62
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
63
|
+
|
64
|
+
result = FraudlabsproRuby::Api::Order.validate(
|
65
|
+
ip: '146.112.62.105',
|
66
|
+
first_name: 'Hector',
|
67
|
+
last_name: 'Henderson',
|
68
|
+
email: 'hh5566@gmail.com',
|
69
|
+
phone: '561-628-8674',
|
70
|
+
|
71
|
+
# Billing information
|
72
|
+
bill_addr: '1766 PowderHouse Road',
|
73
|
+
bill_city: 'West Palm Beach',
|
74
|
+
bill_state: 'FL',
|
75
|
+
bill_zip_code: '33401',
|
76
|
+
bill_country: 'US',
|
77
|
+
|
78
|
+
# Order information
|
79
|
+
user_order_id: '67398',
|
80
|
+
user_order_memo: 'Online Shop',
|
81
|
+
amount: '79.89',
|
82
|
+
quantity: '1',
|
83
|
+
currency: 'USD',
|
84
|
+
payment_mode: FraudlabsproRuby::Api::Order::CREDIT_CARD,
|
85
|
+
card_number: '4556553172971283',
|
86
|
+
|
87
|
+
# Shipping information
|
88
|
+
ship_addr: '4469 Chestnut Street',
|
89
|
+
ship_city: 'Tampa',
|
90
|
+
ship_state: 'FL',
|
91
|
+
ship_zip_code: '33602',
|
92
|
+
ship_country: 'US'
|
93
|
+
)
|
94
|
+
```
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
### Get Transaction
|
99
|
+
|
100
|
+
#### Parameter Properties
|
101
|
+
|
102
|
+
| Parameter Name | Parameter Type | Description |
|
103
|
+
| -------------- | -------------- | ------------------------------------------------------------ |
|
104
|
+
| transaction_id | string | FraudLabs Pro transaction ID or Order ID. |
|
105
|
+
| id_type | string | ID type. Either: **FraudlabsproRuby::Api::Order::FLP_ID** or **FraudlabsproRuby::Api::Order::ORDER_ID** |
|
106
|
+
|
107
|
+
```
|
108
|
+
require 'fraudlabspro_ruby'
|
109
|
+
|
110
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
111
|
+
|
112
|
+
result = FraudlabsproRuby::Api::Order.getTransaction(
|
113
|
+
transaction_id: '20180713-ZNVPV4',
|
114
|
+
id_type: FraudlabsproRuby::Api::Order::FLP_ID
|
115
|
+
)
|
116
|
+
```
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
### Feedback
|
121
|
+
|
122
|
+
#### Object Properties
|
123
|
+
|
124
|
+
| Property Name | Property Type | Description |
|
125
|
+
| --------------- | ------------- | ------------------------------------------------------------ |
|
126
|
+
| transaction_id | string | Unique transaction ID generated from **Validate** function. |
|
127
|
+
| status | string | Perform APPROVE, REJECT, or REJECT_BLACKLIST action to transaction. Refer to [reference section](#feedback-status) for status code. |
|
128
|
+
| note | string | Notes for the feedback request. |
|
129
|
+
|
130
|
+
```
|
131
|
+
require 'fraudlabspro_ruby'
|
132
|
+
|
133
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
134
|
+
|
135
|
+
result = FraudlabsproRuby::Api::Order.feedback(
|
136
|
+
transaction_id: '20180713-ZNVPV4',
|
137
|
+
status: FraudlabsproRuby::Api::Order::APPROVE
|
138
|
+
)
|
139
|
+
```
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
## SMS Verification
|
145
|
+
|
146
|
+
### Send SMS Verification
|
147
|
+
|
148
|
+
#### Object Properties
|
149
|
+
|
150
|
+
| Property Name | Property Type | Description |
|
151
|
+
| ------------- | ------------- | ------------------------------------------------------------ |
|
152
|
+
| tel | string | The recipient mobile phone number in E164 format which is a plus followed by just numbers with no spaces or parentheses. |
|
153
|
+
| mesg | string | The message template for the SMS. Add <otp> as placeholder for the actual OTP to be generated. Max length is 140 characters. |
|
154
|
+
| country_code | string | ISO 3166 country code for the recipient mobile phone number. If parameter is supplied, then some basic telephone number validation is done. |
|
155
|
+
|
156
|
+
```
|
157
|
+
require 'fraudlabspro_ruby'
|
158
|
+
|
159
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
160
|
+
|
161
|
+
result = FraudlabsproRuby::Api::SMSVerification.sendSMS(
|
162
|
+
tel: '+15616288674',
|
163
|
+
mesg: 'Hi, your OTP is <otp>.',
|
164
|
+
country_code: 'US'
|
165
|
+
)
|
166
|
+
```
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
### Get SMS Verification Result
|
171
|
+
|
172
|
+
#### Object Properties
|
173
|
+
|
174
|
+
| Property Name | Property Type | Description |
|
175
|
+
| ------------- | :-----------: | ------------------------------------------------------------ |
|
176
|
+
| tran_id | string | The unique ID that was returned by the Send SMS Verification that triggered the OTP sms. |
|
177
|
+
| otp | string | The OTP that was sent to the recipient’s phone. |
|
178
|
+
|
179
|
+
```
|
180
|
+
require 'fraudlabspro_ruby'
|
181
|
+
|
182
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
183
|
+
|
184
|
+
result = FraudlabsproRuby::Api::SMSVerification.verifySMS(
|
185
|
+
tran_id: 'UNIQUE_TRANS_ID',
|
186
|
+
otp: 'OTP_RECEIVED'
|
187
|
+
)
|
188
|
+
```
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
# Reference
|
193
|
+
|
194
|
+
#### Payment Method
|
195
|
+
|
196
|
+
| Payment Method |
|
197
|
+
| ---------------------------------------------- |
|
198
|
+
| FraudlabsproRuby::Api::Order::CREDIT_CARD |
|
199
|
+
| FraudlabsproRuby::Api::Order::PAYPAL |
|
200
|
+
| FraudlabsproRuby::Api::Order::GOOGLE_CHECKOUT |
|
201
|
+
| FraudlabsproRuby::Api::Order::CASH_ON_DELIVERY |
|
202
|
+
| FraudlabsproRuby::Api::Order::MONEY_ORDER |
|
203
|
+
| FraudlabsproRuby::Api::Order::WIRE_TRANSFER |
|
204
|
+
| FraudlabsproRuby::Api::Order::BANK_DEPOSIT |
|
205
|
+
| FraudlabsproRuby::Api::Order::BITCOIN |
|
206
|
+
| FraudlabsproRuby::Api::Order::OTHERS |
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
#### Feedback Status
|
211
|
+
|
212
|
+
| Feedback Status | Description |
|
213
|
+
| ---------------------------------------------- | ------------------------------------------- |
|
214
|
+
| FraudlabsproRuby::Api::Order::APPROVE | Approves an order that under review status. |
|
215
|
+
| FraudlabsproRuby::Api::Order::REJECT | Rejects an order than under review status. |
|
216
|
+
| FraudlabsproRuby::Api::Order::REJECT_BLACKLIST | Rejects and blacklists an order. |
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
LICENCE
|
222
|
+
=====================
|
223
|
+
See the LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "fraudlabspro_ruby/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "fraudlabspro_ruby"
|
9
|
+
s.version = FraudlabsproRuby::VERSION
|
10
|
+
s.authors = ["fraudlabspro"]
|
11
|
+
s.email = ["support@fraudlabspro.com"]
|
12
|
+
s.summary = "FraudLabs Pro Ruby SDK"
|
13
|
+
s.description = "A Ruby SDK enables user to easily implement fraud detection feature into their solution using the API from www.fraudlabspro.com"
|
14
|
+
s.homepage = "https://github.com/fraudlabspro/fraudlabspro-ruby"
|
15
|
+
s.licenses = ["MIT"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"fraudlabspro_ruby.gemspec",
|
28
|
+
"lib/fraudlabspro_ruby.rb",
|
29
|
+
"lib/fraudlabspro_ruby/api.rb",
|
30
|
+
"lib/fraudlabspro_ruby/api/order.rb",
|
31
|
+
"lib/fraudlabspro_ruby/api/smsverification.rb",
|
32
|
+
"lib/fraudlabspro_ruby/configuration.rb",
|
33
|
+
"lib/fraudlabspro_ruby/version.rb",
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"spec/fraudlabspro_ruby_spec.rb"
|
36
|
+
]
|
37
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'digest/sha1'
|
4
|
+
require "fraudlabspro_ruby/configuration"
|
5
|
+
require "fraudlabspro_ruby/version"
|
6
|
+
|
7
|
+
module FraudlabsproRuby
|
8
|
+
module Api
|
9
|
+
class Order
|
10
|
+
|
11
|
+
# Order statuses.
|
12
|
+
APPROVE = 'APPROVE';
|
13
|
+
REJECT = 'REJECT';
|
14
|
+
REJECT_BLACKLIST = 'REJECT_BLACKLIST';
|
15
|
+
|
16
|
+
# Payment methods.
|
17
|
+
CREDIT_CARD = 'CREDITCARD'
|
18
|
+
PAYPAL = 'PAYPAL';
|
19
|
+
GOOGLE_CHECKOUT = 'GOOGLECHECKOUT';
|
20
|
+
CASH_ON_DELIVERY = 'COD';
|
21
|
+
MONEY_ORDER = 'MONEYORDER';
|
22
|
+
WIRE_TRANSFER = 'WIRED';
|
23
|
+
BANK_DEPOSIT = 'BANKDEPOSIT';
|
24
|
+
BITCOIN = 'BITCOIN';
|
25
|
+
OTHERS = 'OTHERS';
|
26
|
+
|
27
|
+
# ID types.
|
28
|
+
FLP_ID = 'fraudlabspro_id';
|
29
|
+
ORDER_ID = 'user_order_id';
|
30
|
+
|
31
|
+
|
32
|
+
# Validate order for possible fraud.
|
33
|
+
def self.validate(params = {})
|
34
|
+
if params[:email] != nil
|
35
|
+
email_domain = params[:email][(params[:email].index('@') + 1)..-1]
|
36
|
+
end
|
37
|
+
|
38
|
+
if params[:phone] != nil
|
39
|
+
params[:phone] = params[:phone].scan(/\d/).join('')
|
40
|
+
end
|
41
|
+
|
42
|
+
if params[:amount] != nil
|
43
|
+
params[:amount] = '%.2f' % params[:amount]
|
44
|
+
end
|
45
|
+
|
46
|
+
if params[:card_number] != nil
|
47
|
+
params[:card_number] = params[:card_number][0..5]
|
48
|
+
end
|
49
|
+
|
50
|
+
uri = URI.parse("https://api.fraudlabspro.com/v1/order/screen")
|
51
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
52
|
+
http.use_ssl = true
|
53
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
54
|
+
request.set_form_data({
|
55
|
+
'key' => FraudlabsproRuby::Configuration.api_key,
|
56
|
+
'format' => params[:format] || 'json',
|
57
|
+
'source' => 'FraudLabsPro Ruby SDK',
|
58
|
+
'source_version' => FraudlabsproRuby::VERSION,
|
59
|
+
'flp_checksum' => params[:flp_checksum] || '',
|
60
|
+
|
61
|
+
# Billing information.
|
62
|
+
'ip' => params[:ip],
|
63
|
+
'first_name' => params[:first_name] || '',
|
64
|
+
'last_name' => params[:last_name] || '',
|
65
|
+
'username_hash' => do_hash(params[:username]) || '',
|
66
|
+
'password_hash' => do_hash(params[:password]) || '',
|
67
|
+
'email' => params[:email] || '',
|
68
|
+
'email_domain' => email_domain || '',
|
69
|
+
'user_phone' => params[:phone] || '',
|
70
|
+
'bill_addr' => params[:bill_addr] || '',
|
71
|
+
'bill_city' => params[:bill_city] || '',
|
72
|
+
'bill_state' => params[:bill_state] || '',
|
73
|
+
'bill_zip_code' => params[:bill_zip_code] || '',
|
74
|
+
'bill_country' => params[:bill_country] || '',
|
75
|
+
|
76
|
+
# Order information.
|
77
|
+
'user_order_id' => params[:user_order_id] || '',
|
78
|
+
'user_order_memo' => params[:user_order_memo] || '',
|
79
|
+
'amount' => params[:amount] || 0,
|
80
|
+
'quantity' => params[:quantity] || 1,
|
81
|
+
'currency' => params[:currency] || 'USD',
|
82
|
+
'department' => params[:department] || '',
|
83
|
+
'payment_mode' => params[:payment_mode] || '',
|
84
|
+
|
85
|
+
# Credit card information.
|
86
|
+
'bin_no' => params[:card_number] || '',
|
87
|
+
'card_hash' => do_hash(params[:card_number]) || '',
|
88
|
+
'avs_result' => params[:card_avs] || '',
|
89
|
+
'cvv_result' => params[:card_cvv] || '',
|
90
|
+
|
91
|
+
# Shipping information.
|
92
|
+
'ship_addr' => params[:ship_addr] || '',
|
93
|
+
'ship_city' => params[:ship_city] || '',
|
94
|
+
'ship_state' => params[:ship_state] || '',
|
95
|
+
'ship_zip_code' => params[:ship_zip_code] || '',
|
96
|
+
'ship_country' => params[:ship_country] || ''
|
97
|
+
})
|
98
|
+
|
99
|
+
response = http.request(request)
|
100
|
+
|
101
|
+
if response == nil
|
102
|
+
return false
|
103
|
+
else
|
104
|
+
return response
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Sends feedback back to FraudLabs Pro.
|
109
|
+
def self.feedback(params = {})
|
110
|
+
uri = URI.parse("https://api.fraudlabspro.com/v1/order/feedback")
|
111
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
112
|
+
http.use_ssl = true
|
113
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
114
|
+
request.set_form_data({
|
115
|
+
'key' => FraudlabsproRuby::Configuration.api_key,
|
116
|
+
'format' => params[:format] || 'xml',
|
117
|
+
'id' => params[:transaction_id],
|
118
|
+
'action' => params[:status] || '',
|
119
|
+
'note' => params[:note] || ''
|
120
|
+
})
|
121
|
+
|
122
|
+
response = http.request(request)
|
123
|
+
|
124
|
+
if response == nil
|
125
|
+
return false
|
126
|
+
else
|
127
|
+
return response
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Gets transaction result.
|
132
|
+
def self.getTransaction(params = {})
|
133
|
+
if params[:format] == nil
|
134
|
+
params[:format] = 'xml'
|
135
|
+
end
|
136
|
+
|
137
|
+
if params[:id_type] == nil
|
138
|
+
params[:id_type] = ''
|
139
|
+
end
|
140
|
+
|
141
|
+
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])
|
142
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
143
|
+
http.use_ssl = true
|
144
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
145
|
+
|
146
|
+
response = http.request(request)
|
147
|
+
|
148
|
+
if response == nil
|
149
|
+
return false
|
150
|
+
else
|
151
|
+
return response
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Hashes a string to protect its real value.
|
156
|
+
def self.do_hash(value)
|
157
|
+
hash = 'fraudlabspro_' + value.to_s
|
158
|
+
for i in 0..65536
|
159
|
+
hash = Digest::SHA1.hexdigest('fraudlabspro_' + hash)
|
160
|
+
end
|
161
|
+
return hash
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require "fraudlabspro_ruby/configuration"
|
4
|
+
require "fraudlabspro_ruby/version"
|
5
|
+
|
6
|
+
module FraudlabsproRuby
|
7
|
+
module Api
|
8
|
+
class SMSVerification
|
9
|
+
|
10
|
+
# Send SMS Verification for authentication.
|
11
|
+
def self.sendSMS(params = {})
|
12
|
+
if params[:tel].index('+') != 0
|
13
|
+
params[:tel] = '+' + params[:tel]
|
14
|
+
end
|
15
|
+
|
16
|
+
uri = URI.parse("https://api.fraudlabspro.com/v1/verification/send")
|
17
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
18
|
+
http.use_ssl = true
|
19
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
20
|
+
request.set_form_data({
|
21
|
+
'key' => FraudlabsproRuby::Configuration.api_key,
|
22
|
+
'format' => params[:format] || 'json',
|
23
|
+
'tel' => params[:tel],
|
24
|
+
'mesg' => params[:mesg] || '',
|
25
|
+
'country_code' => params[:country_code] || ''
|
26
|
+
})
|
27
|
+
|
28
|
+
response = http.request(request)
|
29
|
+
|
30
|
+
if response == nil
|
31
|
+
return false
|
32
|
+
else
|
33
|
+
return response
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get Verification result.
|
38
|
+
def self.verifySMS(params = {})
|
39
|
+
if params[:format] == nil
|
40
|
+
params[:format] = 'json'
|
41
|
+
end
|
42
|
+
|
43
|
+
uri = URI.parse("https://api.fraudlabspro.com/v1/verification/result?key=" + FraudlabsproRuby::Configuration.api_key + "&format=" + params[:format] + "&tran_id=" + params[:tran_id] + "&otp=" + params[:otp])
|
44
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
45
|
+
http.use_ssl = true
|
46
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
47
|
+
|
48
|
+
response = http.request(request)
|
49
|
+
|
50
|
+
if response == nil
|
51
|
+
return false
|
52
|
+
else
|
53
|
+
return response
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FraudlabsproRuby" do
|
4
|
+
it "work correctly with order validate" do
|
5
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
6
|
+
result = FraudlabsproRuby::Api::Order.validate(
|
7
|
+
ip: '146.112.62.105'
|
8
|
+
)
|
9
|
+
expect(result).not_to be nil
|
10
|
+
expect(result.code).to eq '200'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "work correctly with get transaction" do
|
14
|
+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
15
|
+
result = FraudlabsproRuby::Api::Order.getTransaction(
|
16
|
+
transaction_id: '20180713-ZNVPV4',
|
17
|
+
id_type: FraudlabsproRuby::Api::Order::FLP_ID
|
18
|
+
)
|
19
|
+
expect(result).not_to be nil
|
20
|
+
expect(result.code).to eq '200'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'fraudlabspro_ruby'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
13
|
+
require 'awesome_print'
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fraudlabspro_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- fraudlabspro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Ruby SDK enables user to easily implement fraud detection feature into
|
14
|
+
their solution using the API from www.fraudlabspro.com
|
15
|
+
email:
|
16
|
+
- support@fraudlabspro.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- LICENSE.txt
|
21
|
+
- README.md
|
22
|
+
files:
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- fraudlabspro_ruby.gemspec
|
29
|
+
- lib/fraudlabspro_ruby.rb
|
30
|
+
- lib/fraudlabspro_ruby/api.rb
|
31
|
+
- lib/fraudlabspro_ruby/api/order.rb
|
32
|
+
- lib/fraudlabspro_ruby/api/smsverification.rb
|
33
|
+
- lib/fraudlabspro_ruby/configuration.rb
|
34
|
+
- lib/fraudlabspro_ruby/version.rb
|
35
|
+
- spec/fraudlabspro_ruby_spec.rb
|
36
|
+
- spec/spec_helper.rb
|
37
|
+
homepage: https://github.com/fraudlabspro/fraudlabspro-ruby
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.6.14
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: FraudLabs Pro Ruby SDK
|
61
|
+
test_files: []
|