braintree 2.101.0 → 2.102.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/credit_card_gateway.rb +13 -0
- data/lib/braintree/error_codes.rb +23 -0
- data/lib/braintree/payment_method_gateway.rb +12 -0
- data/lib/braintree/payment_method_nonce.rb +2 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +13 -2
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/nonce.rb +14 -0
- data/lib/braintree/transaction.rb +1 -0
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +3 -0
- data/lib/braintree/webhook_testing_gateway.rb +243 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +80 -73
- data/spec/integration/braintree/credit_card_spec.rb +99 -0
- data/spec/integration/braintree/customer_spec.rb +113 -0
- data/spec/integration/braintree/document_upload_spec.rb +12 -0
- data/spec/integration/braintree/payment_method_nonce_spec.rb +77 -0
- data/spec/integration/braintree/payment_method_spec.rb +109 -0
- data/spec/integration/braintree/transaction_spec.rb +1 -0
- data/spec/unit/braintree/credit_card_spec.rb +22 -2
- data/spec/unit/braintree/customer_spec.rb +22 -2
- data/spec/unit/braintree/webhook_notification_spec.rb +48 -0
- metadata +5 -3
@@ -300,6 +300,50 @@ describe Braintree::PaymentMethod do
|
|
300
300
|
result.credit_card_verification.amount.should == BigDecimal("100.00")
|
301
301
|
end
|
302
302
|
|
303
|
+
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
304
|
+
customer = Braintree::Customer.create!
|
305
|
+
result = Braintree::PaymentMethod.create(
|
306
|
+
:customer_id => customer.id,
|
307
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
308
|
+
:three_d_secure_pass_thru => {
|
309
|
+
:eci_flag => '02',
|
310
|
+
:cavv => 'some_cavv',
|
311
|
+
:xid => 'some_xid',
|
312
|
+
:three_d_secure_version => 'xx',
|
313
|
+
:authentication_response => 'Y',
|
314
|
+
:directory_response => 'Y',
|
315
|
+
:cavv_algorithm => '2',
|
316
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
317
|
+
},
|
318
|
+
:options => {:verify_card => true}
|
319
|
+
)
|
320
|
+
expect(result).not_to be_success
|
321
|
+
error = result.errors.for(:verification).first
|
322
|
+
expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsInvalid)
|
323
|
+
expect(error.message).to eq("The version of 3D Secure authentication must be composed only of digits and separated by periods (e.g. `1.0.2`).")
|
324
|
+
end
|
325
|
+
|
326
|
+
it "accepts three_d_secure pass thru params in the request" do
|
327
|
+
customer = Braintree::Customer.create!
|
328
|
+
result = Braintree::PaymentMethod.create(
|
329
|
+
:customer_id => customer.id,
|
330
|
+
:payment_method_nonce => Braintree::Test::Nonce::Transactable,
|
331
|
+
:three_d_secure_pass_thru => {
|
332
|
+
:eci_flag => '02',
|
333
|
+
:cavv => 'some_cavv',
|
334
|
+
:xid => 'some_xid',
|
335
|
+
:three_d_secure_version => '1.0.2',
|
336
|
+
:authentication_response => 'Y',
|
337
|
+
:directory_response => 'Y',
|
338
|
+
:cavv_algorithm => '2',
|
339
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
340
|
+
},
|
341
|
+
:options => {:verify_card => true}
|
342
|
+
)
|
343
|
+
|
344
|
+
expect(result).to be_success
|
345
|
+
end
|
346
|
+
|
303
347
|
it "returns 3DS info on cc verification" do
|
304
348
|
customer = Braintree::Customer.create.customer
|
305
349
|
result = Braintree::PaymentMethod.create(
|
@@ -1169,6 +1213,71 @@ describe Braintree::PaymentMethod do
|
|
1169
1213
|
|
1170
1214
|
describe "self.update" do
|
1171
1215
|
context "credit cards" do
|
1216
|
+
it "throws validation error when passing invalid pass thru params" do
|
1217
|
+
customer = Braintree::Customer.create!
|
1218
|
+
credit_card = Braintree::CreditCard.create!(
|
1219
|
+
:customer_id => customer.id,
|
1220
|
+
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1221
|
+
:options => {:verify_card => true},
|
1222
|
+
)
|
1223
|
+
|
1224
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1225
|
+
:cardholder_name => "New Holder",
|
1226
|
+
:cvv => "456",
|
1227
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1228
|
+
:expiration_date => "06/2013",
|
1229
|
+
:three_d_secure_pass_thru => {
|
1230
|
+
:eci_flag => '02',
|
1231
|
+
:cavv => 'some_cavv',
|
1232
|
+
:xid => 'some_xid',
|
1233
|
+
:three_d_secure_version => 'xx',
|
1234
|
+
:authentication_response => 'Y',
|
1235
|
+
:directory_response => 'Y',
|
1236
|
+
:cavv_algorithm => '2',
|
1237
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
1238
|
+
},
|
1239
|
+
:options => {:verify_card => true},
|
1240
|
+
)
|
1241
|
+
expect(update_result).to_not be_success
|
1242
|
+
error = update_result.errors.for(:verification).first
|
1243
|
+
expect(error.code).to eq(Braintree::ErrorCodes::Verification::ThreeDSecurePassThru::ThreeDSecureVersionIsInvalid)
|
1244
|
+
expect(error.message).to eq("The version of 3D Secure authentication must be composed only of digits and separated by periods (e.g. `1.0.2`).")
|
1245
|
+
end
|
1246
|
+
|
1247
|
+
it "updates the credit card with three_d_secure pass thru params" do
|
1248
|
+
customer = Braintree::Customer.create!
|
1249
|
+
credit_card = Braintree::CreditCard.create!(
|
1250
|
+
:customer_id => customer.id,
|
1251
|
+
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1252
|
+
:options => {:verify_card => true},
|
1253
|
+
)
|
1254
|
+
|
1255
|
+
update_result = Braintree::PaymentMethod.update(credit_card.token,
|
1256
|
+
:cardholder_name => "New Holder",
|
1257
|
+
:cvv => "456",
|
1258
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
1259
|
+
:expiration_date => "06/2013",
|
1260
|
+
:three_d_secure_pass_thru => {
|
1261
|
+
:eci_flag => '02',
|
1262
|
+
:cavv => 'some_cavv',
|
1263
|
+
:xid => 'some_xid',
|
1264
|
+
:three_d_secure_version => '1.0.2',
|
1265
|
+
:authentication_response => 'Y',
|
1266
|
+
:directory_response => 'Y',
|
1267
|
+
:cavv_algorithm => '2',
|
1268
|
+
:ds_transaction_id => 'some_ds_transaction_id',
|
1269
|
+
},
|
1270
|
+
:options => {:verify_card => true},
|
1271
|
+
)
|
1272
|
+
update_result.success?.should == true
|
1273
|
+
update_result.payment_method.should == credit_card
|
1274
|
+
updated_credit_card = update_result.payment_method
|
1275
|
+
updated_credit_card.cardholder_name.should == "New Holder"
|
1276
|
+
updated_credit_card.bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
1277
|
+
updated_credit_card.last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
1278
|
+
updated_credit_card.expiration_date.should == "06/2013"
|
1279
|
+
end
|
1280
|
+
|
1172
1281
|
it "updates the credit card" do
|
1173
1282
|
customer = Braintree::Customer.create!
|
1174
1283
|
credit_card = Braintree::CreditCard.create!(
|
@@ -419,6 +419,7 @@ describe Braintree::Transaction do
|
|
419
419
|
result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1]
|
420
420
|
result.transaction.credit_card_details.expiration_date.should == "05/2009"
|
421
421
|
result.transaction.credit_card_details.customer_location.should == "US"
|
422
|
+
result.transaction.retrieval_reference_number.should_not be_nil
|
422
423
|
end
|
423
424
|
|
424
425
|
it "returns a successful network response code if successful" do
|
@@ -41,7 +41,17 @@ describe Braintree::CreditCard do
|
|
41
41
|
:region,
|
42
42
|
:street_address
|
43
43
|
]},
|
44
|
-
:
|
44
|
+
{:three_d_secure_pass_thru => [
|
45
|
+
:eci_flag,
|
46
|
+
:cavv,
|
47
|
+
:xid,
|
48
|
+
:three_d_secure_version,
|
49
|
+
:authentication_response,
|
50
|
+
:directory_response,
|
51
|
+
:cavv_algorithm,
|
52
|
+
:ds_transaction_id,
|
53
|
+
]},
|
54
|
+
:customer_id,
|
45
55
|
]
|
46
56
|
end
|
47
57
|
end
|
@@ -78,7 +88,17 @@ describe Braintree::CreditCard do
|
|
78
88
|
:region,
|
79
89
|
:street_address,
|
80
90
|
{:options => [:update_existing]}
|
81
|
-
]}
|
91
|
+
]},
|
92
|
+
{:three_d_secure_pass_thru => [
|
93
|
+
:eci_flag,
|
94
|
+
:cavv,
|
95
|
+
:xid,
|
96
|
+
:three_d_secure_version,
|
97
|
+
:authentication_response,
|
98
|
+
:directory_response,
|
99
|
+
:cavv_algorithm,
|
100
|
+
:ds_transaction_id,
|
101
|
+
]},
|
82
102
|
]
|
83
103
|
end
|
84
104
|
end
|
@@ -116,7 +116,17 @@ describe Braintree::Customer do
|
|
116
116
|
:postal_code,
|
117
117
|
:region,
|
118
118
|
:street_address
|
119
|
-
]}
|
119
|
+
]},
|
120
|
+
{:three_d_secure_pass_thru => [
|
121
|
+
:eci_flag,
|
122
|
+
:cavv,
|
123
|
+
:xid,
|
124
|
+
:three_d_secure_version,
|
125
|
+
:authentication_response,
|
126
|
+
:directory_response,
|
127
|
+
:cavv_algorithm,
|
128
|
+
:ds_transaction_id,
|
129
|
+
]},
|
120
130
|
]},
|
121
131
|
{:paypal_account => [
|
122
132
|
:email,
|
@@ -205,7 +215,17 @@ describe Braintree::Customer do
|
|
205
215
|
:region,
|
206
216
|
:street_address,
|
207
217
|
{:options => [:update_existing]}
|
208
|
-
]}
|
218
|
+
]},
|
219
|
+
{:three_d_secure_pass_thru => [
|
220
|
+
:eci_flag,
|
221
|
+
:cavv,
|
222
|
+
:xid,
|
223
|
+
:three_d_secure_version,
|
224
|
+
:authentication_response,
|
225
|
+
:directory_response,
|
226
|
+
:cavv_algorithm,
|
227
|
+
:ds_transaction_id,
|
228
|
+
]},
|
209
229
|
]},
|
210
230
|
{:options =>
|
211
231
|
[:paypal => [
|
@@ -184,6 +184,54 @@ describe Braintree::WebhookNotification do
|
|
184
184
|
dispute.kind.should == Braintree::Dispute::Kind::Chargeback
|
185
185
|
end
|
186
186
|
|
187
|
+
it "builds a sample notification for a dispute accepted webhook" do
|
188
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
189
|
+
Braintree::WebhookNotification::Kind::DisputeAccepted,
|
190
|
+
dispute_id
|
191
|
+
)
|
192
|
+
|
193
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
194
|
+
|
195
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::DisputeAccepted
|
196
|
+
|
197
|
+
dispute = notification.dispute
|
198
|
+
dispute.status.should == Braintree::Dispute::Status::Accepted
|
199
|
+
dispute.id.should == dispute_id
|
200
|
+
dispute.kind.should == Braintree::Dispute::Kind::Chargeback
|
201
|
+
end
|
202
|
+
|
203
|
+
it "builds a sample notification for a dispute disputed webhook" do
|
204
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
205
|
+
Braintree::WebhookNotification::Kind::DisputeDisputed,
|
206
|
+
dispute_id
|
207
|
+
)
|
208
|
+
|
209
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
210
|
+
|
211
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::DisputeDisputed
|
212
|
+
|
213
|
+
dispute = notification.dispute
|
214
|
+
dispute.status.should == Braintree::Dispute::Status::Disputed
|
215
|
+
dispute.id.should == dispute_id
|
216
|
+
dispute.kind.should == Braintree::Dispute::Kind::Chargeback
|
217
|
+
end
|
218
|
+
|
219
|
+
it "builds a sample notification for a dispute expired webhook" do
|
220
|
+
sample_notification = Braintree::WebhookTesting.sample_notification(
|
221
|
+
Braintree::WebhookNotification::Kind::DisputeExpired,
|
222
|
+
dispute_id
|
223
|
+
)
|
224
|
+
|
225
|
+
notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
|
226
|
+
|
227
|
+
notification.kind.should == Braintree::WebhookNotification::Kind::DisputeExpired
|
228
|
+
|
229
|
+
dispute = notification.dispute
|
230
|
+
dispute.status.should == Braintree::Dispute::Status::Expired
|
231
|
+
dispute.id.should == dispute_id
|
232
|
+
dispute.kind.should == Braintree::Dispute::Kind::Chargeback
|
233
|
+
end
|
234
|
+
|
187
235
|
it "is compatible with the previous dispute won webhook interface" do
|
188
236
|
sample_notification = Braintree::WebhookTesting.sample_notification(
|
189
237
|
Braintree::WebhookNotification::Kind::DisputeWon,
|
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: 2.
|
4
|
+
version: 2.102.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braintree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/braintree/subscription_gateway.rb
|
134
134
|
- lib/braintree/subscription_search.rb
|
135
135
|
- lib/braintree/successful_result.rb
|
136
|
+
- lib/braintree/test/authentication_id.rb
|
136
137
|
- lib/braintree/test/credit_card.rb
|
137
138
|
- lib/braintree/test/merchant_account.rb
|
138
139
|
- lib/braintree/test/nonce.rb
|
@@ -320,7 +321,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
320
321
|
- !ruby/object:Gem::Version
|
321
322
|
version: '0'
|
322
323
|
requirements: []
|
323
|
-
|
324
|
+
rubyforge_project:
|
325
|
+
rubygems_version: 2.7.6.2
|
324
326
|
signing_key:
|
325
327
|
specification_version: 4
|
326
328
|
summary: Braintree Gateway Ruby Client Library
|