braintree 4.9.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/apple_pay_card.rb +2 -0
  3. data/lib/braintree/customer.rb +4 -1
  4. data/lib/braintree/dispute.rb +9 -0
  5. data/lib/braintree/dispute_search.rb +1 -0
  6. data/lib/braintree/error_codes.rb +6 -0
  7. data/lib/braintree/gateway.rb +4 -0
  8. data/lib/braintree/payment_instrument_type.rb +7 -6
  9. data/lib/braintree/payment_method_gateway.rb +2 -0
  10. data/lib/braintree/payment_method_nonce_details.rb +3 -0
  11. data/lib/braintree/payment_method_parser.rb +2 -0
  12. data/lib/braintree/sepa_direct_debit_account.rb +58 -0
  13. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  14. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  15. data/lib/braintree/test/nonce.rb +2 -0
  16. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  17. data/lib/braintree/transaction.rb +4 -0
  18. data/lib/braintree/transaction_search.rb +1 -0
  19. data/lib/braintree/version.rb +1 -1
  20. data/lib/braintree/webhook_notification.rb +1 -0
  21. data/lib/braintree/webhook_testing_gateway.rb +76 -0
  22. data/lib/braintree.rb +4 -0
  23. data/spec/integration/braintree/customer_spec.rb +1 -1
  24. data/spec/integration/braintree/dispute_search_spec.rb +29 -5
  25. data/spec/integration/braintree/paypal_account_spec.rb +2 -2
  26. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +176 -0
  27. data/spec/integration/braintree/subscription_spec.rb +1 -1
  28. data/spec/integration/braintree/transaction_search_spec.rb +34 -2
  29. data/spec/integration/braintree/transaction_spec.rb +35 -17
  30. data/spec/integration/spec_helper.rb +6 -0
  31. data/spec/unit/braintree/apple_pay_card_spec.rb +99 -11
  32. data/spec/unit/braintree/customer_spec.rb +11 -1
  33. data/spec/unit/braintree/dispute_search_spec.rb +1 -0
  34. data/spec/unit/braintree/dispute_spec.rb +8 -0
  35. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +9 -1
  36. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  37. data/spec/unit/braintree/sepa_debit_account_spec.rb +85 -0
  38. data/spec/unit/braintree/transaction/deposit_details_spec.rb +1 -1
  39. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  40. data/spec/unit/braintree/transaction_spec.rb +30 -0
  41. data/spec/unit/braintree/webhook_notification_spec.rb +16 -0
  42. metadata +11 -3
@@ -0,0 +1,85 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::SepaDirectDebitAccount do
4
+ describe "self.new" do
5
+ subject do
6
+ -> { described_class.new }
7
+ end
8
+
9
+ it "is protected" do
10
+ is_expected.to raise_error(NoMethodError, /protected method .new/)
11
+ end
12
+ end
13
+
14
+ describe "self._new" do
15
+ let(:params) do
16
+ {
17
+ bank_reference_token: "a-reference-token",
18
+ mandate_type: "ONE_OFF",
19
+ last_4: "4321",
20
+ merchant_or_partner_customer_id: "a-mp-customer-id",
21
+ customer_id: "a-customer-id",
22
+ customer_global_id: "a-customer-global-id",
23
+ default: true,
24
+ token: "a-token",
25
+ global_id: "a-global-id",
26
+ image_url: "a-image-url",
27
+ view_mandate_url: "a-view-mandate-url",
28
+ created_at: Time.now,
29
+ updated_at: Time.now,
30
+ }
31
+ end
32
+
33
+ subject do
34
+ described_class._new(:gateway, params)
35
+ end
36
+
37
+ it "initializes the object with the appropriate attributes set" do
38
+ is_expected.to have_attributes(**params)
39
+ end
40
+ end
41
+
42
+ describe "self.find" do
43
+ let(:token) { "token" }
44
+
45
+ subject do
46
+ described_class.find(token)
47
+ end
48
+
49
+ it "calls gateway find" do
50
+ expect_any_instance_of(Braintree::SepaDirectDebitAccountGateway).to receive(:find).with(token)
51
+ subject
52
+ end
53
+ end
54
+
55
+ describe "self.delete" do
56
+ let(:token) { "token" }
57
+
58
+ subject do
59
+ described_class.delete(token)
60
+ end
61
+
62
+ it "calls gateway delete" do
63
+ expect_any_instance_of(Braintree::SepaDirectDebitAccountGateway).to receive(:delete).with(token)
64
+ subject
65
+ end
66
+ end
67
+
68
+ describe "default?" do
69
+ subject do
70
+ described_class._new(:gateway, :default => default).default?
71
+ end
72
+
73
+ context "when sepa debit account is the default payment method for the customer" do
74
+ let(:default) { true }
75
+
76
+ it { is_expected.to be true }
77
+ end
78
+
79
+ context "when sepa debit account is not the default payment method for the customer" do
80
+ let(:default) { false }
81
+
82
+ it { is_expected.to be false }
83
+ end
84
+ end
85
+ end
@@ -4,7 +4,7 @@ describe Braintree::Transaction::DisbursementDetails do
4
4
  describe "valid?" do
5
5
  it "returns true if disbursement details are initialized" do
6
6
  details = Braintree::Transaction::DisbursementDetails.new(
7
- :disbursement_date => Date.new(2013, 4, 1),
7
+ :disbursement_date => Date.new(2013, 4, 1).to_s,
8
8
  )
9
9
  details.valid?.should == true
10
10
  end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::SepaDirectDebitAccountDetails do
4
+ describe "initialize" do
5
+ let(:params) do
6
+ {
7
+ bank_reference_token: "a-reference-token",
8
+ capture_id: "a-capture-id",
9
+ debug_id: "a-debug-id",
10
+ global_id: "a-global-id",
11
+ last_4: "1234",
12
+ mandate_type: "ONE_OFF",
13
+ merchant_or_partner_customer_id: "12312312343",
14
+ paypal_v2_order_id: "a-paypal-v2-order-id",
15
+ refund_from_transaction_fee_amount: "2.34",
16
+ refund_from_transaction_fee_currency_iso_code: "EUR",
17
+ refund_id: "a-refund-id",
18
+ settlement_type: "INSTANT",
19
+ token: "a-token",
20
+ transaction_fee_amount: "12.34",
21
+ transaction_fee_currency_iso_code: "EUR",
22
+ }
23
+ end
24
+
25
+ subject do
26
+ described_class.new(params)
27
+ end
28
+
29
+ it "sets all fields" do
30
+ is_expected.to have_attributes(**params)
31
+ end
32
+ end
33
+ end
@@ -255,6 +255,29 @@ describe Braintree::Transaction do
255
255
  expect(transaction.network_response_code).to eq("00")
256
256
  expect(transaction.network_response_text).to eq("Successful approval/completion or V.I.P. PIN verification is successful")
257
257
  end
258
+
259
+ it "accepts sepa_direct_debit_return_code" do
260
+ transaction = Braintree::Transaction._new(
261
+ :gateway,
262
+ :sepa_direct_debit_return_code => "AM04",
263
+ )
264
+ expect(transaction.sepa_direct_debit_return_code).to eq("AM04")
265
+ end
266
+
267
+ it "accepts sepa_direct_debit_account_details" do
268
+ transaction = Braintree::Transaction._new(
269
+ :gateway,
270
+ :id => "123",
271
+ :type => "sale",
272
+ :amount => "12.34",
273
+ :status => "settled",
274
+ :sepa_debit_account_detail => {
275
+ :token => "1234",
276
+ },
277
+ )
278
+ details = transaction.sepa_direct_debit_account_details
279
+ details.token.should == "1234"
280
+ end
258
281
  end
259
282
 
260
283
  describe "inspect" do
@@ -390,4 +413,11 @@ describe Braintree::Transaction do
390
413
  transaction.processed_with_network_token?.should == false
391
414
  end
392
415
  end
416
+
417
+ describe "gateway rejection reason" do
418
+ it "verifies excessive_retry mapping" do
419
+ transaction = Braintree::Transaction._new(:gateway, :gateway_rejection_reason => "excessive_retry")
420
+ transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry
421
+ end
422
+ end
393
423
  end
@@ -200,6 +200,22 @@ describe Braintree::WebhookNotification do
200
200
  dispute.kind.should == Braintree::Dispute::Kind::Chargeback
201
201
  end
202
202
 
203
+ it "builds a sample notification for a dispute auto_accepted webhook" do
204
+ sample_notification = Braintree::WebhookTesting.sample_notification(
205
+ Braintree::WebhookNotification::Kind::DisputeAutoAccepted,
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::DisputeAutoAccepted
212
+
213
+ dispute = notification.dispute
214
+ dispute.status.should == Braintree::Dispute::Status::AutoAccepted
215
+ dispute.id.should == dispute_id
216
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
217
+ end
218
+
203
219
  it "builds a sample notification for a dispute disputed webhook" do
204
220
  sample_notification = Braintree::WebhookTesting.sample_notification(
205
221
  Braintree::WebhookNotification::Kind::DisputeDisputed,
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: 4.9.0
4
+ version: 4.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2023-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -146,6 +146,9 @@ files:
146
146
  - lib/braintree/risk_data.rb
147
147
  - lib/braintree/risk_data/liability_shift.rb
148
148
  - lib/braintree/samsung_pay_card.rb
149
+ - lib/braintree/sepa_direct_debit_account.rb
150
+ - lib/braintree/sepa_direct_debit_account_gateway.rb
151
+ - lib/braintree/sepa_direct_debit_account_nonce_details.rb
149
152
  - lib/braintree/settlement_batch_summary.rb
150
153
  - lib/braintree/settlement_batch_summary_gateway.rb
151
154
  - lib/braintree/sha256_digest.rb
@@ -177,6 +180,7 @@ files:
177
180
  - lib/braintree/transaction/paypal_details.rb
178
181
  - lib/braintree/transaction/paypal_here_details.rb
179
182
  - lib/braintree/transaction/samsung_pay_card_details.rb
183
+ - lib/braintree/transaction/sepa_direct_debit_account_details.rb
180
184
  - lib/braintree/transaction/status_details.rb
181
185
  - lib/braintree/transaction/subscription_details.rb
182
186
  - lib/braintree/transaction/us_bank_account_details.rb
@@ -245,6 +249,7 @@ files:
245
249
  - spec/integration/braintree/paypal_account_spec.rb
246
250
  - spec/integration/braintree/plan_spec.rb
247
251
  - spec/integration/braintree/samsung_pay_card_spec.rb
252
+ - spec/integration/braintree/sepa_direct_debit_account_spec.rb
248
253
  - spec/integration/braintree/settlement_batch_summary_spec.rb
249
254
  - spec/integration/braintree/subscription_spec.rb
250
255
  - spec/integration/braintree/test/transaction_amounts_spec.rb
@@ -303,6 +308,8 @@ files:
303
308
  - spec/unit/braintree/resource_collection_spec.rb
304
309
  - spec/unit/braintree/risk_data/liability_shift.rb
305
310
  - spec/unit/braintree/risk_data_spec.rb
311
+ - spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb
312
+ - spec/unit/braintree/sepa_debit_account_spec.rb
306
313
  - spec/unit/braintree/sha256_digest_spec.rb
307
314
  - spec/unit/braintree/signature_service_spec.rb
308
315
  - spec/unit/braintree/subscription_search_spec.rb
@@ -314,6 +321,7 @@ files:
314
321
  - spec/unit/braintree/transaction/deposit_details_spec.rb
315
322
  - spec/unit/braintree/transaction/installment_spec.rb
316
323
  - spec/unit/braintree/transaction/paypal_details_spec.rb
324
+ - spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb
317
325
  - spec/unit/braintree/transaction_search_spec.rb
318
326
  - spec/unit/braintree/transaction_spec.rb
319
327
  - spec/unit/braintree/unknown_payment_method_spec.rb
@@ -354,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
354
362
  - !ruby/object:Gem::Version
355
363
  version: '0'
356
364
  requirements: []
357
- rubygems_version: 3.3.22
365
+ rubygems_version: 3.4.3
358
366
  signing_key:
359
367
  specification_version: 4
360
368
  summary: Braintree Ruby Server SDK