braintree 3.2.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/braintree.gemspec +3 -3
- data/lib/braintree.rb +6 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -1
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -2
- data/lib/braintree/credit_card_gateway.rb +14 -4
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +6 -4
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +15 -1
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +3 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +10 -6
- data/lib/braintree/google_pay_card.rb +1 -1
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +1 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -10
- data/lib/braintree/payment_method_gateway.rb +10 -7
- data/lib/braintree/payment_method_nonce.rb +7 -4
- data/lib/braintree/payment_method_nonce_details.rb +37 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +6 -6
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +32 -24
- data/lib/braintree/transaction_gateway.rb +24 -5
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +30 -20
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +30 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +0 -1
- data/lib/braintree/xml/parser.rb +22 -12
- data/lib/braintree/xml/rexml.rb +70 -0
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +28 -24
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
- data/spec/integration/braintree/credit_card_spec.rb +213 -122
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +282 -165
- data/spec/integration/braintree/dispute_search_spec.rb +28 -3
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +28 -35
- data/spec/integration/braintree/payment_method_spec.rb +269 -165
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +133 -133
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +93 -67
- data/spec/integration/braintree/transaction_spec.rb +574 -360
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +9 -3
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +13 -13
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +20 -10
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +1 -0
- data/spec/unit/braintree/dispute_spec.rb +34 -9
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +9 -9
- data/spec/unit/braintree/risk_data_spec.rb +9 -5
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +16 -8
- data/lib/braintree/settlement_batch.rb +0 -0
@@ -5,18 +5,18 @@ describe Braintree::ApplePayGateway do
|
|
5
5
|
gateway = Braintree::Gateway.new(
|
6
6
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
7
7
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
8
|
-
:logger => Logger.new("/dev/null")
|
8
|
+
:logger => Logger.new("/dev/null"),
|
9
9
|
)
|
10
10
|
|
11
11
|
result = gateway.merchant.create(
|
12
12
|
:email => "name@email.com",
|
13
13
|
:country_code_alpha3 => "USA",
|
14
|
-
:payment_methods => ["credit_card", "paypal"]
|
14
|
+
:payment_methods => ["credit_card", "paypal"],
|
15
15
|
)
|
16
16
|
|
17
17
|
@gateway = Braintree::Gateway.new(
|
18
18
|
:access_token => result.credentials.access_token,
|
19
|
-
:logger => Logger.new("/dev/null")
|
19
|
+
:logger => Logger.new("/dev/null"),
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
@@ -12,7 +12,8 @@ describe Braintree::Gateway do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "query" do
|
15
|
-
|
15
|
+
# we are temporarily skipping this test until we have a more stable CI env
|
16
|
+
xit "makes valid GraphQL queries when given a definition" do
|
16
17
|
definition = <<-GRAPHQL
|
17
18
|
mutation ExampleServerSideSingleUseToken($input: TokenizeCreditCardInput!) {
|
18
19
|
tokenizeCreditCard(input: $input) {
|
@@ -12,7 +12,7 @@ describe Braintree::ClientToken do
|
|
12
12
|
config,
|
13
13
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
14
14
|
:shared_customer_identifier => "fake_identifier",
|
15
|
-
:shared_customer_identifier_type => "testing"
|
15
|
+
:shared_customer_identifier_type => "testing",
|
16
16
|
)
|
17
17
|
|
18
18
|
response = http.get_payment_methods
|
@@ -49,7 +49,7 @@ describe Braintree::ClientToken do
|
|
49
49
|
:customer_id => result.customer.id,
|
50
50
|
:options => {
|
51
51
|
:verify_card => true
|
52
|
-
}
|
52
|
+
},
|
53
53
|
)
|
54
54
|
client_token = decode_client_token(raw_client_token)
|
55
55
|
|
@@ -57,7 +57,7 @@ describe Braintree::ClientToken do
|
|
57
57
|
config,
|
58
58
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
59
59
|
:shared_customer_identifier => "fake_identifier",
|
60
|
-
:shared_customer_identifier_type => "testing"
|
60
|
+
:shared_customer_identifier_type => "testing",
|
61
61
|
)
|
62
62
|
|
63
63
|
response = http.add_payment_method(
|
@@ -65,7 +65,7 @@ describe Braintree::ClientToken do
|
|
65
65
|
:number => "4000111111111115",
|
66
66
|
:expiration_month => "11",
|
67
67
|
:expiration_year => "2099"
|
68
|
-
}
|
68
|
+
},
|
69
69
|
)
|
70
70
|
|
71
71
|
response.code.should == "422"
|
@@ -79,7 +79,7 @@ describe Braintree::ClientToken do
|
|
79
79
|
:customer_id => customer_id,
|
80
80
|
:options => {
|
81
81
|
:make_default => true
|
82
|
-
}
|
82
|
+
},
|
83
83
|
)
|
84
84
|
client_token = decode_client_token(raw_client_token)
|
85
85
|
|
@@ -87,7 +87,7 @@ describe Braintree::ClientToken do
|
|
87
87
|
config,
|
88
88
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
89
89
|
:shared_customer_identifier => "fake_identifier",
|
90
|
-
:shared_customer_identifier_type => "testing"
|
90
|
+
:shared_customer_identifier_type => "testing",
|
91
91
|
)
|
92
92
|
|
93
93
|
response = http.add_payment_method(
|
@@ -95,7 +95,7 @@ describe Braintree::ClientToken do
|
|
95
95
|
:number => "4111111111111111",
|
96
96
|
:expiration_month => "11",
|
97
97
|
:expiration_year => "2099"
|
98
|
-
}
|
98
|
+
},
|
99
99
|
)
|
100
100
|
|
101
101
|
response.code.should == "201"
|
@@ -105,7 +105,7 @@ describe Braintree::ClientToken do
|
|
105
105
|
:number => "4005519200000004",
|
106
106
|
:expiration_month => "11",
|
107
107
|
:expiration_year => "2099"
|
108
|
-
}
|
108
|
+
},
|
109
109
|
)
|
110
110
|
|
111
111
|
response.code.should == "201"
|
@@ -119,7 +119,7 @@ describe Braintree::ClientToken do
|
|
119
119
|
result = Braintree::Customer.create
|
120
120
|
customer_id = result.customer.id
|
121
121
|
raw_client_token = Braintree::ClientToken.generate(
|
122
|
-
:customer_id => customer_id
|
122
|
+
:customer_id => customer_id,
|
123
123
|
)
|
124
124
|
client_token = decode_client_token(raw_client_token)
|
125
125
|
|
@@ -127,7 +127,7 @@ describe Braintree::ClientToken do
|
|
127
127
|
config,
|
128
128
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
129
129
|
:shared_customer_identifier => "fake_identifier",
|
130
|
-
:shared_customer_identifier_type => "testing"
|
130
|
+
:shared_customer_identifier_type => "testing",
|
131
131
|
)
|
132
132
|
|
133
133
|
response = http.add_payment_method(
|
@@ -135,7 +135,7 @@ describe Braintree::ClientToken do
|
|
135
135
|
:number => "4111111111111111",
|
136
136
|
:expiration_month => "11",
|
137
137
|
:expiration_year => "2099"
|
138
|
-
}
|
138
|
+
},
|
139
139
|
)
|
140
140
|
|
141
141
|
response.code.should == "201"
|
@@ -144,7 +144,7 @@ describe Braintree::ClientToken do
|
|
144
144
|
:customer_id => customer_id,
|
145
145
|
:options => {
|
146
146
|
:fail_on_duplicate_payment_method => true
|
147
|
-
}
|
147
|
+
},
|
148
148
|
)
|
149
149
|
second_client_token = decode_client_token(second_raw_client_token)
|
150
150
|
|
@@ -155,7 +155,7 @@ describe Braintree::ClientToken do
|
|
155
155
|
:number => "4111111111111111",
|
156
156
|
:expiration_month => "11",
|
157
157
|
:expiration_year => "2099"
|
158
|
-
}
|
158
|
+
},
|
159
159
|
)
|
160
160
|
|
161
161
|
response.code.should == "422"
|
@@ -165,7 +165,7 @@ describe Braintree::ClientToken do
|
|
165
165
|
merchant_account_id = SpecHelper::NonDefaultMerchantAccountId
|
166
166
|
|
167
167
|
raw_client_token = Braintree::ClientToken.generate(
|
168
|
-
:merchant_account_id => merchant_account_id
|
168
|
+
:merchant_account_id => merchant_account_id,
|
169
169
|
)
|
170
170
|
client_token = decode_client_token(raw_client_token)
|
171
171
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "json"
|
2
2
|
|
3
3
|
def decode_client_token(raw_client_token)
|
4
4
|
decoded_client_token_string = Base64.decode64(raw_client_token)
|
@@ -20,7 +20,7 @@ def _initialize_client(options)
|
|
20
20
|
ClientApiHttp.new(Braintree::Configuration.instantiate,
|
21
21
|
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
22
22
|
:shared_customer_identifier => "fake_identifier",
|
23
|
-
:shared_customer_identifier_type => "testing"
|
23
|
+
:shared_customer_identifier_type => "testing",
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
@@ -42,7 +42,7 @@ def nonce_for_paypal_account(paypal_account_details)
|
|
42
42
|
raw_client_token = Braintree::ClientToken.generate
|
43
43
|
client_token = decode_client_token(raw_client_token)
|
44
44
|
client = ClientApiHttp.new(Braintree::Configuration.instantiate,
|
45
|
-
:authorization_fingerprint => client_token["authorizationFingerprint"]
|
45
|
+
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
46
46
|
)
|
47
47
|
|
48
48
|
response = client.create_paypal_account(paypal_account_details)
|
@@ -283,7 +283,7 @@ class ClientApiHttp
|
|
283
283
|
params.merge!(
|
284
284
|
:authorization_fingerprint => @options[:authorization_fingerprint],
|
285
285
|
:shared_customer_identifier => "fake_identifier",
|
286
|
-
:shared_customer_identifier_type => "testing"
|
286
|
+
:shared_customer_identifier_type => "testing",
|
287
287
|
)
|
288
288
|
|
289
289
|
post("/merchants/#{config.merchant_id}/client_api/v1/payment_methods/credit_cards", params)
|
@@ -292,7 +292,7 @@ class ClientApiHttp
|
|
292
292
|
def create_paypal_account(params)
|
293
293
|
params = {:paypal_account => params}
|
294
294
|
params.merge!(
|
295
|
-
:authorization_fingerprint => @options[:authorization_fingerprint]
|
295
|
+
:authorization_fingerprint => @options[:authorization_fingerprint],
|
296
296
|
)
|
297
297
|
|
298
298
|
post("/merchants/#{config.merchant_id}/client_api/v1/payment_methods/paypal_accounts", params)
|
@@ -46,7 +46,7 @@ describe Braintree::CreditCard do
|
|
46
46
|
:customer_id => customer.id,
|
47
47
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
48
48
|
:expiration_month => "05",
|
49
|
-
:expiration_year => "2012"
|
49
|
+
:expiration_year => "2012",
|
50
50
|
)
|
51
51
|
result.success?.should == true
|
52
52
|
credit_card = result.credit_card
|
@@ -63,7 +63,7 @@ describe Braintree::CreditCard do
|
|
63
63
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
64
64
|
:expiration_date => "05/2009",
|
65
65
|
:cvv => "100",
|
66
|
-
:token => token
|
66
|
+
:token => token,
|
67
67
|
)
|
68
68
|
result.success?.should == true
|
69
69
|
credit_card = result.credit_card
|
@@ -81,7 +81,7 @@ describe Braintree::CreditCard do
|
|
81
81
|
:customer_id => customer.id,
|
82
82
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
83
83
|
:expiration_date => "05/2009",
|
84
|
-
:billing_address_id => address.id
|
84
|
+
:billing_address_id => address.id,
|
85
85
|
).credit_card
|
86
86
|
|
87
87
|
credit_card.billing_address.id.should == address.id
|
@@ -95,7 +95,7 @@ describe Braintree::CreditCard do
|
|
95
95
|
:customer_id => customer.id,
|
96
96
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
97
97
|
:expiration_date => "05/2009",
|
98
|
-
:options => {}
|
98
|
+
:options => {},
|
99
99
|
)
|
100
100
|
result.success?.should == true
|
101
101
|
end
|
@@ -106,7 +106,7 @@ describe Braintree::CreditCard do
|
|
106
106
|
:customer_id => customer.id,
|
107
107
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
108
108
|
:expiration_date => "05/2009",
|
109
|
-
:options => {:verify_card => true}
|
109
|
+
:options => {:verify_card => true},
|
110
110
|
)
|
111
111
|
result.success?.should == false
|
112
112
|
result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
@@ -124,7 +124,7 @@ describe Braintree::CreditCard do
|
|
124
124
|
:customer_id => customer.id,
|
125
125
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
126
126
|
:expiration_date => "05/2009",
|
127
|
-
:options => {:verify_card => true, :verification_amount => "100.00"}
|
127
|
+
:options => {:verify_card => true, :verification_amount => "100.00"},
|
128
128
|
)
|
129
129
|
result.success?.should == false
|
130
130
|
result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
@@ -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",
|
@@ -145,13 +145,57 @@ describe Braintree::CreditCard do
|
|
145
145
|
:cvv => "123",
|
146
146
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
147
147
|
:expiration_date => "05/2020",
|
148
|
-
:options => {:verify_card => true}
|
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
|
+
expect(verification.risk_data).to respond_to(:device_data_captured)
|
155
|
+
expect(verification.risk_data).to respond_to(:fraud_service_provider)
|
156
|
+
expect(verification.risk_data).to respond_to(:transaction_risk_score)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
161
|
+
with_fraud_protection_enterprise_merchant do
|
162
|
+
customer = Braintree::Customer.create!
|
163
|
+
result = Braintree::CreditCard.create(
|
164
|
+
:cardholder_name => "Original Holder",
|
165
|
+
:customer_id => customer.id,
|
166
|
+
:cvv => "123",
|
167
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
168
|
+
:expiration_date => "05/2020",
|
169
|
+
:options => {
|
170
|
+
:skip_advanced_fraud_checking => false,
|
171
|
+
:verify_card => true,
|
172
|
+
},
|
173
|
+
)
|
174
|
+
|
175
|
+
expect(result).to be_success
|
176
|
+
verification = result.credit_card.verification
|
177
|
+
expect(verification.risk_data).not_to be_nil
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
182
|
+
with_fraud_protection_enterprise_merchant do
|
183
|
+
customer = Braintree::Customer.create!
|
184
|
+
result = Braintree::CreditCard.create(
|
185
|
+
:cardholder_name => "Original Holder",
|
186
|
+
:customer_id => customer.id,
|
187
|
+
:cvv => "123",
|
188
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
189
|
+
:expiration_date => "05/2020",
|
190
|
+
:options => {
|
191
|
+
:skip_advanced_fraud_checking => true,
|
192
|
+
:verify_card => true,
|
193
|
+
},
|
194
|
+
)
|
195
|
+
|
196
|
+
expect(result).to be_success
|
197
|
+
verification = result.credit_card.verification
|
198
|
+
expect(verification.risk_data).to be_nil
|
155
199
|
end
|
156
200
|
end
|
157
201
|
|
@@ -171,7 +215,7 @@ describe Braintree::CreditCard do
|
|
171
215
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
172
216
|
:expiration_date => "05/2009",
|
173
217
|
:cvv => "200",
|
174
|
-
:options => {:verify_card => true}
|
218
|
+
:options => {:verify_card => true},
|
175
219
|
)
|
176
220
|
result.success?.should == false
|
177
221
|
result.credit_card_verification.gateway_rejection_reason.should == Braintree::CreditCardVerification::GatewayRejectionReason::CVV
|
@@ -188,7 +232,7 @@ describe Braintree::CreditCard do
|
|
188
232
|
:customer_id => customer.id,
|
189
233
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
190
234
|
:expiration_date => "05/2009",
|
191
|
-
:options => {:verify_card => true, :verification_amount => "1.01"}
|
235
|
+
:options => {:verify_card => true, :verification_amount => "1.01"},
|
192
236
|
)
|
193
237
|
result.success?.should == false
|
194
238
|
result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
@@ -209,7 +253,7 @@ describe Braintree::CreditCard do
|
|
209
253
|
:options => {
|
210
254
|
:verify_card => true,
|
211
255
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
212
|
-
}
|
256
|
+
},
|
213
257
|
)
|
214
258
|
result.success?.should == false
|
215
259
|
result.credit_card_verification.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
|
@@ -221,7 +265,7 @@ describe Braintree::CreditCard do
|
|
221
265
|
:customer_id => customer.id,
|
222
266
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
|
223
267
|
:expiration_date => "05/2009",
|
224
|
-
:options => {:verify_card => false}
|
268
|
+
:options => {:verify_card => false},
|
225
269
|
)
|
226
270
|
result.success?.should == true
|
227
271
|
end
|
@@ -232,15 +276,15 @@ describe Braintree::CreditCard do
|
|
232
276
|
:customer_id => customer.id,
|
233
277
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
234
278
|
:three_d_secure_pass_thru => {
|
235
|
-
:eci_flag =>
|
236
|
-
:cavv =>
|
237
|
-
:xid =>
|
238
|
-
:authentication_response =>
|
239
|
-
:directory_response =>
|
240
|
-
:cavv_algorithm =>
|
241
|
-
:ds_transaction_id =>
|
279
|
+
:eci_flag => "02",
|
280
|
+
:cavv => "some_cavv",
|
281
|
+
:xid => "some_xid",
|
282
|
+
:authentication_response => "Y",
|
283
|
+
:directory_response => "Y",
|
284
|
+
:cavv_algorithm => "2",
|
285
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
242
286
|
},
|
243
|
-
:options => {:verify_card => true}
|
287
|
+
:options => {:verify_card => true},
|
244
288
|
)
|
245
289
|
expect(result).not_to be_success
|
246
290
|
error = result.errors.for(:verification).first
|
@@ -254,16 +298,16 @@ describe Braintree::CreditCard do
|
|
254
298
|
:customer_id => customer.id,
|
255
299
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
256
300
|
:three_d_secure_pass_thru => {
|
257
|
-
:eci_flag =>
|
258
|
-
:cavv =>
|
259
|
-
:xid =>
|
260
|
-
:three_d_secure_version =>
|
261
|
-
:authentication_response =>
|
262
|
-
:directory_response =>
|
263
|
-
:cavv_algorithm =>
|
264
|
-
:ds_transaction_id =>
|
301
|
+
:eci_flag => "02",
|
302
|
+
:cavv => "some_cavv",
|
303
|
+
:xid => "some_xid",
|
304
|
+
:three_d_secure_version => "1.0.2",
|
305
|
+
:authentication_response => "Y",
|
306
|
+
:directory_response => "Y",
|
307
|
+
:cavv_algorithm => "2",
|
308
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
265
309
|
},
|
266
|
-
:options => {:verify_card => true}
|
310
|
+
:options => {:verify_card => true},
|
267
311
|
)
|
268
312
|
result.success?.should == true
|
269
313
|
|
@@ -274,7 +318,7 @@ describe Braintree::CreditCard do
|
|
274
318
|
result = Braintree::CreditCard.create(
|
275
319
|
:customer_id => customer.id,
|
276
320
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
277
|
-
:options => {:verify_card => true}
|
321
|
+
:options => {:verify_card => true},
|
278
322
|
)
|
279
323
|
result.success?.should == true
|
280
324
|
|
@@ -302,7 +346,7 @@ describe Braintree::CreditCard do
|
|
302
346
|
:locality => "Chicago",
|
303
347
|
:region => "Illinois",
|
304
348
|
:postal_code => "60622"
|
305
|
-
}
|
349
|
+
},
|
306
350
|
)
|
307
351
|
result.success?.should == true
|
308
352
|
credit_card = result.credit_card
|
@@ -321,7 +365,7 @@ describe Braintree::CreditCard do
|
|
321
365
|
:country_code_alpha2 => "US",
|
322
366
|
:country_code_alpha3 => "USA",
|
323
367
|
:country_code_numeric => "840"
|
324
|
-
}
|
368
|
+
},
|
325
369
|
)
|
326
370
|
result.success?.should == true
|
327
371
|
credit_card = result.credit_card
|
@@ -340,7 +384,7 @@ describe Braintree::CreditCard do
|
|
340
384
|
:billing_address => {
|
341
385
|
:country_name => "Mexico",
|
342
386
|
:country_code_alpha2 => "US"
|
343
|
-
}
|
387
|
+
},
|
344
388
|
)
|
345
389
|
result.success?.should == false
|
346
390
|
result.errors.for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
@@ -351,7 +395,7 @@ describe Braintree::CreditCard do
|
|
351
395
|
result = Braintree::CreditCard.create(
|
352
396
|
:customer_id => customer.id,
|
353
397
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
354
|
-
:expiration_date => "invalid_date"
|
398
|
+
:expiration_date => "invalid_date",
|
355
399
|
)
|
356
400
|
result.success?.should == false
|
357
401
|
result.errors.for(:credit_card).on(:expiration_date)[0].message.should == "Expiration date is invalid."
|
@@ -362,7 +406,7 @@ describe Braintree::CreditCard do
|
|
362
406
|
card1 = Braintree::CreditCard.create(
|
363
407
|
:customer_id => customer.id,
|
364
408
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
365
|
-
:expiration_date => "05/2009"
|
409
|
+
:expiration_date => "05/2009",
|
366
410
|
).credit_card
|
367
411
|
card1.should be_default
|
368
412
|
|
@@ -372,7 +416,7 @@ describe Braintree::CreditCard do
|
|
372
416
|
:expiration_date => "05/2009",
|
373
417
|
:options => {
|
374
418
|
:make_default => true
|
375
|
-
}
|
419
|
+
},
|
376
420
|
).credit_card
|
377
421
|
card2.should be_default
|
378
422
|
|
@@ -401,7 +445,7 @@ describe Braintree::CreditCard do
|
|
401
445
|
:customer_id => customer.id,
|
402
446
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
403
447
|
:expiration_date => "05/2014",
|
404
|
-
:options => {:verify_card => true}
|
448
|
+
:options => {:verify_card => true},
|
405
449
|
)
|
406
450
|
credit_card = result.credit_card
|
407
451
|
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
@@ -413,7 +457,7 @@ describe Braintree::CreditCard do
|
|
413
457
|
:customer_id => customer.id,
|
414
458
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Healthcare,
|
415
459
|
:expiration_date => "05/2014",
|
416
|
-
:options => {:verify_card => true}
|
460
|
+
:options => {:verify_card => true},
|
417
461
|
)
|
418
462
|
credit_card = result.credit_card
|
419
463
|
credit_card.healthcare.should == Braintree::CreditCard::Healthcare::Yes
|
@@ -426,7 +470,7 @@ describe Braintree::CreditCard do
|
|
426
470
|
:customer_id => customer.id,
|
427
471
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::DurbinRegulated,
|
428
472
|
:expiration_date => "05/2014",
|
429
|
-
:options => {:verify_card => true}
|
473
|
+
:options => {:verify_card => true},
|
430
474
|
)
|
431
475
|
credit_card = result.credit_card
|
432
476
|
credit_card.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
|
@@ -438,7 +482,7 @@ describe Braintree::CreditCard do
|
|
438
482
|
:customer_id => customer.id,
|
439
483
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::CountryOfIssuance,
|
440
484
|
:expiration_date => "05/2014",
|
441
|
-
:options => {:verify_card => true}
|
485
|
+
:options => {:verify_card => true},
|
442
486
|
)
|
443
487
|
credit_card = result.credit_card
|
444
488
|
credit_card.country_of_issuance.should == Braintree::Test::CreditCardDefaults::CountryOfIssuance
|
@@ -450,7 +494,7 @@ describe Braintree::CreditCard do
|
|
450
494
|
:customer_id => customer.id,
|
451
495
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::IssuingBank,
|
452
496
|
:expiration_date => "05/2014",
|
453
|
-
:options => {:verify_card => true}
|
497
|
+
:options => {:verify_card => true},
|
454
498
|
)
|
455
499
|
credit_card = result.credit_card
|
456
500
|
credit_card.issuing_bank.should == Braintree::Test::CreditCardDefaults::IssuingBank
|
@@ -462,7 +506,7 @@ describe Braintree::CreditCard do
|
|
462
506
|
:customer_id => customer.id,
|
463
507
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Payroll,
|
464
508
|
:expiration_date => "05/2014",
|
465
|
-
:options => {:verify_card => true}
|
509
|
+
:options => {:verify_card => true},
|
466
510
|
)
|
467
511
|
credit_card = result.credit_card
|
468
512
|
credit_card.payroll.should == Braintree::CreditCard::Payroll::Yes
|
@@ -475,7 +519,7 @@ describe Braintree::CreditCard do
|
|
475
519
|
:customer_id => customer.id,
|
476
520
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Debit,
|
477
521
|
:expiration_date => "05/2014",
|
478
|
-
:options => {:verify_card => true}
|
522
|
+
:options => {:verify_card => true},
|
479
523
|
)
|
480
524
|
credit_card = result.credit_card
|
481
525
|
credit_card.debit.should == Braintree::CreditCard::Debit::Yes
|
@@ -487,7 +531,7 @@ describe Braintree::CreditCard do
|
|
487
531
|
:customer_id => customer.id,
|
488
532
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Commercial,
|
489
533
|
:expiration_date => "05/2014",
|
490
|
-
:options => {:verify_card => true}
|
534
|
+
:options => {:verify_card => true},
|
491
535
|
)
|
492
536
|
credit_card = result.credit_card
|
493
537
|
credit_card.commercial.should == Braintree::CreditCard::Commercial::Yes
|
@@ -499,7 +543,7 @@ describe Braintree::CreditCard do
|
|
499
543
|
:customer_id => customer.id,
|
500
544
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::No,
|
501
545
|
:expiration_date => "05/2014",
|
502
|
-
:options => {:verify_card => true}
|
546
|
+
:options => {:verify_card => true},
|
503
547
|
)
|
504
548
|
credit_card = result.credit_card
|
505
549
|
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::No
|
@@ -517,7 +561,7 @@ describe Braintree::CreditCard do
|
|
517
561
|
:customer_id => customer.id,
|
518
562
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Unknown,
|
519
563
|
:expiration_date => "05/2014",
|
520
|
-
:options => {:verify_card => true}
|
564
|
+
:options => {:verify_card => true},
|
521
565
|
)
|
522
566
|
credit_card = result.credit_card
|
523
567
|
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Unknown
|
@@ -538,7 +582,7 @@ describe Braintree::CreditCard do
|
|
538
582
|
customer = Braintree::Customer.create!
|
539
583
|
result = Braintree::CreditCard.create(
|
540
584
|
:customer_id => customer.id,
|
541
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
585
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
|
542
586
|
)
|
543
587
|
result.success?.should == true
|
544
588
|
result.credit_card.venmo_sdk?.should == false
|
@@ -550,7 +594,7 @@ describe Braintree::CreditCard do
|
|
550
594
|
customer = Braintree::Customer.create!
|
551
595
|
result = Braintree::CreditCard.create(
|
552
596
|
:customer_id => customer.id,
|
553
|
-
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode
|
597
|
+
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
|
554
598
|
)
|
555
599
|
|
556
600
|
result.success?.should == false
|
@@ -569,7 +613,7 @@ describe Braintree::CreditCard do
|
|
569
613
|
:cvv => "100",
|
570
614
|
:options => {
|
571
615
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
572
|
-
}
|
616
|
+
},
|
573
617
|
)
|
574
618
|
result.success?.should == true
|
575
619
|
result.credit_card.venmo_sdk?.should == false
|
@@ -584,7 +628,7 @@ describe Braintree::CreditCard do
|
|
584
628
|
:cvv => "100",
|
585
629
|
:options => {
|
586
630
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
|
587
|
-
}
|
631
|
+
},
|
588
632
|
)
|
589
633
|
result.success?.should == true
|
590
634
|
result.credit_card.venmo_sdk?.should == false
|
@@ -600,12 +644,12 @@ describe Braintree::CreditCard do
|
|
600
644
|
:expiration_month => "11",
|
601
645
|
:expiration_year => "2099",
|
602
646
|
},
|
603
|
-
:share => true
|
647
|
+
:share => true,
|
604
648
|
)
|
605
649
|
customer = Braintree::Customer.create!
|
606
650
|
result = Braintree::CreditCard.create(
|
607
651
|
:customer_id => customer.id,
|
608
|
-
:payment_method_nonce => nonce
|
652
|
+
:payment_method_nonce => nonce,
|
609
653
|
)
|
610
654
|
|
611
655
|
result.success?.should == true
|
@@ -642,7 +686,7 @@ describe Braintree::CreditCard do
|
|
642
686
|
:verify_card => true,
|
643
687
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
644
688
|
:verification_account_type => "debit",
|
645
|
-
}
|
689
|
+
},
|
646
690
|
)
|
647
691
|
|
648
692
|
expect(result).to be_success
|
@@ -659,7 +703,7 @@ describe Braintree::CreditCard do
|
|
659
703
|
:verify_card => true,
|
660
704
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
661
705
|
:verification_account_type => "credit",
|
662
|
-
}
|
706
|
+
},
|
663
707
|
)
|
664
708
|
|
665
709
|
expect(result).to be_success
|
@@ -675,7 +719,7 @@ describe Braintree::CreditCard do
|
|
675
719
|
:verify_card => true,
|
676
720
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
677
721
|
:verification_account_type => "ach",
|
678
|
-
}
|
722
|
+
},
|
679
723
|
)
|
680
724
|
|
681
725
|
expect(result).to_not be_success
|
@@ -691,7 +735,7 @@ describe Braintree::CreditCard do
|
|
691
735
|
:options => {
|
692
736
|
:verify_card => true,
|
693
737
|
:verification_account_type => "credit",
|
694
|
-
}
|
738
|
+
},
|
695
739
|
)
|
696
740
|
|
697
741
|
expect(result).to_not be_success
|
@@ -707,7 +751,7 @@ describe Braintree::CreditCard do
|
|
707
751
|
:customer_id => customer.id,
|
708
752
|
:cardholder_name => "Adam Davis",
|
709
753
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
710
|
-
:expiration_date => "05/2009"
|
754
|
+
:expiration_date => "05/2009",
|
711
755
|
)
|
712
756
|
credit_card.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6]
|
713
757
|
credit_card.cardholder_name.should == "Adam Davis"
|
@@ -721,7 +765,7 @@ describe Braintree::CreditCard do
|
|
721
765
|
Braintree::CreditCard.create!(
|
722
766
|
:customer_id => customer.id,
|
723
767
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
724
|
-
:expiration_date => "invalid_date"
|
768
|
+
:expiration_date => "invalid_date",
|
725
769
|
)
|
726
770
|
end.to raise_error(Braintree::ValidationsFailed)
|
727
771
|
end
|
@@ -733,11 +777,11 @@ describe Braintree::CreditCard do
|
|
733
777
|
:credit_card => {
|
734
778
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
735
779
|
:expiration_date => "05/2010"
|
736
|
-
}
|
780
|
+
},
|
737
781
|
)
|
738
782
|
result = Braintree::CreditCard.credit(
|
739
783
|
customer.credit_cards[0].token,
|
740
|
-
:amount => "100.00"
|
784
|
+
:amount => "100.00",
|
741
785
|
)
|
742
786
|
result.success?.should == true
|
743
787
|
result.transaction.amount.should == BigDecimal("100.00")
|
@@ -756,11 +800,11 @@ describe Braintree::CreditCard do
|
|
756
800
|
:credit_card => {
|
757
801
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
758
802
|
:expiration_date => "05/2010"
|
759
|
-
}
|
803
|
+
},
|
760
804
|
)
|
761
805
|
transaction = Braintree::CreditCard.credit!(
|
762
806
|
customer.credit_cards[0].token,
|
763
|
-
:amount => "100.00"
|
807
|
+
:amount => "100.00",
|
764
808
|
)
|
765
809
|
transaction.amount.should == BigDecimal("100.00")
|
766
810
|
transaction.type.should == "credit"
|
@@ -780,13 +824,13 @@ describe Braintree::CreditCard do
|
|
780
824
|
:customer_id => customer.id,
|
781
825
|
:cvv => "123",
|
782
826
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
783
|
-
:expiration_date => "05/2012"
|
827
|
+
:expiration_date => "05/2012",
|
784
828
|
)
|
785
829
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
786
830
|
:cardholder_name => "New Holder",
|
787
831
|
:cvv => "456",
|
788
832
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
789
|
-
:expiration_date => "06/2013"
|
833
|
+
:expiration_date => "06/2013",
|
790
834
|
)
|
791
835
|
update_result.success?.should == true
|
792
836
|
update_result.credit_card.should == credit_card
|
@@ -804,20 +848,20 @@ describe Braintree::CreditCard do
|
|
804
848
|
:customer_id => customer.id,
|
805
849
|
:cvv => "123",
|
806
850
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
807
|
-
:expiration_date => "05/2012"
|
851
|
+
:expiration_date => "05/2012",
|
808
852
|
)
|
809
853
|
result = Braintree::CreditCard.update(credit_card.token,
|
810
854
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
811
855
|
:three_d_secure_pass_thru => {
|
812
|
-
:eci_flag =>
|
813
|
-
:cavv =>
|
814
|
-
:xid =>
|
815
|
-
:authentication_response =>
|
816
|
-
:directory_response =>
|
817
|
-
:cavv_algorithm =>
|
818
|
-
:ds_transaction_id =>
|
856
|
+
:eci_flag => "02",
|
857
|
+
:cavv => "some_cavv",
|
858
|
+
:xid => "some_xid",
|
859
|
+
:authentication_response => "Y",
|
860
|
+
:directory_response => "Y",
|
861
|
+
:cavv_algorithm => "2",
|
862
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
819
863
|
},
|
820
|
-
:options => {:verify_card => true}
|
864
|
+
:options => {:verify_card => true},
|
821
865
|
)
|
822
866
|
expect(result).not_to be_success
|
823
867
|
error = result.errors.for(:verification).first
|
@@ -832,25 +876,72 @@ describe Braintree::CreditCard do
|
|
832
876
|
:customer_id => customer.id,
|
833
877
|
:cvv => "123",
|
834
878
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
835
|
-
:expiration_date => "05/2012"
|
879
|
+
:expiration_date => "05/2012",
|
836
880
|
)
|
837
881
|
result = Braintree::CreditCard.update(credit_card.token,
|
838
882
|
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
839
883
|
:three_d_secure_pass_thru => {
|
840
|
-
:eci_flag =>
|
841
|
-
:cavv =>
|
884
|
+
:eci_flag => "02",
|
885
|
+
:cavv => "some_cavv",
|
842
886
|
:three_d_secure_version=> "2.1.0",
|
843
|
-
:xid =>
|
844
|
-
:authentication_response =>
|
845
|
-
:directory_response =>
|
846
|
-
:cavv_algorithm =>
|
847
|
-
:ds_transaction_id =>
|
887
|
+
:xid => "some_xid",
|
888
|
+
:authentication_response => "Y",
|
889
|
+
:directory_response => "Y",
|
890
|
+
:cavv_algorithm => "2",
|
891
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
848
892
|
},
|
849
|
-
:options => {:verify_card => true}
|
893
|
+
:options => {:verify_card => true},
|
850
894
|
)
|
851
895
|
|
852
896
|
result.success?.should == true
|
897
|
+
end
|
853
898
|
|
899
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
900
|
+
with_fraud_protection_enterprise_merchant do
|
901
|
+
customer = Braintree::Customer.create!
|
902
|
+
credit_card = Braintree::CreditCard.create!(
|
903
|
+
:cardholder_name => "Original Holder",
|
904
|
+
:customer_id => customer.id,
|
905
|
+
:cvv => "123",
|
906
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
907
|
+
:expiration_date => "05/2020",
|
908
|
+
)
|
909
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
910
|
+
:expiration_date => "05/2021",
|
911
|
+
:options => {
|
912
|
+
:verify_card => true,
|
913
|
+
:skip_advanced_fraud_checking => false,
|
914
|
+
},
|
915
|
+
)
|
916
|
+
|
917
|
+
expect(updated_result).to be_success
|
918
|
+
verification = updated_result.credit_card.verification
|
919
|
+
expect(verification.risk_data).not_to be_nil
|
920
|
+
end
|
921
|
+
end
|
922
|
+
|
923
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
924
|
+
with_fraud_protection_enterprise_merchant do
|
925
|
+
customer = Braintree::Customer.create!
|
926
|
+
credit_card = Braintree::CreditCard.create!(
|
927
|
+
:cardholder_name => "Original Holder",
|
928
|
+
:customer_id => customer.id,
|
929
|
+
:cvv => "123",
|
930
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
931
|
+
:expiration_date => "05/2020",
|
932
|
+
)
|
933
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
934
|
+
:expiration_date => "05/2021",
|
935
|
+
:options => {
|
936
|
+
:verify_card => true,
|
937
|
+
:skip_advanced_fraud_checking => true,
|
938
|
+
},
|
939
|
+
)
|
940
|
+
|
941
|
+
expect(updated_result).to be_success
|
942
|
+
verification = updated_result.credit_card.verification
|
943
|
+
expect(verification.risk_data).to be_nil
|
944
|
+
end
|
854
945
|
end
|
855
946
|
|
856
947
|
context "billing address" do
|
@@ -862,12 +953,12 @@ describe Braintree::CreditCard do
|
|
862
953
|
:expiration_date => "05/2012",
|
863
954
|
:billing_address => {
|
864
955
|
:street_address => "123 Nigeria Ave"
|
865
|
-
}
|
956
|
+
},
|
866
957
|
)
|
867
958
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
868
959
|
:billing_address => {
|
869
960
|
:region => "IL"
|
870
|
-
}
|
961
|
+
},
|
871
962
|
)
|
872
963
|
update_result.success?.should == true
|
873
964
|
updated_credit_card = update_result.credit_card
|
@@ -884,13 +975,13 @@ describe Braintree::CreditCard do
|
|
884
975
|
:expiration_date => "05/2012",
|
885
976
|
:billing_address => {
|
886
977
|
:street_address => "123 Nigeria Ave"
|
887
|
-
}
|
978
|
+
},
|
888
979
|
)
|
889
980
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
890
981
|
:billing_address => {
|
891
982
|
:region => "IL",
|
892
983
|
:options => {:update_existing => true}
|
893
|
-
}
|
984
|
+
},
|
894
985
|
)
|
895
986
|
update_result.success?.should == true
|
896
987
|
updated_credit_card = update_result.credit_card
|
@@ -907,7 +998,7 @@ describe Braintree::CreditCard do
|
|
907
998
|
:expiration_date => "05/2012",
|
908
999
|
:billing_address => {
|
909
1000
|
:street_address => "123 Nigeria Ave"
|
910
|
-
}
|
1001
|
+
},
|
911
1002
|
)
|
912
1003
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
913
1004
|
:billing_address => {
|
@@ -916,7 +1007,7 @@ describe Braintree::CreditCard do
|
|
916
1007
|
:country_code_alpha3 => "ASM",
|
917
1008
|
:country_code_numeric => "016",
|
918
1009
|
:options => {:update_existing => true}
|
919
|
-
}
|
1010
|
+
},
|
920
1011
|
)
|
921
1012
|
update_result.success?.should == true
|
922
1013
|
updated_credit_card = update_result.credit_card
|
@@ -932,12 +1023,12 @@ describe Braintree::CreditCard do
|
|
932
1023
|
credit_card = Braintree::CreditCard.create!(
|
933
1024
|
:customer_id => customer.id,
|
934
1025
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
935
|
-
:expiration_date => "05/2012"
|
1026
|
+
:expiration_date => "05/2012",
|
936
1027
|
)
|
937
1028
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
938
1029
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
939
1030
|
:expiration_month => "07",
|
940
|
-
:expiration_year => "2011"
|
1031
|
+
:expiration_year => "2011",
|
941
1032
|
)
|
942
1033
|
update_result.success?.should == true
|
943
1034
|
update_result.credit_card.should == credit_card
|
@@ -953,14 +1044,14 @@ describe Braintree::CreditCard do
|
|
953
1044
|
:customer_id => customer.id,
|
954
1045
|
:cvv => "123",
|
955
1046
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
956
|
-
:expiration_date => "05/2012"
|
1047
|
+
:expiration_date => "05/2012",
|
957
1048
|
)
|
958
1049
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
959
1050
|
:cardholder_name => "New Holder",
|
960
1051
|
:cvv => "456",
|
961
1052
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
962
1053
|
:expiration_date => "06/2013",
|
963
|
-
:options => {:verify_card => true}
|
1054
|
+
:options => {:verify_card => true},
|
964
1055
|
)
|
965
1056
|
update_result.success?.should == false
|
966
1057
|
update_result.credit_card_verification.status.should == Braintree::CreditCardVerification::Status::ProcessorDeclined
|
@@ -985,7 +1076,7 @@ describe Braintree::CreditCard do
|
|
985
1076
|
:region => "Old State",
|
986
1077
|
:postal_code => "12345",
|
987
1078
|
:country_name => "Canada"
|
988
|
-
}
|
1079
|
+
},
|
989
1080
|
)
|
990
1081
|
result = Braintree::CreditCard.update(credit_card.token,
|
991
1082
|
:options => {:verify_card => false},
|
@@ -999,7 +1090,7 @@ describe Braintree::CreditCard do
|
|
999
1090
|
:region => "New State",
|
1000
1091
|
:postal_code => "56789",
|
1001
1092
|
:country_name => "United States of America"
|
1002
|
-
}
|
1093
|
+
},
|
1003
1094
|
)
|
1004
1095
|
result.success?.should == true
|
1005
1096
|
address = result.credit_card.billing_address
|
@@ -1020,12 +1111,12 @@ describe Braintree::CreditCard do
|
|
1020
1111
|
:cardholder_name => "Original Holder",
|
1021
1112
|
:customer_id => customer.id,
|
1022
1113
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1023
|
-
:expiration_date => "05/2012"
|
1114
|
+
:expiration_date => "05/2012",
|
1024
1115
|
)
|
1025
1116
|
update_result = Braintree::CreditCard.update(credit_card.token,
|
1026
1117
|
:cardholder_name => "New Holder",
|
1027
1118
|
:number => "invalid",
|
1028
|
-
:expiration_date => "05/2014"
|
1119
|
+
:expiration_date => "05/2014",
|
1029
1120
|
)
|
1030
1121
|
update_result.success?.should == false
|
1031
1122
|
update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits."
|
@@ -1036,12 +1127,12 @@ describe Braintree::CreditCard do
|
|
1036
1127
|
card1 = Braintree::CreditCard.create(
|
1037
1128
|
:customer_id => customer.id,
|
1038
1129
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1039
|
-
:expiration_date => "05/2009"
|
1130
|
+
:expiration_date => "05/2009",
|
1040
1131
|
).credit_card
|
1041
1132
|
card2 = Braintree::CreditCard.create(
|
1042
1133
|
:customer_id => customer.id,
|
1043
1134
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1044
|
-
:expiration_date => "05/2009"
|
1135
|
+
:expiration_date => "05/2009",
|
1045
1136
|
).credit_card
|
1046
1137
|
|
1047
1138
|
card1.should be_default
|
@@ -1099,12 +1190,12 @@ describe Braintree::CreditCard do
|
|
1099
1190
|
:cardholder_name => "Original Holder",
|
1100
1191
|
:customer_id => customer.id,
|
1101
1192
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1102
|
-
:expiration_date => "05/2012"
|
1193
|
+
:expiration_date => "05/2012",
|
1103
1194
|
)
|
1104
1195
|
updated_credit_card = Braintree::CreditCard.update!(credit_card.token,
|
1105
1196
|
:cardholder_name => "New Holder",
|
1106
1197
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1107
|
-
:expiration_date => "06/2013"
|
1198
|
+
:expiration_date => "06/2013",
|
1108
1199
|
)
|
1109
1200
|
updated_credit_card.token.should == credit_card.token
|
1110
1201
|
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
@@ -1120,13 +1211,13 @@ describe Braintree::CreditCard do
|
|
1120
1211
|
:cardholder_name => "Original Holder",
|
1121
1212
|
:customer_id => customer.id,
|
1122
1213
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1123
|
-
:expiration_date => "05/2012"
|
1214
|
+
:expiration_date => "05/2012",
|
1124
1215
|
)
|
1125
1216
|
expect do
|
1126
1217
|
Braintree::CreditCard.update!(credit_card.token,
|
1127
1218
|
:cardholder_name => "New Holder",
|
1128
1219
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1129
|
-
:expiration_date => "invalid/date"
|
1220
|
+
:expiration_date => "invalid/date",
|
1130
1221
|
)
|
1131
1222
|
end.to raise_error(Braintree::ValidationsFailed)
|
1132
1223
|
end
|
@@ -1138,7 +1229,7 @@ describe Braintree::CreditCard do
|
|
1138
1229
|
result = Braintree::CreditCard.create(
|
1139
1230
|
:customer_id => customer.id,
|
1140
1231
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1141
|
-
:expiration_date => "05/2012"
|
1232
|
+
:expiration_date => "05/2012",
|
1142
1233
|
)
|
1143
1234
|
|
1144
1235
|
result.success?.should == true
|
@@ -1158,7 +1249,7 @@ describe Braintree::CreditCard do
|
|
1158
1249
|
Braintree::CreditCard.create!(
|
1159
1250
|
:customer_id => customer.id,
|
1160
1251
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1161
|
-
:expiration_date => "01/#{Time.now.year - 3}"
|
1252
|
+
:expiration_date => "01/#{Time.now.year - 3}",
|
1162
1253
|
)
|
1163
1254
|
end
|
1164
1255
|
|
@@ -1189,14 +1280,14 @@ describe Braintree::CreditCard do
|
|
1189
1280
|
Braintree::CreditCard.create!(
|
1190
1281
|
:customer_id => customer.id,
|
1191
1282
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1192
|
-
:expiration_date => "01/2010"
|
1283
|
+
:expiration_date => "01/2010",
|
1193
1284
|
)
|
1194
1285
|
end
|
1195
1286
|
|
1196
1287
|
collection = Braintree::CreditCard.expiring_between(Time.mktime(2010, 1, 1), Time.mktime(2010,3, 1))
|
1197
1288
|
collection.maximum_size.should > 100
|
1198
1289
|
|
1199
|
-
credit_card_ids = collection.map {|c| c.token }.uniq.compact
|
1290
|
+
credit_card_ids = collection.map { |c| c.token }.uniq.compact
|
1200
1291
|
credit_card_ids.size.should == collection.maximum_size
|
1201
1292
|
end
|
1202
1293
|
end
|
@@ -1207,7 +1298,7 @@ describe Braintree::CreditCard do
|
|
1207
1298
|
result = Braintree::CreditCard.create(
|
1208
1299
|
:customer_id => customer.id,
|
1209
1300
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1210
|
-
:expiration_date => "05/2012"
|
1301
|
+
:expiration_date => "05/2012",
|
1211
1302
|
)
|
1212
1303
|
result.success?.should == true
|
1213
1304
|
credit_card = Braintree::CreditCard.find(result.credit_card.token)
|
@@ -1222,13 +1313,13 @@ describe Braintree::CreditCard do
|
|
1222
1313
|
credit_card = Braintree::CreditCard.create(
|
1223
1314
|
:customer_id => customer.id,
|
1224
1315
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1225
|
-
:expiration_date => "05/2012"
|
1316
|
+
:expiration_date => "05/2012",
|
1226
1317
|
).credit_card
|
1227
1318
|
|
1228
1319
|
subscription = Braintree::Subscription.create(
|
1229
1320
|
:payment_method_token => credit_card.token,
|
1230
1321
|
:plan_id => "integration_trialless_plan",
|
1231
|
-
:price => "1.00"
|
1322
|
+
:price => "1.00",
|
1232
1323
|
).subscription
|
1233
1324
|
|
1234
1325
|
found_card = Braintree::CreditCard.find(credit_card.token)
|
@@ -1272,7 +1363,7 @@ describe Braintree::CreditCard do
|
|
1272
1363
|
:expiration_month => "11",
|
1273
1364
|
:expiration_year => "2099",
|
1274
1365
|
},
|
1275
|
-
:client_token_options => {:customer_id => customer.id}
|
1366
|
+
:client_token_options => {:customer_id => customer.id},
|
1276
1367
|
)
|
1277
1368
|
|
1278
1369
|
credit_card = Braintree::CreditCard.from_nonce(nonce)
|
@@ -1286,7 +1377,7 @@ describe Braintree::CreditCard do
|
|
1286
1377
|
:number => "4111111111111111",
|
1287
1378
|
:expiration_month => "11",
|
1288
1379
|
:expiration_year => "2099",
|
1289
|
-
}
|
1380
|
+
},
|
1290
1381
|
)
|
1291
1382
|
expect do
|
1292
1383
|
Braintree::CreditCard.from_nonce(nonce)
|
@@ -1301,7 +1392,7 @@ describe Braintree::CreditCard do
|
|
1301
1392
|
:expiration_month => "11",
|
1302
1393
|
:expiration_year => "2099",
|
1303
1394
|
},
|
1304
|
-
:client_token_options => {:customer_id => customer.id}
|
1395
|
+
:client_token_options => {:customer_id => customer.id},
|
1305
1396
|
)
|
1306
1397
|
|
1307
1398
|
Braintree::CreditCard.from_nonce(nonce)
|
@@ -1317,7 +1408,7 @@ describe Braintree::CreditCard do
|
|
1317
1408
|
:credit_card => {
|
1318
1409
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1319
1410
|
:expiration_date => "05/2010"
|
1320
|
-
}
|
1411
|
+
},
|
1321
1412
|
)
|
1322
1413
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00")
|
1323
1414
|
|
@@ -1336,13 +1427,13 @@ describe Braintree::CreditCard do
|
|
1336
1427
|
:credit_card => {
|
1337
1428
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1338
1429
|
:expiration_date => "05/2010"
|
1339
|
-
}
|
1430
|
+
},
|
1340
1431
|
)
|
1341
1432
|
result = Braintree::CreditCard.sale(customer.credit_cards[0].token,
|
1342
1433
|
:amount => "100.00",
|
1343
1434
|
:credit_card => {
|
1344
1435
|
:cvv => "301"
|
1345
|
-
}
|
1436
|
+
},
|
1346
1437
|
)
|
1347
1438
|
|
1348
1439
|
result.success?.should == true
|
@@ -1360,7 +1451,7 @@ describe Braintree::CreditCard do
|
|
1360
1451
|
:credit_card => {
|
1361
1452
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1362
1453
|
:expiration_date => "05/2010"
|
1363
|
-
}
|
1454
|
+
},
|
1364
1455
|
)
|
1365
1456
|
transaction = Braintree::CreditCard.sale!(customer.credit_cards[0].token, :amount => "100.00")
|
1366
1457
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -1380,7 +1471,7 @@ describe Braintree::CreditCard do
|
|
1380
1471
|
:cardholder_name => "Original Holder",
|
1381
1472
|
:customer_id => customer.id,
|
1382
1473
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1383
|
-
:expiration_date => "05/2012"
|
1474
|
+
:expiration_date => "05/2012",
|
1384
1475
|
)
|
1385
1476
|
|
1386
1477
|
credit_card.nonce.should_not be_nil
|
@@ -1398,7 +1489,7 @@ describe Braintree::CreditCard do
|
|
1398
1489
|
credit_card = Braintree::CreditCard.create(
|
1399
1490
|
:customer_id => customer.id,
|
1400
1491
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1401
|
-
:expiration_date => "05/2009"
|
1492
|
+
:expiration_date => "05/2009",
|
1402
1493
|
).credit_card
|
1403
1494
|
credit_card_vaulted = Braintree::CreditCard.find(credit_card.token)
|
1404
1495
|
credit_card_vaulted.is_network_tokenized?.should == false
|