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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a83d6966dbe837625c68efa0fdee683820705fba7c4c1f65118892d61ea2261b
4
- data.tar.gz: f947bda53f860763dc3c57080ded11b1823e9c48e71efb05a89bb0490e7dad79
3
+ metadata.gz: d00fc1e35be1af3de05492fc2300a27ff643adec2d6c600088240c54f3ce59cf
4
+ data.tar.gz: 5c8d2d3aa4e16d587dd83cda3aa5d5f0cda4d17414557564a0754857f4ca706b
5
5
  SHA512:
6
- metadata.gz: f9a82a773ef66320358e028dbb9a403f6bcc97d7c32d727bff0b00a2936ab54ae8bbfba201024a7e8d5956ef17be0247b61f0e8e3cc23aecb819a5e77d833a9a
7
- data.tar.gz: 21a069ff7615e48429c6882ed354334f37fd7e0600e6696b97b000178a03531955d6156dcd77b3927bc2d35a144ecafa07d65d2b6d9566d5202630bfac62cb37
6
+ metadata.gz: b289dbe733557dd65754f36c2e8e592160619d3ea0222e3d645cbea2711752933f9b403140eb3b666531b0cb2372a58fc45f5286e37de111d2fb041d87f41d2a
7
+ data.tar.gz: 4cdc5ed40d74adfd3d6b6cb3ad622670200f6c60bc9a5314c457e8bfb886265284ff8d62645ffa88d82f7bec6b10816e3919959e527238640e3f932b2b57b821
@@ -10,6 +10,7 @@ module Braintree
10
10
  All = constants.map { |c| const_get(c) }
11
11
  end
12
12
 
13
+ attr_reader :billing_address
13
14
  attr_reader :bin
14
15
  attr_reader :card_type
15
16
  attr_reader :cardholder_name
@@ -39,6 +40,7 @@ module Braintree
39
40
  def initialize(gateway, attributes) # :nodoc:
40
41
  @gateway = gateway
41
42
  set_instance_variables_from_hash(attributes)
43
+ @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
42
44
  @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
43
45
  end
44
46
 
@@ -19,6 +19,7 @@ module Braintree
19
19
  attr_reader :paypal_accounts
20
20
  attr_reader :phone
21
21
  attr_reader :samsung_pay_cards
22
+ attr_reader :sepa_direct_debit_accounts
22
23
  attr_reader :tax_identifiers
23
24
  attr_reader :updated_at
24
25
  attr_reader :us_bank_accounts
@@ -89,6 +90,7 @@ module Braintree
89
90
  @venmo_accounts = (@venmo_accounts || []).map { |pm| VenmoAccount._new gateway, pm }
90
91
  @us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm }
91
92
  @visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm }
93
+ @sepa_direct_debit_accounts = (@sepa_debit_accounts || []).map { |pm| SepaDirectDebitAccount._new gateway, pm }
92
94
  @samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm }
93
95
  @addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
94
96
  @tax_identifiers = (@tax_identifiers || []).map { |addr| TaxIdentifier._new gateway, addr }
@@ -121,7 +123,8 @@ module Braintree
121
123
  @venmo_accounts +
122
124
  @us_bank_accounts +
123
125
  @visa_checkout_cards +
124
- @samsung_pay_cards
126
+ @samsung_pay_cards +
127
+ @sepa_direct_debit_accounts
125
128
  end
126
129
 
127
130
  def inspect # :nodoc:
@@ -21,6 +21,7 @@ module Braintree
21
21
  attr_reader :merchant_account_id
22
22
  attr_reader :original_dispute_id
23
23
  attr_reader :paypal_messages
24
+ attr_reader :pre_dispute_program
24
25
  attr_reader :processor_comments
25
26
  attr_reader :protection_level
26
27
  attr_reader :reason
@@ -37,6 +38,7 @@ module Braintree
37
38
 
38
39
  module Status
39
40
  Accepted = "accepted"
41
+ AutoAccepted = "auto_accepted"
40
42
  Disputed = "disputed"
41
43
  Expired = "expired"
42
44
  Open = "open"
@@ -86,6 +88,13 @@ module Braintree
86
88
  All = constants.map { |c| const_get(c) }
87
89
  end
88
90
 
91
+ module PreDisputeProgram
92
+ None = "none"
93
+ VisaRdr = "visa_rdr"
94
+
95
+ All = constants.map { |c| const_get(c) }
96
+ end
97
+
89
98
  class << self
90
99
  protected :new
91
100
  def _new(*args) # :nodoc:
@@ -13,6 +13,7 @@ module Braintree
13
13
  multiple_value_field :protection_level, :allows => Dispute::ProtectionLevel::All
14
14
  multiple_value_field :kind, :allows => Dispute::Kind::All
15
15
  multiple_value_field :merchant_account_id
16
+ multiple_value_field :pre_dispute_program, :allows => Dispute::PreDisputeProgram::All
16
17
  multiple_value_field :reason, :allows => Dispute::Reason::All
17
18
  multiple_value_field :reason_code
18
19
  multiple_value_field :status, :allows => Dispute::Status::All
@@ -203,6 +203,12 @@ module Braintree
203
203
  TokenIsInUse = "92906"
204
204
  end
205
205
 
206
+ module SepaDirectDebitAccount
207
+ SepaDebitAccountPaymentMethodMandateTypeIsNotSupported = "87115"
208
+ SepaDebitAccountPaymentMethodCustomerIdIsInvalid = "87116"
209
+ SepaDebitAccountPaymentMethodCustomerIdIsRequired = "87117"
210
+ end
211
+
206
212
  module Subscription
207
213
  BillingDayOfMonthCannotBeUpdated = "91918"
208
214
  BillingDayOfMonthIsInvalid = "91914"
@@ -78,6 +78,10 @@ module Braintree
78
78
  UsBankAccountGateway.new(self)
79
79
  end
80
80
 
81
+ def sepa_direct_debit_account
82
+ SepaDirectDebitAccountGateway.new(self)
83
+ end
84
+
81
85
  def merchant
82
86
  MerchantGateway.new(self)
83
87
  end
@@ -1,14 +1,15 @@
1
1
  module Braintree
2
2
  module PaymentInstrumentType
3
- PayPalAccount = "paypal_account"
4
- CreditCard = "credit_card"
5
3
  ApplePayCard = "apple_pay_card"
4
+ CreditCard = "credit_card"
6
5
  GooglePayCard = "android_pay_card"
7
- VenmoAccount = "venmo_account"
8
- UsBankAccount = "us_bank_account"
9
- VisaCheckoutCard = "visa_checkout_card"
10
- SamsungPayCard = "samsung_pay_card"
11
6
  LocalPayment = "local_payment"
7
+ PayPalAccount = "paypal_account"
12
8
  PayPalHere = "paypal_here"
9
+ SamsungPayCard = "samsung_pay_card"
10
+ SepaDirectDebitAccount = "sepa_debit_account"
11
+ UsBankAccount = "us_bank_account"
12
+ VenmoAccount = "venmo_account"
13
+ VisaCheckoutCard = "visa_checkout_card"
13
14
  end
14
15
  end
@@ -50,6 +50,8 @@ module Braintree
50
50
  GooglePayCard._new(@gateway, response[:android_pay_card])
51
51
  elsif response.has_key?(:venmo_account)
52
52
  VenmoAccount._new(@gateway, response[:venmo_account])
53
+ elsif response.has_key?(:sepa_debit_account)
54
+ SepaDirectDebitAccount._new(@gateway, response[:sepa_debit_account])
53
55
  else
54
56
  UnknownPaymentMethod._new(@gateway, response)
55
57
  end
@@ -9,12 +9,14 @@ module Braintree
9
9
  attr_reader :is_network_tokenized
10
10
  attr_reader :last_two
11
11
  attr_reader :payer_info
12
+ attr_reader :sepa_direct_debit_account_nonce_details
12
13
 
13
14
  alias_method :is_network_tokenized?, :is_network_tokenized
14
15
 
15
16
  def initialize(attributes)
16
17
  set_instance_variables_from_hash attributes unless attributes.nil?
17
18
  @payer_info = PaymentMethodNonceDetailsPayerInfo.new(attributes[:payer_info]) if attributes[:payer_info]
19
+ @sepa_direct_debit_account_nonce_details = ::Braintree::SepaDirectDebitAccountNonceDetails.new(attributes)
18
20
  end
19
21
 
20
22
  def inspect
@@ -26,6 +28,7 @@ module Braintree
26
28
  :is_network_tokenized,
27
29
  :last_two,
28
30
  :payer_info,
31
+ :sepa_direct_debit_account_nonce_details,
29
32
  ]
30
33
 
31
34
  formatted_attrs = attr_order.map do |attr|
@@ -18,6 +18,8 @@ module Braintree
18
18
  VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
19
19
  elsif attributes[:samsung_pay_card]
20
20
  SamsungPayCard._new(gateway, attributes[:samsung_pay_card])
21
+ elsif attributes[:sepa_debit_account]
22
+ SepaDirectDebitAccount._new(gateway, attributes[:sepa_debit_account])
21
23
  else
22
24
  UnknownPaymentMethod._new(gateway, attributes)
23
25
  end
@@ -0,0 +1,58 @@
1
+ module Braintree
2
+ class SepaDirectDebitAccount
3
+ include BaseModule
4
+
5
+ attr_reader :bank_reference_token
6
+ attr_reader :created_at
7
+ attr_reader :customer_id
8
+ attr_reader :customer_global_id
9
+ attr_reader :default
10
+ attr_reader :global_id
11
+ attr_reader :image_url
12
+ attr_reader :last_4
13
+ attr_reader :mandate_type
14
+ attr_reader :merchant_or_partner_customer_id
15
+ attr_reader :token
16
+ attr_reader :updated_at
17
+ attr_reader :view_mandate_url
18
+
19
+ def initialize(gateway, attributes) # :nodoc:
20
+ @gateway = gateway
21
+ set_instance_variables_from_hash(attributes)
22
+ end
23
+
24
+ def default?
25
+ @default
26
+ end
27
+
28
+ class << self
29
+ protected :new
30
+ end
31
+
32
+ def self._new(*args) # :nodoc:
33
+ self.new(*args)
34
+ end
35
+
36
+ def self.find(*args)
37
+ Configuration.gateway.sepa_direct_debit_account.find(*args)
38
+ end
39
+
40
+ def self.delete(*args)
41
+ Configuration.gateway.sepa_direct_debit_account.delete(*args)
42
+ end
43
+
44
+ def self.sale(token, transaction_attributes)
45
+ options = transaction_attributes[:options] || {}
46
+ Configuration.gateway.transaction.sale(
47
+ transaction_attributes.merge(
48
+ :payment_method_token => token,
49
+ :options => options.merge(:submit_for_settlement => true),
50
+ ),
51
+ )
52
+ end
53
+
54
+ def self.sale!(token, transaction_attributes)
55
+ return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,25 @@
1
+ module Braintree
2
+ class SepaDirectDebitAccountGateway
3
+ def initialize(gateway)
4
+ @gateway = gateway
5
+ @config = gateway.config
6
+ @config.assert_has_access_token_or_keys
7
+ end
8
+
9
+ def find(token)
10
+ raise ArgumentError if token.nil? || token.to_s.strip == ""
11
+ response = @config.http.get("#{@config.base_merchant_path}/payment_methods/sepa_debit_account/#{token}")
12
+ SepaDirectDebitAccount._new(@gateway, response[:sepa_debit_account])
13
+ rescue NotFoundError
14
+ raise NotFoundError, "sepa direct debit account with token #{token.inspect} not found"
15
+ end
16
+
17
+ def delete(token)
18
+ raise ArgumentError if token.nil? || token.to_s.strip == ""
19
+ @config.http.delete("#{@config.base_merchant_path}/payment_methods/sepa_debit_account/#{token}")
20
+ SuccessfulResult.new
21
+ rescue NotFoundError
22
+ raise NotFoundError, "sepa direct debit account with token #{token.inspect} not found"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ module Braintree
2
+ class SepaDirectDebitAccountNonceDetails# :nodoc:
3
+ include BaseModule
4
+
5
+ attr_reader :bank_reference_token
6
+ attr_reader :last_4
7
+ attr_reader :mandate_type
8
+ attr_reader :merchant_or_partner_customer_id
9
+
10
+ def initialize(attributes)
11
+ set_instance_variables_from_hash attributes unless attributes.nil?
12
+ end
13
+
14
+ def inspect
15
+ attr_order = [
16
+ :bank_reference_token,
17
+ :last_4,
18
+ :mandate_type,
19
+ :merchant_or_partner_customer_id,
20
+ ]
21
+
22
+ formatted_attrs = attr_order.map do |attr|
23
+ "#{attr}: #{send(attr).inspect}"
24
+ end
25
+ "#<SepaDirectDebitAccountNonceDetails#{formatted_attrs.join(", ")}>"
26
+ end
27
+ end
28
+ end
@@ -4,6 +4,7 @@ module Braintree
4
4
  Transactable = "fake-valid-nonce"
5
5
  Consumed = "fake-consumed-nonce"
6
6
  PayPalOneTimePayment = "fake-paypal-one-time-nonce"
7
+ #NEXT_MAJOR_VERSION - no longer supported in the Gateway, remove this constant
7
8
  PayPalFuturePayment = "fake-paypal-future-nonce"
8
9
  PayPalBillingAgreement = "fake-paypal-billing-agreement-nonce"
9
10
  LocalPayment = "fake-local-payment-method-nonce"
@@ -68,6 +69,7 @@ module Braintree
68
69
  SamsungPayDiscover = "tokensam_fake_discover"
69
70
  SamsungPayMasterCard = "tokensam_fake_mastercard"
70
71
  SamsungPayVisa = "tokensam_fake_visa"
72
+ SepaDirectDebit = "fake-sepa-direct-debit-nonce"
71
73
  end
72
74
  end
73
75
  end
@@ -0,0 +1,27 @@
1
+ module Braintree
2
+ class Transaction
3
+ class SepaDirectDebitAccountDetails # :nodoc:
4
+ include BaseModule
5
+
6
+ attr_reader :bank_reference_token
7
+ attr_reader :capture_id
8
+ attr_reader :debug_id
9
+ attr_reader :global_id
10
+ attr_reader :last_4
11
+ attr_reader :mandate_type
12
+ attr_reader :merchant_or_partner_customer_id
13
+ attr_reader :paypal_v2_order_id
14
+ attr_reader :refund_from_transaction_fee_amount
15
+ attr_reader :refund_from_transaction_fee_currency_iso_code
16
+ attr_reader :refund_id
17
+ attr_reader :settlement_type
18
+ attr_reader :token
19
+ attr_reader :transaction_fee_amount
20
+ attr_reader :transaction_fee_currency_iso_code
21
+
22
+ def initialize(attributes)
23
+ set_instance_variables_from_hash attributes unless attributes.nil?
24
+ end
25
+ end
26
+ end
27
+ end
@@ -24,6 +24,7 @@ module Braintree
24
24
  AVSAndCVV = "avs_and_cvv"
25
25
  CVV = "cvv"
26
26
  Duplicate = "duplicate"
27
+ ExcessiveRetry = "excessive_retry"
27
28
  Fraud = "fraud"
28
29
  RiskThreshold = "risk_threshold"
29
30
  ThreeDSecure = "three_d_secure"
@@ -153,6 +154,8 @@ module Braintree
153
154
  attr_reader :samsung_pay_card_details
154
155
  attr_reader :sca_exemption_requested
155
156
  attr_reader :service_fee_amount
157
+ attr_reader :sepa_direct_debit_account_details
158
+ attr_reader :sepa_direct_debit_return_code
156
159
  attr_reader :settlement_batch_id
157
160
  attr_reader :shipping_amount
158
161
  attr_reader :shipping_details
@@ -307,6 +310,7 @@ module Braintree
307
310
  @paypal_here_details = PayPalHereDetails.new(@paypal_here)
308
311
  @samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
309
312
  @sca_exemption_requested = attributes[:sca_exemption_requested]
313
+ @sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail)
310
314
  @service_fee_amount = Util.to_big_decimal(service_fee_amount)
311
315
  @shipping_details = AddressDetails.new(@shipping)
312
316
  @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
@@ -28,6 +28,7 @@ module Braintree
28
28
  :paypal_authorization_id,
29
29
  :paypal_payer_email,
30
30
  :processor_authorization_code,
31
+ :sepa_debit_paypal_v2_order_id,
31
32
  :settlement_batch_id,
32
33
  :shipping_company,
33
34
  :shipping_country_name,
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 9
4
+ Minor = 10
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -19,6 +19,7 @@ module Braintree
19
19
  DisputeLost = "dispute_lost"
20
20
  DisputeWon = "dispute_won"
21
21
  DisputeAccepted = "dispute_accepted"
22
+ DisputeAutoAccepted = "dispute_auto_accepted"
22
23
  DisputeDisputed = "dispute_disputed"
23
24
  DisputeExpired = "dispute_expired"
24
25
 
@@ -42,6 +42,8 @@ module Braintree
42
42
  _dispute_won_sample_xml(id)
43
43
  when Braintree::WebhookNotification::Kind::DisputeAccepted
44
44
  _dispute_accepted_sample_xml(id)
45
+ when Braintree::WebhookNotification::Kind::DisputeAutoAccepted
46
+ _dispute_auto_accepted_sample_xml(id)
45
47
  when Braintree::WebhookNotification::Kind::DisputeDisputed
46
48
  _dispute_disputed_sample_xml(id)
47
49
  when Braintree::WebhookNotification::Kind::DisputeExpired
@@ -337,6 +339,14 @@ module Braintree
337
339
  end
338
340
  end
339
341
 
342
+ def _dispute_auto_accepted_sample_xml(id)
343
+ if id == "legacy_dispute_id"
344
+ _old_dispute_auto_accepted_sample_xml(id)
345
+ else
346
+ _new_dispute_auto_accepted_sample_xml(id)
347
+ end
348
+ end
349
+
340
350
  def _dispute_disputed_sample_xml(id)
341
351
  if id == "legacy_dispute_id"
342
352
  _old_dispute_disputed_sample_xml(id)
@@ -434,6 +444,26 @@ module Braintree
434
444
  XML
435
445
  end
436
446
 
447
+ def _old_dispute_auto_accepted_sample_xml(id)
448
+ <<-XML
449
+ <dispute>
450
+ <amount>100.00</amount>
451
+ <currency-iso-code>USD</currency-iso-code>
452
+ <received-date type="date">2014-03-01</received-date>
453
+ <reply-by-date type="date">2014-03-21</reply-by-date>
454
+ <kind>chargeback</kind>
455
+ <status>auto_accepted</status>
456
+ <reason>fraud</reason>
457
+ <id>#{id}</id>
458
+ <transaction>
459
+ <id>#{id}</id>
460
+ <amount>100.00</amount>
461
+ </transaction>
462
+ <date-opened type=\"date\">2014-03-21</date-opened>
463
+ </dispute>
464
+ XML
465
+ end
466
+
437
467
  def _old_dispute_disputed_sample_xml(id)
438
468
  <<-XML
439
469
  <dispute>
@@ -685,6 +715,52 @@ module Braintree
685
715
  XML
686
716
  end
687
717
 
718
+ def _new_dispute_auto_accepted_sample_xml(id)
719
+ <<-XML
720
+ <dispute>
721
+ <id>#{id}</id>
722
+ <amount>100.00</amount>
723
+ <amount-disputed>100.00</amount-disputed>
724
+ <amount-won>95.00</amount-won>
725
+ <case-number>CASE-12345</case-number>
726
+ <created-at type="datetime">2017-06-16T20:44:41Z</created-at>
727
+ <currency-iso-code>USD</currency-iso-code>
728
+ <forwarded-comments nil="true"/>
729
+ <kind>chargeback</kind>
730
+ <merchant-account-id>ytnlulaloidoqwvzxjrdqputg</merchant-account-id>
731
+ <reason>fraud</reason>
732
+ <reason-code nil="true"/>
733
+ <reason-description nil="true"/>
734
+ <received-date type="date">2016-02-15</received-date>
735
+ <reference-number>REF-9876</reference-number>
736
+ <reply-by-date type="date">2016-02-22</reply-by-date>
737
+ <status>auto_accepted</status>
738
+ <updated-at type="datetime">2017-06-16T20:44:41Z</updated-at>
739
+ <original-dispute-id>9qde5qgp</original-dispute-id>
740
+ <status-history type="array">
741
+ <status-history>
742
+ <status>open</status>
743
+ <timestamp type="datetime">2017-06-16T20:44:41Z</timestamp>
744
+ </status-history>
745
+ <status-history>
746
+ <status>auto_accepted</status>
747
+ <timestamp type="datetime">2017-06-25T20:50:55Z</timestamp>
748
+ </status-history>
749
+ </status-history>
750
+ <evidence type="array"/>
751
+ <transaction>
752
+ <id>#{id}</id>
753
+ <amount>100.00</amount>
754
+ <created-at>2017-06-21T20:44:41Z</created-at>
755
+ <order-id nil="true"/>
756
+ <purchase-order-number nil="true"/>
757
+ <payment-instrument-subtype>Visa</payment-instrument-subtype>
758
+ </transaction>
759
+ <date-opened type=\"date\">2014-03-21</date-opened>
760
+ </dispute>
761
+ XML
762
+ end
763
+
688
764
  def _new_dispute_disputed_sample_xml(id)
689
765
  <<-XML
690
766
  <dispute>
data/lib/braintree.rb CHANGED
@@ -124,6 +124,9 @@ require "braintree/us_bank_account_verification_gateway"
124
124
  require "braintree/us_bank_account_verification_search"
125
125
  require "braintree/us_bank_account_gateway"
126
126
  require "braintree/transaction/us_bank_account_details"
127
+ require "braintree/sepa_direct_debit_account"
128
+ require "braintree/sepa_direct_debit_account_gateway"
129
+ require "braintree/sepa_direct_debit_account_nonce_details"
127
130
  require "braintree/sha256_digest"
128
131
  require "braintree/signature_service"
129
132
  require "braintree/subscription"
@@ -150,6 +153,7 @@ require "braintree/transaction/installment/adjustment"
150
153
  require "braintree/transaction/paypal_details"
151
154
  require "braintree/transaction/paypal_here_details"
152
155
  require "braintree/transaction/samsung_pay_card_details"
156
+ require "braintree/transaction/sepa_direct_debit_account_details"
153
157
  require "braintree/transaction/status_details"
154
158
  require "braintree/transaction/subscription_details"
155
159
  require "braintree/transaction/venmo_account_details"
@@ -1754,7 +1754,7 @@ describe Braintree::Customer do
1754
1754
  context "future" do
1755
1755
  it "creates a customer with a future paypal account" do
1756
1756
  result = Braintree::Customer.create(
1757
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
1757
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
1758
1758
  )
1759
1759
 
1760
1760
  result.should be_success
@@ -98,13 +98,37 @@ describe Braintree::Dispute, "search" do
98
98
  Braintree::Dispute::ChargebackProtectionLevel::Effortless
99
99
  ]
100
100
  end
101
- expect(collection.disputes.count).to eq(1)
102
- dispute = collection.disputes.first
101
+ expect(collection.disputes.count).to be > 0
103
102
 
104
103
  # NEXT_MAJOR_VERSION Remove this assertion when chargeback_protection_level is removed from the SDK
105
- expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
106
- expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
107
- expect(dispute.reason).to eq(Braintree::Dispute::Reason::Fraud)
104
+ collection.disputes.each do |dispute|
105
+ expect(dispute.chargeback_protection_level).to eq(Braintree::Dispute::ChargebackProtectionLevel::Effortless)
106
+ expect(dispute.protection_level).to eq(Braintree::Dispute::ProtectionLevel::EffortlessCBP)
107
+ expect(dispute.reason).to eq(Braintree::Dispute::Reason::Fraud)
108
+ end
109
+ end
110
+
111
+ context "pre-dispute program" do
112
+ it "correctly returns disputes by pre-dispute program" do
113
+ collection = Braintree::Dispute.search do |search|
114
+ search.pre_dispute_program.in [
115
+ Braintree::Dispute::PreDisputeProgram::VisaRdr
116
+ ]
117
+ end
118
+
119
+ expect(collection.disputes.count).to eq(1)
120
+ dispute = collection.disputes.first
121
+ expect(dispute.pre_dispute_program).to eq(Braintree::Dispute::PreDisputeProgram::VisaRdr)
122
+ end
123
+
124
+ it "correctly returns disputes with no pre-dispute program" do
125
+ collection = Braintree::Dispute.search do |search|
126
+ search.pre_dispute_program.is Braintree::Dispute::PreDisputeProgram::None
127
+ end
128
+
129
+ expect(collection.disputes.count).to be > 1
130
+ expect(collection.disputes.map(&:pre_dispute_program).uniq).to eq([Braintree::Dispute::PreDisputeProgram::None])
131
+ end
108
132
  end
109
133
 
110
134
  it "correctly returns disputes by effective_date range" do
@@ -267,7 +267,7 @@ describe Braintree::PayPalAccount do
267
267
  context "self.sale" do
268
268
  it "creates a transaction using a paypal account and returns a result object" do
269
269
  customer = Braintree::Customer.create!(
270
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
270
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
271
271
  )
272
272
 
273
273
  result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
@@ -283,7 +283,7 @@ describe Braintree::PayPalAccount do
283
283
  context "self.sale!" do
284
284
  it "creates a transaction using a paypal account and returns a transaction" do
285
285
  customer = Braintree::Customer.create!(
286
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
286
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
287
287
  )
288
288
 
289
289
  transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")