braintree 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/version.rb +1 -1
- data/spec/integration/braintree/credit_card_spec.rb +7 -5
- data/spec/integration/braintree/merchant_spec.rb +2 -2
- data/spec/integration/braintree/transaction_spec.rb +24 -16
- data/spec/integration/spec_helper.rb +7 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +6 -2
- data/spec/unit/braintree/risk_data_spec.rb +9 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6f4e51f43d816075ea0d94fdf7b9c7cc93b66293d6f03eb2bf2c1b387f25f46
|
4
|
+
data.tar.gz: b0318dcc9f2a0d539a2dd43090e93bd2deaaedc339a7fe56844714b3a2d0e794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5db81d38673b53ee88428054ede01e065ae0ff4399548ddddd951676e34dc5cde4ca87654a39f9f3ef3a50403974a895e4347c876d85139bea88937dadc5e55f
|
7
|
+
data.tar.gz: 1bb19f771028a007c21da653a5efc1ca484f5c237da528eafab7bb783840973739df2c88cd7ea54ad21e1ec9bad592eebc62ff4eddf96965ba8307eccd91d6c4
|
data/lib/braintree/risk_data.rb
CHANGED
@@ -6,16 +6,18 @@ module Braintree
|
|
6
6
|
attr_reader :customer_location_zip
|
7
7
|
attr_reader :customer_tenure
|
8
8
|
attr_reader :decision
|
9
|
+
attr_reader :decision_reasons
|
9
10
|
attr_reader :device_data_captured
|
10
11
|
attr_reader :fraud_service_provider
|
11
12
|
attr_reader :id
|
13
|
+
attr_reader :transaction_risk_score
|
12
14
|
|
13
15
|
def initialize(attributes)
|
14
16
|
set_instance_variables_from_hash attributes unless attributes.nil?
|
15
17
|
end
|
16
18
|
|
17
19
|
def inspect
|
18
|
-
attr_order = [:id, :decision, :device_data_captured, :fraud_service_provider]
|
20
|
+
attr_order = [:id, :decision, :decision_reasons, :device_data_captured, :fraud_service_provider, :transaction_risk_score]
|
19
21
|
formatted_attrs = attr_order.map do |attr|
|
20
22
|
"#{attr}: #{send(attr).inspect}"
|
21
23
|
end
|
@@ -2,16 +2,21 @@ module Braintree
|
|
2
2
|
class ThreeDSecureInfo # :nodoc:
|
3
3
|
include BaseModule
|
4
4
|
|
5
|
+
attr_reader :acs_transaction_id
|
6
|
+
attr_reader :cavv
|
7
|
+
attr_reader :ds_transaction_id
|
8
|
+
attr_reader :eci_flag
|
5
9
|
attr_reader :enrolled
|
6
|
-
attr_reader :liability_shifted
|
7
10
|
attr_reader :liability_shift_possible
|
11
|
+
attr_reader :liability_shifted
|
12
|
+
attr_reader :pares_status
|
8
13
|
attr_reader :status
|
9
|
-
attr_reader :cavv
|
10
|
-
attr_reader :xid
|
11
|
-
attr_reader :eci_flag
|
12
|
-
attr_reader :three_d_secure_version
|
13
|
-
attr_reader :ds_transaction_id
|
14
14
|
attr_reader :three_d_secure_authentication_id
|
15
|
+
attr_reader :three_d_secure_transaction_id
|
16
|
+
attr_reader :three_d_secure_version
|
17
|
+
attr_reader :xid
|
18
|
+
attr_reader :lookup
|
19
|
+
attr_reader :authentication
|
15
20
|
|
16
21
|
alias_method :liability_shifted?, :liability_shifted
|
17
22
|
alias_method :liability_shift_possible?, :liability_shift_possible
|
@@ -22,16 +27,21 @@ module Braintree
|
|
22
27
|
|
23
28
|
def inspect
|
24
29
|
attr_order = [
|
30
|
+
:acs_transaction_id,
|
31
|
+
:authentication,
|
32
|
+
:cavv,
|
33
|
+
:ds_transaction_id,
|
34
|
+
:eci_flag,
|
25
35
|
:enrolled,
|
26
|
-
:liability_shifted,
|
27
36
|
:liability_shift_possible,
|
37
|
+
:liability_shifted,
|
38
|
+
:lookup,
|
39
|
+
:pares_status,
|
28
40
|
:status,
|
29
|
-
:cavv,
|
30
|
-
:xid,
|
31
|
-
:eci_flag,
|
32
|
-
:three_d_secure_version,
|
33
|
-
:ds_transaction_id,
|
34
41
|
:three_d_secure_authentication_id,
|
42
|
+
:three_d_secure_transaction_id,
|
43
|
+
:three_d_secure_version,
|
44
|
+
:xid
|
35
45
|
]
|
36
46
|
|
37
47
|
formatted_attrs = attr_order.map do |attr|
|
data/lib/braintree/version.rb
CHANGED
@@ -137,7 +137,7 @@ describe Braintree::CreditCard do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
it "returns risk data on verification on credit_card create" do
|
140
|
-
|
140
|
+
with_fraud_protection_enterprise_merchant do
|
141
141
|
customer = Braintree::Customer.create!
|
142
142
|
credit_card = Braintree::CreditCard.create!(
|
143
143
|
:cardholder_name => "Original Holder",
|
@@ -148,10 +148,12 @@ describe Braintree::CreditCard do
|
|
148
148
|
:options => {:verify_card => true}
|
149
149
|
)
|
150
150
|
verification = credit_card.verification
|
151
|
-
verification.risk_data.
|
152
|
-
verification.risk_data.
|
153
|
-
verification.risk_data.
|
154
|
-
verification.risk_data.
|
151
|
+
verification.risk_data.id.should_not be_nil
|
152
|
+
verification.risk_data.decision.should_not be_nil
|
153
|
+
verification.risk_data.decision_reasons.should_not be_nil
|
154
|
+
verification.risk_data.device_data_captured.should_not be_nil
|
155
|
+
verification.risk_data.fraud_service_provider.should_not be_nil
|
156
|
+
expect(verification.risk_data).to respond_to(:transaction_risk_score)
|
155
157
|
end
|
156
158
|
end
|
157
159
|
|
@@ -305,7 +305,7 @@ describe Braintree::MerchantGateway do
|
|
305
305
|
it "succeeds" do
|
306
306
|
result = Braintree::Merchant.provision_raw_apple_pay
|
307
307
|
result.should be_success
|
308
|
-
result.supported_networks.should == ["visa", "mastercard", "amex", "discover", "maestro"]
|
308
|
+
result.supported_networks.should == ["visa", "mastercard", "amex", "discover", "maestro", "elo"]
|
309
309
|
end
|
310
310
|
|
311
311
|
it "is repeatable" do
|
@@ -313,7 +313,7 @@ describe Braintree::MerchantGateway do
|
|
313
313
|
result.should be_success
|
314
314
|
result = Braintree::Merchant.provision_raw_apple_pay
|
315
315
|
result.should be_success
|
316
|
-
result.supported_networks.should == ["visa", "mastercard", "amex", "discover", "maestro"]
|
316
|
+
result.supported_networks.should == ["visa", "mastercard", "amex", "discover", "maestro", "elo"]
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
@@ -123,8 +123,8 @@ describe Braintree::Transaction do
|
|
123
123
|
|
124
124
|
describe "self.create" do
|
125
125
|
describe "risk data" do
|
126
|
-
it "returns decision, device_data_captured and
|
127
|
-
|
126
|
+
it "returns decision, device_data_captured, id, transaction_risk_score, and decision_reasons" do
|
127
|
+
with_fraud_protection_enterprise_merchant do
|
128
128
|
result = Braintree::Transaction.create(
|
129
129
|
:type => "sale",
|
130
130
|
:amount => 1_00,
|
@@ -134,15 +134,17 @@ describe Braintree::Transaction do
|
|
134
134
|
}
|
135
135
|
)
|
136
136
|
result.transaction.risk_data.should be_a(Braintree::RiskData)
|
137
|
-
result.transaction.risk_data.
|
138
|
-
result.transaction.risk_data.
|
139
|
-
result.transaction.risk_data.
|
140
|
-
result.transaction.risk_data.
|
137
|
+
result.transaction.risk_data.id.should_not be_nil
|
138
|
+
result.transaction.risk_data.decision.should_not be_nil
|
139
|
+
result.transaction.risk_data.decision_reasons.should_not be_nil
|
140
|
+
result.transaction.risk_data.device_data_captured.should_not be_nil
|
141
|
+
result.transaction.risk_data.fraud_service_provider.should_not be_nil
|
142
|
+
expect(result.transaction.risk_data).to respond_to(:transaction_risk_score)
|
141
143
|
end
|
142
144
|
end
|
143
145
|
|
144
146
|
it "handles validation errors for invalid risk data attributes" do
|
145
|
-
|
147
|
+
with_advanced_fraud_kount_integration_merchant do
|
146
148
|
result = Braintree::Transaction.create(
|
147
149
|
:type => "sale",
|
148
150
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -930,7 +932,7 @@ describe Braintree::Transaction do
|
|
930
932
|
end
|
931
933
|
|
932
934
|
it "exposes the fraud gateway rejection reason" do
|
933
|
-
|
935
|
+
with_advanced_fraud_kount_integration_merchant do
|
934
936
|
result = Braintree::Transaction.sale(
|
935
937
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
936
938
|
:credit_card => {
|
@@ -945,7 +947,7 @@ describe Braintree::Transaction do
|
|
945
947
|
end
|
946
948
|
|
947
949
|
it "exposes the risk_threshold gateway rejection reason (via test cc num)" do
|
948
|
-
|
950
|
+
with_advanced_fraud_kount_integration_merchant do
|
949
951
|
result = Braintree::Transaction.sale(
|
950
952
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
951
953
|
:credit_card => {
|
@@ -960,7 +962,7 @@ describe Braintree::Transaction do
|
|
960
962
|
end
|
961
963
|
|
962
964
|
it "exposes the risk_threshold gateway rejection reason (via test test nonce)" do
|
963
|
-
|
965
|
+
with_advanced_fraud_kount_integration_merchant do
|
964
966
|
result = Braintree::Transaction.sale(
|
965
967
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
966
968
|
:payment_method_nonce => Braintree::Test::Nonce::GatewayRejectedRiskThresholds,
|
@@ -5044,7 +5046,7 @@ describe Braintree::Transaction do
|
|
5044
5046
|
end
|
5045
5047
|
|
5046
5048
|
it "skips advanced fraud checking if transaction[options][skip_advanced_fraud_checking] is set to true" do
|
5047
|
-
|
5049
|
+
with_advanced_fraud_kount_integration_merchant do
|
5048
5050
|
result = Braintree::Transaction.sale(
|
5049
5051
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
5050
5052
|
:credit_card => {
|
@@ -6238,15 +6240,21 @@ describe Braintree::Transaction do
|
|
6238
6240
|
it "returns all the three_d_secure_info" do
|
6239
6241
|
transaction = Braintree::Transaction.find("threedsecuredtransaction")
|
6240
6242
|
|
6243
|
+
expect(transaction.three_d_secure_info.authentication).to have_key(:trans_status)
|
6244
|
+
expect(transaction.three_d_secure_info.authentication).to have_key(:trans_status_reason)
|
6245
|
+
expect(transaction.three_d_secure_info.lookup).to have_key(:trans_status)
|
6246
|
+
expect(transaction.three_d_secure_info.lookup).to have_key(:trans_status_reason)
|
6247
|
+
transaction.three_d_secure_info.cavv.should == "somebase64value"
|
6248
|
+
transaction.three_d_secure_info.ds_transaction_id.should == "dstxnid"
|
6249
|
+
transaction.three_d_secure_info.eci_flag.should == "07"
|
6241
6250
|
transaction.three_d_secure_info.enrolled.should == "Y"
|
6242
|
-
transaction.three_d_secure_info.should
|
6251
|
+
transaction.three_d_secure_info.pares_status.should == "Y"
|
6243
6252
|
transaction.three_d_secure_info.should be_liability_shift_possible
|
6253
|
+
transaction.three_d_secure_info.should be_liability_shifted
|
6244
6254
|
transaction.three_d_secure_info.status.should == "authenticate_successful"
|
6245
|
-
transaction.three_d_secure_info.
|
6246
|
-
transaction.three_d_secure_info.xid.should == "xidvalue"
|
6247
|
-
transaction.three_d_secure_info.eci_flag.should == "07"
|
6255
|
+
expect(transaction.three_d_secure_info.three_d_secure_authentication_id).to be
|
6248
6256
|
transaction.three_d_secure_info.three_d_secure_version.should == "1.0.2"
|
6249
|
-
transaction.three_d_secure_info.
|
6257
|
+
transaction.three_d_secure_info.xid.should == "xidvalue"
|
6250
6258
|
end
|
6251
6259
|
|
6252
6260
|
it "is nil if the transaction wasn't 3d secured" do
|
@@ -42,12 +42,18 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def with_advanced_fraud_kount_integration_merchant(&block)
|
46
46
|
with_other_merchant("advanced_fraud_integration_merchant_id", "advanced_fraud_integration_public_key", "advanced_fraud_integration_private_key") do
|
47
47
|
block.call
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def with_fraud_protection_enterprise_merchant(&block)
|
52
|
+
with_other_merchant("fraud_protection_enterprise_integration_merchant_id", "fraud_protection_enterprise_integration_public_key", "fraud_protection_enterprise_integration_private_key") do
|
53
|
+
block.call
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
51
57
|
def with_altpay_merchant(&block)
|
52
58
|
with_other_merchant("altpay_merchant", "altpay_merchant_public_key", "altpay_merchant_private_key", &block)
|
53
59
|
end
|
@@ -117,14 +117,18 @@ describe Braintree::CreditCardVerification do
|
|
117
117
|
verification = Braintree::CreditCardVerification._new(:risk_data => {
|
118
118
|
:id => "123",
|
119
119
|
:decision => "WOO YOU WON $1000 dollars",
|
120
|
+
:decision_reasons => ["reason"],
|
120
121
|
:device_data_captured => true,
|
121
|
-
:fraud_service_provider => "
|
122
|
+
:fraud_service_provider => "paypal_fraud_protection",
|
123
|
+
:transaction_risk_score => "12",
|
122
124
|
})
|
123
125
|
|
124
126
|
verification.risk_data.id.should == "123"
|
125
127
|
verification.risk_data.decision.should == "WOO YOU WON $1000 dollars"
|
128
|
+
verification.risk_data.decision_reasons.should == ["reason"]
|
126
129
|
verification.risk_data.device_data_captured.should == true
|
127
|
-
verification.risk_data.fraud_service_provider.should == "
|
130
|
+
verification.risk_data.fraud_service_provider.should == "paypal_fraud_protection"
|
131
|
+
verification.risk_data.transaction_risk_score.should == "12"
|
128
132
|
end
|
129
133
|
|
130
134
|
it "handles a nil risk_data" do
|
@@ -2,12 +2,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
3
3
|
describe Braintree::RiskData do
|
4
4
|
describe "#initialize" do
|
5
|
-
it "sets id, decision and
|
6
|
-
risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "
|
5
|
+
it "sets id, decision, device_data_captured, decision_reasons and transaction_risk_score" do
|
6
|
+
risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "fraud_protection", :decision_reasons => ["reason"], :transaction_risk_score => "12")
|
7
7
|
risk_data.id.should == "123"
|
8
8
|
risk_data.decision.should == "YOU WON $1000 DOLLARS"
|
9
9
|
risk_data.device_data_captured.should be_truthy
|
10
|
-
risk_data.fraud_service_provider.should == "
|
10
|
+
risk_data.fraud_service_provider.should == "fraud_protection"
|
11
|
+
risk_data.decision_reasons.should == ["reason"]
|
12
|
+
risk_data.transaction_risk_score.should == "12"
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -16,10 +18,12 @@ describe Braintree::RiskData do
|
|
16
18
|
details = Braintree::RiskData.new(
|
17
19
|
:id => "123",
|
18
20
|
:decision => "YOU WON $1000 DOLLARS",
|
21
|
+
:decision_reasons => ["reason"],
|
19
22
|
:device_data_captured => true,
|
20
|
-
:fraud_service_provider => "
|
23
|
+
:fraud_service_provider => "fraud_protection",
|
24
|
+
:transaction_risk_score => "12",
|
21
25
|
)
|
22
|
-
details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", device_data_captured: true, fraud_service_provider: "
|
26
|
+
details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", transaction_risk_score: "12">)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -3,37 +3,55 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
3
3
|
describe Braintree::ThreeDSecureInfo do
|
4
4
|
let(:three_d_secure_info) {
|
5
5
|
Braintree::ThreeDSecureInfo.new(
|
6
|
+
:acs_transaction_id => "acs_id",
|
7
|
+
:cavv => "cavvvalue",
|
8
|
+
:ds_transaction_id => "dstrxid",
|
9
|
+
:eci_flag => "06",
|
6
10
|
:enrolled => "Y",
|
7
|
-
:liability_shifted => true,
|
8
11
|
:liability_shift_possible => true,
|
9
|
-
:
|
10
|
-
:
|
12
|
+
:liability_shifted => true,
|
13
|
+
:pares_status => "Y",
|
11
14
|
:status => "authenticate_successful",
|
12
|
-
:eci_flag => "06",
|
13
|
-
:three_d_secure_version => "1.0.2",
|
14
|
-
:ds_transaction_id => "dstrxid",
|
15
15
|
:three_d_secure_authentication_id => "auth_id",
|
16
|
+
:three_d_secure_transaction_id => "trans_id",
|
17
|
+
:three_d_secure_version => "1.0.2",
|
18
|
+
:xid => "xidvalue",
|
19
|
+
:authentication => {
|
20
|
+
:trans_status => "authstatus",
|
21
|
+
:trans_status_reason => "authstatusreason"
|
22
|
+
},
|
23
|
+
:lookup => {
|
24
|
+
:trans_status => "lookupstatus",
|
25
|
+
:trans_status_reason => "lookupstatusreason"
|
26
|
+
}
|
16
27
|
)
|
17
28
|
}
|
18
29
|
|
19
30
|
describe "#initialize" do
|
20
31
|
it "sets attributes" do
|
21
|
-
three_d_secure_info.
|
22
|
-
three_d_secure_info.status.should == "authenticate_successful"
|
23
|
-
three_d_secure_info.liability_shifted.should == true
|
24
|
-
three_d_secure_info.liability_shift_possible.should == true
|
32
|
+
three_d_secure_info.acs_transaction_id.should == "acs_id"
|
25
33
|
three_d_secure_info.cavv.should == "cavvvalue"
|
26
|
-
three_d_secure_info.xid.should == "xidvalue"
|
27
|
-
three_d_secure_info.eci_flag.should == "06"
|
28
|
-
three_d_secure_info.three_d_secure_version.should == "1.0.2"
|
29
34
|
three_d_secure_info.ds_transaction_id.should == "dstrxid"
|
35
|
+
three_d_secure_info.eci_flag.should == "06"
|
36
|
+
three_d_secure_info.enrolled.should == "Y"
|
37
|
+
three_d_secure_info.liability_shift_possible.should == true
|
38
|
+
three_d_secure_info.liability_shifted.should == true
|
39
|
+
three_d_secure_info.pares_status.should == "Y"
|
40
|
+
three_d_secure_info.status.should == "authenticate_successful"
|
30
41
|
three_d_secure_info.three_d_secure_authentication_id.should == "auth_id"
|
42
|
+
three_d_secure_info.three_d_secure_transaction_id.should == "trans_id"
|
43
|
+
three_d_secure_info.three_d_secure_version.should == "1.0.2"
|
44
|
+
three_d_secure_info.xid.should == "xidvalue"
|
45
|
+
three_d_secure_info.lookup[:trans_status].should == "lookupstatus"
|
46
|
+
three_d_secure_info.lookup[:trans_status_reason].should == "lookupstatusreason"
|
47
|
+
three_d_secure_info.authentication[:trans_status].should == "authstatus"
|
48
|
+
three_d_secure_info.authentication[:trans_status_reason].should == "authstatusreason"
|
31
49
|
end
|
32
50
|
end
|
33
51
|
|
34
52
|
describe "inspect" do
|
35
53
|
it "prints the attributes" do
|
36
|
-
three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo enrolled: "Y",
|
54
|
+
three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo acs_transaction_id: "acs_id", authentication: {:trans_status=>"authstatus", :trans_status_reason=>"authstatusreason"}, cavv: "cavvvalue", ds_transaction_id: "dstrxid", eci_flag: "06", enrolled: "Y", liability_shift_possible: true, liability_shifted: true, lookup: {:trans_status=>"lookupstatus", :trans_status_reason=>"lookupstatusreason"}, pares_status: "Y", status: "authenticate_successful", three_d_secure_authentication_id: "auth_id", three_d_secure_transaction_id: "trans_id", three_d_secure_version: "1.0.2", xid: "xidvalue">)
|
37
55
|
end
|
38
56
|
end
|
39
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|