fraudlabspro_ruby 3.2.0 → 4.0.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +3 -3
- data/fraudlabspro_ruby.gemspec +2 -1
- data/lib/fraudlabspro_ruby/api/order.rb +6 -10
- data/lib/fraudlabspro_ruby/api/smsverification.rb +5 -7
- data/lib/fraudlabspro_ruby/version.rb +1 -1
- data/spec/fraudlabspro_ruby_fraudvalidation_spec.rb +69 -0
- data/spec/fraudlabspro_ruby_smsverification_spec.rb +34 -0
- data/spec/spec_helper.rb +3 -1
- metadata +8 -8
- data/spec/fraudlabspro_ruby_spec.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea78ccb89debc549cee9658464a8196697d8db7759cba308c0c46ba1ada412c
|
4
|
+
data.tar.gz: 97b0a290bc3da3b2c230b79efe9218e38b5d51706009eec6e76f4bf95d8d4ed1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c7648891d25bdc4f3ee2b72dc042f63c8f5d923ffdb95f81e99b9facd83e7f006c744f9e5e8437c6b5dbad075f80f5d5900333fdf16728854ccdc6df13cd996
|
7
|
+
data.tar.gz: 3268be5b12d9bf20a5ba37bf4ce85be076a32e9b3749c13793b85908917ace42bb57f8a5c36b20276bbb0494328bf04a16a6add623e0e6cdd49b739a0e2bf06e
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@ FraudLabs Pro Ruby SDK
|
|
2
2
|
========================
|
3
3
|
This Ruby module enables user to easily implement fraud detection feature into their solution using the API from https://www.fraudlabspro.com.
|
4
4
|
|
5
|
-
Below are the features of this
|
5
|
+
Below are the features of this Ruby module:
|
6
6
|
- Fraud analysis and scoring
|
7
7
|
- IP address geolocation & proxy validation
|
8
8
|
- Email address validation
|
@@ -45,7 +45,7 @@ Usage Example
|
|
45
45
|
| quantity | integer | Total quantity of the transaction. |
|
46
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
47
|
| department | string | Merchant identifier to uniquely identify a product or service department. |
|
48
|
-
| payment_mode | string | Payment mode of transaction.
|
48
|
+
| payment_mode | string | Payment mode of transaction. Valid values: creditcard, affirm, paypal, googlecheckout, bitcoin, cod, moneyorder, wired, bankdeposit, elviauthorized, paymitco, cybersource, sezzle, viabill, amazonpay, pmnts_gateway, giftcard, others. |
|
49
49
|
| card_number | string | Billing credit card number or BIN number. |
|
50
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
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. |
|
@@ -160,7 +160,7 @@ require 'fraudlabspro_ruby'
|
|
160
160
|
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
|
161
161
|
|
162
162
|
result = FraudlabsproRuby::Api::SMSVerification.sendSMS(
|
163
|
-
tel: '+
|
163
|
+
tel: '+123456789',
|
164
164
|
mesg: 'Hi, your OTP is <otp>.',
|
165
165
|
otp_timeout: 3600,
|
166
166
|
country_code: 'US'
|
data/fraudlabspro_ruby.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/fraudlabspro_ruby/configuration.rb",
|
33
33
|
"lib/fraudlabspro_ruby/version.rb",
|
34
34
|
"spec/spec_helper.rb",
|
35
|
-
"spec/
|
35
|
+
"spec/fraudlabspro_ruby_fraudvalidation_spec.rb",
|
36
|
+
"spec/fraudlabspro_ruby_smsverification_spec.rb"
|
36
37
|
]
|
37
38
|
end
|
@@ -47,14 +47,14 @@ module FraudlabsproRuby
|
|
47
47
|
params[:card_number] = params[:card_number][0..5]
|
48
48
|
end
|
49
49
|
|
50
|
-
uri = URI.parse("https://api.fraudlabspro.com/
|
50
|
+
uri = URI.parse("https://api.fraudlabspro.com/v2/order/screen")
|
51
51
|
http = Net::HTTP.new(uri.host, uri.port)
|
52
52
|
http.use_ssl = true
|
53
53
|
request = Net::HTTP::Post.new(uri.request_uri)
|
54
54
|
request.set_form_data({
|
55
55
|
'key' => FraudlabsproRuby::Configuration.api_key,
|
56
|
-
'format' =>
|
57
|
-
'source' => '
|
56
|
+
'format' => 'json',
|
57
|
+
'source' => 'sdk-ruby',
|
58
58
|
'source_version' => FraudlabsproRuby::VERSION,
|
59
59
|
'flp_checksum' => params[:flp_checksum] || '',
|
60
60
|
|
@@ -107,13 +107,13 @@ module FraudlabsproRuby
|
|
107
107
|
|
108
108
|
# Sends feedback back to FraudLabs Pro.
|
109
109
|
def self.feedback(params = {})
|
110
|
-
uri = URI.parse("https://api.fraudlabspro.com/
|
110
|
+
uri = URI.parse("https://api.fraudlabspro.com/v2/order/feedback")
|
111
111
|
http = Net::HTTP.new(uri.host, uri.port)
|
112
112
|
http.use_ssl = true
|
113
113
|
request = Net::HTTP::Post.new(uri.request_uri)
|
114
114
|
request.set_form_data({
|
115
115
|
'key' => FraudlabsproRuby::Configuration.api_key,
|
116
|
-
'format' =>
|
116
|
+
'format' => 'json',
|
117
117
|
'id' => params[:transaction_id],
|
118
118
|
'action' => params[:status] || '',
|
119
119
|
'note' => params[:note] || ''
|
@@ -130,15 +130,11 @@ module FraudlabsproRuby
|
|
130
130
|
|
131
131
|
# Gets transaction result.
|
132
132
|
def self.getTransaction(params = {})
|
133
|
-
if params[:format] == nil
|
134
|
-
params[:format] = 'xml'
|
135
|
-
end
|
136
|
-
|
137
133
|
if params[:id_type] == nil
|
138
134
|
params[:id_type] = ''
|
139
135
|
end
|
140
136
|
|
141
|
-
uri = URI.parse("https://api.fraudlabspro.com/
|
137
|
+
uri = URI.parse("https://api.fraudlabspro.com/v2/order/result?key=" + FraudlabsproRuby::Configuration.api_key + "&format=json&id=" + params[:transaction_id] + "&id_type=" + params[:id_type])
|
142
138
|
http = Net::HTTP.new(uri.host, uri.port)
|
143
139
|
http.use_ssl = true
|
144
140
|
request = Net::HTTP::Get.new(uri.request_uri)
|
@@ -13,13 +13,15 @@ module FraudlabsproRuby
|
|
13
13
|
params[:tel] = '+' + params[:tel]
|
14
14
|
end
|
15
15
|
|
16
|
-
uri = URI.parse("https://api.fraudlabspro.com/
|
16
|
+
uri = URI.parse("https://api.fraudlabspro.com/v2/verification/send")
|
17
17
|
http = Net::HTTP.new(uri.host, uri.port)
|
18
18
|
http.use_ssl = true
|
19
19
|
request = Net::HTTP::Post.new(uri.request_uri)
|
20
20
|
request.set_form_data({
|
21
21
|
'key' => FraudlabsproRuby::Configuration.api_key,
|
22
|
-
'format' =>
|
22
|
+
'format' => 'json',
|
23
|
+
'source' => 'sdk-ruby',
|
24
|
+
'source_version' => FraudlabsproRuby::VERSION,
|
23
25
|
'tel' => params[:tel],
|
24
26
|
'mesg' => params[:mesg] || '',
|
25
27
|
'otp_timeout' => params[:otp_timeout] || 3600,
|
@@ -37,11 +39,7 @@ module FraudlabsproRuby
|
|
37
39
|
|
38
40
|
# Get Verification result.
|
39
41
|
def self.verifySMS(params = {})
|
40
|
-
|
41
|
-
params[:format] = 'json'
|
42
|
-
end
|
43
|
-
|
44
|
-
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])
|
42
|
+
uri = URI.parse("https://api.fraudlabspro.com/v2/verification/result?key=" + FraudlabsproRuby::Configuration.api_key + "&format=json&tran_id=" + params[:tran_id] + "&otp=" + params[:otp])
|
45
43
|
http = Net::HTTP.new(uri.host, uri.port)
|
46
44
|
http.use_ssl = true
|
47
45
|
request = Net::HTTP::Get.new(uri.request_uri)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FraudlabsproRuby" do
|
4
|
+
it "work correctly with invalid Api Key" do
|
5
|
+
FraudlabsproRuby::Configuration.api_key = ''
|
6
|
+
result = FraudlabsproRuby::Api::Order.validate(
|
7
|
+
ip: '8.8.8.8'
|
8
|
+
)
|
9
|
+
data = JSON.parse(result.body)
|
10
|
+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "work correctly with Api Key exist" do
|
14
|
+
if $test_api_key == 'YOUR_API_KEY'
|
15
|
+
print "/*
|
16
|
+
* You could enter a FraudLabs Pro API Key in spec/spec_helper.rb
|
17
|
+
* for real web service calling test.
|
18
|
+
*
|
19
|
+
* You could sign up for a free API key at https://www.fraudlabspro.com/pricing
|
20
|
+
* if you do not have one.
|
21
|
+
*/"
|
22
|
+
expect($test_api_key).to eq 'YOUR_API_KEY'
|
23
|
+
else
|
24
|
+
expect($test_api_key).to_not eq 'YOUR_API_KEY'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "work correctly with validate order" do
|
29
|
+
FraudlabsproRuby::Configuration.api_key = $test_api_key
|
30
|
+
result = FraudlabsproRuby::Api::Order.validate(
|
31
|
+
ip: '8.8.8.8'
|
32
|
+
)
|
33
|
+
data = JSON.parse(result.body)
|
34
|
+
if $test_api_key == 'YOUR_API_KEY'
|
35
|
+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
|
36
|
+
else
|
37
|
+
expect(data['ip_geolocation']['country_code']).to eq 'US'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "work correctly with get transaction" do
|
42
|
+
FraudlabsproRuby::Configuration.api_key = $test_api_key
|
43
|
+
result = FraudlabsproRuby::Api::Order.getTransaction(
|
44
|
+
transaction_id: '20180713-ZNVPV4',
|
45
|
+
id_type: FraudlabsproRuby::Api::Order::FLP_ID
|
46
|
+
)
|
47
|
+
data = JSON.parse(result.body)
|
48
|
+
if $test_api_key == 'YOUR_API_KEY'
|
49
|
+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
|
50
|
+
else
|
51
|
+
expect(data['error']['error_message']).to eq 'TRANSACTION NOT FOUND'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "work correctly with validate order" do
|
56
|
+
FraudlabsproRuby::Configuration.api_key = $test_api_key
|
57
|
+
result = FraudlabsproRuby::Api::Order.feedback(
|
58
|
+
transaction_id: '20180713-ZNVPV4',
|
59
|
+
status: FraudlabsproRuby::Api::Order::APPROVE
|
60
|
+
)
|
61
|
+
data = JSON.parse(result.body)
|
62
|
+
if $test_api_key == 'YOUR_API_KEY'
|
63
|
+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
|
64
|
+
else
|
65
|
+
expect(data['error']['error_message']).to eq 'TRANSACTION NOT FOUND'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "FraudlabsproRuby" do
|
4
|
+
it "work correctly with send sms" do
|
5
|
+
FraudlabsproRuby::Configuration.api_key = $test_api_key
|
6
|
+
result = FraudlabsproRuby::Api::SMSVerification.sendSMS(
|
7
|
+
tel: '+123456789',
|
8
|
+
mesg: 'Hi, your OTP is <otp>.',
|
9
|
+
otp_timeout: 3600,
|
10
|
+
country_code: 'US'
|
11
|
+
)
|
12
|
+
data = JSON.parse(result.body)
|
13
|
+
if $test_api_key == 'YOUR_API_KEY'
|
14
|
+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
|
15
|
+
else
|
16
|
+
expect(data['error']['error_message']).to eq 'INVALID PHONE NUMBER'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "work correctly with verify otp" do
|
21
|
+
FraudlabsproRuby::Configuration.api_key = $test_api_key
|
22
|
+
result = FraudlabsproRuby::Api::SMSVerification.verifySMS(
|
23
|
+
tran_id: 'UNIQUE_TRANS_ID',
|
24
|
+
otp: 'OTP_RECEIVED'
|
25
|
+
)
|
26
|
+
data = JSON.parse(result.body)
|
27
|
+
if $test_api_key == 'YOUR_API_KEY'
|
28
|
+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
|
29
|
+
else
|
30
|
+
expect(data['error']['error_message']).to eq 'INVALID OTP'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
4
|
require 'fraudlabspro_ruby'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
# Requires supporting files with custom matchers and macros, etc,
|
7
8
|
# in ./support/ and its subdirectories.
|
@@ -10,4 +11,5 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
10
11
|
RSpec.configure do |config|
|
11
12
|
|
12
13
|
end
|
13
|
-
|
14
|
+
|
15
|
+
$test_api_key = 'YOUR_API_KEY'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fraudlabspro_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fraudlabspro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby SDK enables user to easily implement fraud detection feature into
|
14
14
|
their solution using the API from www.fraudlabspro.com
|
@@ -32,13 +32,14 @@ files:
|
|
32
32
|
- lib/fraudlabspro_ruby/api/smsverification.rb
|
33
33
|
- lib/fraudlabspro_ruby/configuration.rb
|
34
34
|
- lib/fraudlabspro_ruby/version.rb
|
35
|
-
- spec/
|
35
|
+
- spec/fraudlabspro_ruby_fraudvalidation_spec.rb
|
36
|
+
- spec/fraudlabspro_ruby_smsverification_spec.rb
|
36
37
|
- spec/spec_helper.rb
|
37
38
|
homepage: https://github.com/fraudlabspro/fraudlabspro-ruby
|
38
39
|
licenses:
|
39
40
|
- MIT
|
40
41
|
metadata: {}
|
41
|
-
post_install_message:
|
42
|
+
post_install_message:
|
42
43
|
rdoc_options: []
|
43
44
|
require_paths:
|
44
45
|
- lib
|
@@ -53,9 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
requirements: []
|
56
|
-
|
57
|
-
|
58
|
-
signing_key:
|
57
|
+
rubygems_version: 3.4.22
|
58
|
+
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: FraudLabs Pro Ruby SDK
|
61
61
|
test_files: []
|
@@ -1,23 +0,0 @@
|
|
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
|