braintree 2.100.0 → 2.104.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/address_gateway.rb +2 -2
  3. data/lib/braintree/amex_express_checkout_card.rb +2 -0
  4. data/lib/braintree/android_pay_card.rb +5 -0
  5. data/lib/braintree/base_module.rb +4 -0
  6. data/lib/braintree/credit_card.rb +5 -1
  7. data/lib/braintree/credit_card_gateway.rb +13 -0
  8. data/lib/braintree/credit_card_verification.rb +2 -0
  9. data/lib/braintree/customer.rb +5 -2
  10. data/lib/braintree/dispute.rb +1 -0
  11. data/lib/braintree/dispute/transaction.rb +2 -0
  12. data/lib/braintree/error_codes.rb +76 -34
  13. data/lib/braintree/graphql_client.rb +7 -1
  14. data/lib/braintree/local_payment_completed.rb +1 -1
  15. data/lib/braintree/masterpass_card.rb +2 -0
  16. data/lib/braintree/payment_instrument_type.rb +2 -1
  17. data/lib/braintree/payment_method_gateway.rb +14 -0
  18. data/lib/braintree/payment_method_nonce.rb +2 -0
  19. data/lib/braintree/payment_method_nonce_gateway.rb +13 -2
  20. data/lib/braintree/payment_method_parser.rb +1 -0
  21. data/lib/braintree/risk_data.rb +4 -1
  22. data/lib/braintree/test/authentication_id.rb +21 -0
  23. data/lib/braintree/test/credit_card.rb +1 -0
  24. data/lib/braintree/test/nonce.rb +18 -0
  25. data/lib/braintree/three_d_secure_info.rb +2 -0
  26. data/lib/braintree/transaction.rb +15 -1
  27. data/lib/braintree/transaction/address_details.rb +11 -0
  28. data/lib/braintree/transaction/android_pay_details.rb +4 -0
  29. data/lib/braintree/transaction/masterpass_card_details.rb +2 -0
  30. data/lib/braintree/transaction/paypal_details.rb +2 -0
  31. data/lib/braintree/transaction_gateway.rb +12 -3
  32. data/lib/braintree/version.rb +2 -2
  33. data/lib/braintree/webhook_notification.rb +3 -0
  34. data/lib/braintree/webhook_testing_gateway.rb +243 -0
  35. data/spec/integration/braintree/client_api/spec_helper.rb +98 -46
  36. data/spec/integration/braintree/credit_card_spec.rb +120 -2
  37. data/spec/integration/braintree/credit_card_verification_spec.rb +2 -0
  38. data/spec/integration/braintree/customer_spec.rb +116 -0
  39. data/spec/integration/braintree/dispute_search_spec.rb +1 -1
  40. data/spec/integration/braintree/dispute_spec.rb +1 -0
  41. data/spec/integration/braintree/document_upload_spec.rb +12 -0
  42. data/spec/integration/braintree/merchant_spec.rb +2 -2
  43. data/spec/integration/braintree/payment_method_nonce_spec.rb +83 -2
  44. data/spec/integration/braintree/payment_method_spec.rb +113 -18
  45. data/spec/integration/braintree/paypal_account_spec.rb +1 -1
  46. data/spec/integration/braintree/transaction_spec.rb +435 -45
  47. data/spec/spec_helper.rb +1 -1
  48. data/spec/unit/braintree/credit_card_spec.rb +49 -3
  49. data/spec/unit/braintree/credit_card_verification_spec.rb +7 -0
  50. data/spec/unit/braintree/customer_spec.rb +26 -2
  51. data/spec/unit/braintree/dispute_spec.rb +3 -0
  52. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  53. data/spec/unit/braintree/three_d_secure_info_spec.rb +3 -1
  54. data/spec/unit/braintree/transaction/paypal_details_spec.rb +57 -0
  55. data/spec/unit/braintree/transaction_spec.rb +16 -2
  56. data/spec/unit/braintree/webhook_notification_spec.rb +48 -0
  57. metadata +5 -3
@@ -110,7 +110,7 @@ unless defined?(SPEC_HELPER_LOADED)
110
110
  def self.create_3ds_verification(merchant_account_id, params)
111
111
  config = Braintree::Configuration.instantiate
112
112
  response = config.http.post("#{config.base_merchant_path}/three_d_secure/create_verification/#{merchant_account_id}", :three_d_secure_verification => params)
113
- response[:three_d_secure_verification][:three_d_secure_token]
113
+ response[:three_d_secure_verification][:three_d_secure_authentication_id]
114
114
  end
115
115
 
116
116
  def self.create_merchant(params={})
@@ -37,11 +37,22 @@ describe Braintree::CreditCard do
37
37
  :first_name,
38
38
  :last_name,
39
39
  :locality,
40
+ :phone_number,
40
41
  :postal_code,
41
42
  :region,
42
43
  :street_address
43
44
  ]},
44
- :customer_id
45
+ {:three_d_secure_pass_thru => [
46
+ :eci_flag,
47
+ :cavv,
48
+ :xid,
49
+ :three_d_secure_version,
50
+ :authentication_response,
51
+ :directory_response,
52
+ :cavv_algorithm,
53
+ :ds_transaction_id,
54
+ ]},
55
+ :customer_id,
45
56
  ]
46
57
  end
47
58
  end
@@ -74,11 +85,22 @@ describe Braintree::CreditCard do
74
85
  :first_name,
75
86
  :last_name,
76
87
  :locality,
88
+ :phone_number,
77
89
  :postal_code,
78
90
  :region,
79
91
  :street_address,
80
92
  {:options => [:update_existing]}
81
- ]}
93
+ ]},
94
+ {:three_d_secure_pass_thru => [
95
+ :eci_flag,
96
+ :cavv,
97
+ :xid,
98
+ :three_d_secure_version,
99
+ :authentication_response,
100
+ :directory_response,
101
+ :cavv_algorithm,
102
+ :ds_transaction_id,
103
+ ]},
82
104
  ]
83
105
  end
84
106
  end
@@ -176,7 +198,8 @@ describe Braintree::CreditCard do
176
198
  :expiration_year => "2020",
177
199
  :last_4 => "1111",
178
200
  :token => "tok1",
179
- :updated_at => Time.now
201
+ :updated_at => Time.now,
202
+ :is_network_tokenized => false,
180
203
  )
181
204
  output = credit_card.inspect
182
205
  output.should include(%q(bin: "411111"))
@@ -190,6 +213,7 @@ describe Braintree::CreditCard do
190
213
  output.should include(%q(token: "tok1"))
191
214
  output.should include(%Q(updated_at: #{credit_card.updated_at.inspect}))
192
215
  output.should include(%Q(created_at: #{credit_card.created_at.inspect}))
216
+ output.should include(%q(is_network_tokenized?: false))
193
217
  end
194
218
  end
195
219
 
@@ -204,6 +228,28 @@ describe Braintree::CreditCard do
204
228
  end
205
229
  end
206
230
 
231
+ describe "is_network_tokenized?" do
232
+ it "returns true" do
233
+ credit_card = Braintree::CreditCard._new(
234
+ :gateway,
235
+ :bin => "510510",
236
+ :last_4 => "5100",
237
+ :is_network_tokenized => true
238
+ )
239
+ credit_card.is_network_tokenized?.should == true
240
+ end
241
+
242
+ it "returns false" do
243
+ credit_card = Braintree::CreditCard._new(
244
+ :gateway,
245
+ :bin => "510510",
246
+ :last_4 => "5100",
247
+ :is_network_tokenized => false
248
+ )
249
+ credit_card.is_network_tokenized?.should == false
250
+ end
251
+ end
252
+
207
253
  describe "self.update" do
208
254
  it "raises an exception if attributes contain an invalid key" do
209
255
  expect do
@@ -42,6 +42,13 @@ describe Braintree::CreditCardVerification do
42
42
  Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount.should == BigDecimal("12.34")
43
43
  end
44
44
 
45
+ it "accepts network_transaction_id" do
46
+ verification = Braintree::CreditCardVerification._new(
47
+ :network_transaction_id => "123456789012345"
48
+ )
49
+ expect(verification.network_transaction_id).to eq "123456789012345"
50
+ end
51
+
45
52
  describe "self.create" do
46
53
  it "rejects invalid parameters" do
47
54
  expect do
@@ -113,10 +113,21 @@ describe Braintree::Customer do
113
113
  :first_name,
114
114
  :last_name,
115
115
  :locality,
116
+ :phone_number,
116
117
  :postal_code,
117
118
  :region,
118
119
  :street_address
119
- ]}
120
+ ]},
121
+ {:three_d_secure_pass_thru => [
122
+ :eci_flag,
123
+ :cavv,
124
+ :xid,
125
+ :three_d_secure_version,
126
+ :authentication_response,
127
+ :directory_response,
128
+ :cavv_algorithm,
129
+ :ds_transaction_id,
130
+ ]},
120
131
  ]},
121
132
  {:paypal_account => [
122
133
  :email,
@@ -141,6 +152,7 @@ describe Braintree::Customer do
141
152
  :first_name,
142
153
  :last_name,
143
154
  :locality,
155
+ :phone_number,
144
156
  :postal_code,
145
157
  :region,
146
158
  :street_address,
@@ -201,11 +213,22 @@ describe Braintree::Customer do
201
213
  :first_name,
202
214
  :last_name,
203
215
  :locality,
216
+ :phone_number,
204
217
  :postal_code,
205
218
  :region,
206
219
  :street_address,
207
220
  {:options => [:update_existing]}
208
- ]}
221
+ ]},
222
+ {:three_d_secure_pass_thru => [
223
+ :eci_flag,
224
+ :cavv,
225
+ :xid,
226
+ :three_d_secure_version,
227
+ :authentication_response,
228
+ :directory_response,
229
+ :cavv_algorithm,
230
+ :ds_transaction_id,
231
+ ]},
209
232
  ]},
210
233
  {:options =>
211
234
  [:paypal => [
@@ -224,6 +247,7 @@ describe Braintree::Customer do
224
247
  :first_name,
225
248
  :last_name,
226
249
  :locality,
250
+ :phone_number,
227
251
  :postal_code,
228
252
  :region,
229
253
  :street_address,
@@ -42,6 +42,7 @@ describe Braintree::Dispute do
42
42
  :amount => "31.00",
43
43
  :id => "open_disputed_transaction",
44
44
  :created_at => Time.utc(2009, 2, 9, 12, 59, 59),
45
+ :installment_count => nil,
45
46
  :order_id => nil,
46
47
  :purchase_order_number => "po",
47
48
  :payment_instrument_subtype => "Visa",
@@ -319,6 +320,8 @@ describe Braintree::Dispute do
319
320
 
320
321
  dispute.transaction.amount.should == 31.00
321
322
  dispute.transaction.id.should == "open_disputed_transaction"
323
+ dispute.transaction.created_at.should == Time.utc(2009, 2, 9, 12, 59, 59)
324
+ dispute.transaction.installment_count.should == nil
322
325
  dispute.transaction.order_id.should == nil
323
326
  dispute.transaction.purchase_order_number.should == "po"
324
327
  dispute.transaction.payment_instrument_subtype.should == "Visa"
@@ -32,5 +32,19 @@ describe Braintree::LocalPaymentCompleted do
32
32
  local_payment_completed.transaction.order_id.should eq("an-order-id")
33
33
  local_payment_completed.transaction.status.should eq(Braintree::Transaction::Status::Authorized)
34
34
  end
35
+
36
+ it "initializes the object with the appropriate attributes set if no transaction is provided" do
37
+ params = {
38
+ payment_id: "a-payment-id",
39
+ payer_id: "a-payer-id",
40
+ payment_method_nonce: "a-nonce",
41
+ }
42
+ local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
43
+
44
+ local_payment_completed.payment_id.should eq("a-payment-id")
45
+ local_payment_completed.payer_id.should eq("a-payer-id")
46
+ local_payment_completed.payment_method_nonce.should eq("a-nonce")
47
+ local_payment_completed.transaction.should be_nil
48
+ end
35
49
  end
36
50
  end
@@ -12,6 +12,7 @@ describe Braintree::ThreeDSecureInfo do
12
12
  :eci_flag => "06",
13
13
  :three_d_secure_version => "1.0.2",
14
14
  :ds_transaction_id => "dstrxid",
15
+ :three_d_secure_authentication_id => "auth_id",
15
16
  )
16
17
  }
17
18
 
@@ -26,12 +27,13 @@ describe Braintree::ThreeDSecureInfo do
26
27
  three_d_secure_info.eci_flag.should == "06"
27
28
  three_d_secure_info.three_d_secure_version.should == "1.0.2"
28
29
  three_d_secure_info.ds_transaction_id.should == "dstrxid"
30
+ three_d_secure_info.three_d_secure_authentication_id.should == "auth_id"
29
31
  end
30
32
  end
31
33
 
32
34
  describe "inspect" do
33
35
  it "prints the attributes" do
34
- three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo enrolled: "Y", liability_shifted: true, liability_shift_possible: true, status: "authenticate_successful", cavv: "cavvvalue", xid: "xidvalue", eci_flag: "06", three_d_secure_version: "1.0.2", ds_transaction_id: "dstrxid">)
36
+ three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo enrolled: "Y", liability_shifted: true, liability_shift_possible: true, status: "authenticate_successful", cavv: "cavvvalue", xid: "xidvalue", eci_flag: "06", three_d_secure_version: "1.0.2", ds_transaction_id: "dstrxid", three_d_secure_authentication_id: "auth_id">)
35
37
  end
36
38
  end
37
39
 
@@ -0,0 +1,57 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::PayPalDetails do
4
+ describe "initialize" do
5
+ it "sets all fields" do
6
+ details = Braintree::Transaction::PayPalDetails.new(
7
+ :authorization_id => "id",
8
+ :capture_id => "capture-id",
9
+ :custom_field => "custom-field",
10
+ :debug_id => "debug-id",
11
+ :description => "description",
12
+ :image_url => "www.image.com",
13
+ :implicitly_vaulted_payment_method_global_id => "global-id",
14
+ :implicitly_vaulted_payment_method_token => "payment-method-token",
15
+ :payee_email => "payee@example.com",
16
+ :payee_id => "payee-id",
17
+ :payer_email => "payer@example.com",
18
+ :payer_first_name => "Grace",
19
+ :payer_id => "payer-id",
20
+ :payer_last_name => "Hopper",
21
+ :payer_status =>"status",
22
+ :payment_id => "payment-id",
23
+ :refund_from_transaction_fee_amount => "1.00",
24
+ :refund_from_transaction_fee_currency_iso_code => "123",
25
+ :refund_id => "refund-id",
26
+ :seller_protection_status => "seller-protection-status",
27
+ :token => "token",
28
+ :transaction_fee_amount => "2.00",
29
+ :transaction_fee_currency_iso_code => "123"
30
+ )
31
+
32
+ expect(details.authorization_id).to eq("id")
33
+ expect(details.capture_id).to eq("capture-id")
34
+ expect(details.custom_field).to eq("custom-field")
35
+ expect(details.debug_id).to eq("debug-id")
36
+ expect(details.description).to eq("description")
37
+ expect(details.image_url).to eq("www.image.com")
38
+ expect(details.implicitly_vaulted_payment_method_global_id).to eq("global-id")
39
+ expect(details.implicitly_vaulted_payment_method_token).to eq("payment-method-token")
40
+ expect(details.payee_email).to eq("payee@example.com")
41
+ expect(details.payee_id).to eq("payee-id")
42
+ expect(details.payer_email).to eq("payer@example.com")
43
+ expect(details.payer_first_name).to eq("Grace")
44
+ expect(details.payer_id).to eq("payer-id")
45
+ expect(details.payer_last_name).to eq("Hopper")
46
+ expect(details.payer_status).to eq("status")
47
+ expect(details.payment_id).to eq("payment-id")
48
+ expect(details.refund_from_transaction_fee_amount).to eq("1.00")
49
+ expect(details.refund_from_transaction_fee_currency_iso_code).to eq("123")
50
+ expect(details.refund_id).to eq("refund-id")
51
+ expect(details.seller_protection_status).to eq("seller-protection-status")
52
+ expect(details.token).to eq("token")
53
+ expect(details.transaction_fee_amount).to eq("2.00")
54
+ expect(details.transaction_fee_currency_iso_code).to eq("123")
55
+ end
56
+ end
57
+ end
@@ -276,16 +276,18 @@ describe Braintree::Transaction do
276
276
  end
277
277
 
278
278
  describe "inspect" do
279
- it "includes the id, type, amount, and status first" do
279
+ it "includes the id, type, amount, status, and processed_with_network_token?" do
280
280
  transaction = Braintree::Transaction._new(
281
281
  :gateway,
282
282
  :id => "1234",
283
283
  :type => "sale",
284
284
  :amount => "100.00",
285
- :status => Braintree::Transaction::Status::Authorized
285
+ :status => Braintree::Transaction::Status::Authorized,
286
+ :processed_with_network_token => false,
286
287
  )
287
288
  output = transaction.inspect
288
289
  output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
290
+ output.should include(%Q(processed_with_network_token?: false))
289
291
  end
290
292
  end
291
293
 
@@ -394,4 +396,16 @@ describe Braintree::Transaction do
394
396
  )
395
397
  end
396
398
  end
399
+
400
+ describe "processed_with_network_token?" do
401
+ it "is true if the transaction was processed with a network token" do
402
+ transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => true)
403
+ transaction.processed_with_network_token?.should == true
404
+ end
405
+
406
+ it "is false if the transaction was not processed with a network token" do
407
+ transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => false)
408
+ transaction.processed_with_network_token?.should == false
409
+ end
410
+ end
397
411
  end
@@ -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.100.0
4
+ version: 2.104.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-28 00:00:00.000000000 Z
11
+ date: 2020-10-12 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
@@ -281,6 +282,7 @@ files:
281
282
  - spec/unit/braintree/transaction/credit_card_details_spec.rb
282
283
  - spec/unit/braintree/transaction/customer_details_spec.rb
283
284
  - spec/unit/braintree/transaction/deposit_details_spec.rb
285
+ - spec/unit/braintree/transaction/paypal_details_spec.rb
284
286
  - spec/unit/braintree/transaction_search_spec.rb
285
287
  - spec/unit/braintree/transaction_spec.rb
286
288
  - spec/unit/braintree/transparent_redirect_spec.rb
@@ -320,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
320
322
  - !ruby/object:Gem::Version
321
323
  version: '0'
322
324
  requirements: []
323
- rubygems_version: 3.0.6
325
+ rubygems_version: 3.0.8
324
326
  signing_key:
325
327
  specification_version: 4
326
328
  summary: Braintree Gateway Ruby Client Library