braintree 2.99.0 → 2.104.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) 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 +14 -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 -33
  13. data/lib/braintree/graphql_client.rb +7 -1
  14. data/lib/braintree/masterpass_card.rb +2 -0
  15. data/lib/braintree/payment_instrument_type.rb +2 -1
  16. data/lib/braintree/payment_method_gateway.rb +14 -0
  17. data/lib/braintree/payment_method_nonce.rb +2 -0
  18. data/lib/braintree/payment_method_nonce_gateway.rb +13 -2
  19. data/lib/braintree/payment_method_parser.rb +1 -0
  20. data/lib/braintree/risk_data.rb +4 -1
  21. data/lib/braintree/test/authentication_id.rb +21 -0
  22. data/lib/braintree/test/credit_card.rb +1 -0
  23. data/lib/braintree/test/nonce.rb +18 -0
  24. data/lib/braintree/three_d_secure_info.rb +2 -0
  25. data/lib/braintree/transaction.rb +15 -1
  26. data/lib/braintree/transaction/address_details.rb +11 -0
  27. data/lib/braintree/transaction/android_pay_details.rb +5 -0
  28. data/lib/braintree/transaction/apple_pay_details.rb +1 -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 +1 -1
  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 +135 -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 +437 -45
  47. data/spec/spec_helper.rb +1 -1
  48. data/spec/unit/braintree/credit_card_spec.rb +51 -3
  49. data/spec/unit/braintree/credit_card_verification_spec.rb +7 -0
  50. data/spec/unit/braintree/customer_spec.rb +28 -2
  51. data/spec/unit/braintree/dispute_spec.rb +3 -0
  52. data/spec/unit/braintree/three_d_secure_info_spec.rb +3 -1
  53. data/spec/unit/braintree/transaction/paypal_details_spec.rb +57 -0
  54. data/spec/unit/braintree/transaction_spec.rb +16 -2
  55. data/spec/unit/braintree/webhook_notification_spec.rb +48 -0
  56. metadata +5 -3
@@ -8,12 +8,23 @@ module Braintree
8
8
  @config.assert_has_access_token_or_keys
9
9
  end
10
10
 
11
- def create(payment_method_token)
12
- response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces")
11
+ def create(payment_method_token, args = { payment_method_nonce: {} })
12
+ Util.verify_keys(PaymentMethodNonceGateway._create_signature, args)
13
+
14
+ response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces", args)
13
15
  payment_method_nonce = PaymentMethodNonce._new(@gateway, response.fetch(:payment_method_nonce))
14
16
  SuccessfulResult.new(:payment_method_nonce => payment_method_nonce)
15
17
  end
16
18
 
19
+ def self._create_signature
20
+ [ {
21
+ :payment_method_nonce=> [
22
+ :merchant_account_id, :authentication_insight,
23
+ {:authentication_insight_options => [:amount, :recurring_customer_consent, :recurring_max_amount]}
24
+ ]
25
+ }]
26
+ end
27
+
17
28
  def create!(*args)
18
29
  return_object_or_raise(:payment_method_nonce) { create(*args) }
19
30
  end
@@ -13,6 +13,7 @@ module Braintree
13
13
  elsif attributes[:apple_pay_card]
14
14
  ApplePayCard._new(gateway, attributes[:apple_pay_card])
15
15
  elsif attributes[:android_pay_card]
16
+ # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
16
17
  AndroidPayCard._new(gateway, attributes[:android_pay_card])
17
18
  elsif attributes[:amex_express_checkout_card]
18
19
  AmexExpressCheckoutCard._new(gateway, attributes[:amex_express_checkout_card])
@@ -2,10 +2,13 @@ module Braintree
2
2
  class RiskData # :nodoc:
3
3
  include BaseModule
4
4
 
5
+ attr_reader :customer_device_id
6
+ attr_reader :customer_location_zip
7
+ attr_reader :customer_tenure
5
8
  attr_reader :decision
6
9
  attr_reader :device_data_captured
7
- attr_reader :id
8
10
  attr_reader :fraud_service_provider
11
+ attr_reader :id
9
12
 
10
13
  def initialize(attributes)
11
14
  set_instance_variables_from_hash attributes unless attributes.nil?
@@ -0,0 +1,21 @@
1
+ module Braintree
2
+ module Test
3
+ module AuthenticationId
4
+ ThreeDSecureVisaFullAuthentication = "fake-three-d-secure-visa-full-authentication-id"
5
+ ThreeDSecureVisaLookupTimeout = "fake-three-d-secure-visa-lookup-timeout-id"
6
+ ThreeDSecureVisaFailedSignature = "fake-three-d-secure-visa-failed-signature-id"
7
+ ThreeDSecureVisaFailedAuthentication = "fake-three-d-secure-visa-failed-authentication-id"
8
+ ThreeDSecureVisaAttemptsNonParticipating = "fake-three-d-secure-visa-attempts-non-participating-id"
9
+ ThreeDSecureVisaNoteEnrolled = "fake-three-d-secure-visa-not-enrolled-id"
10
+ ThreeDSecureVisaUnavailable = "fake-three-d-secure-visa-unavailable-id"
11
+ ThreeDSecureVisaMPILookupError = "fake-three-d-secure-visa-mpi-lookup-error-id"
12
+ ThreeDSecureVisaMPIAuthenticateError = "fake-three-d-secure-visa-mpi-authenticate-error-id"
13
+ ThreeDSecureVisaAuthenticationUnavailable = "fake-three-d-secure-visa-authentication-unavailable-id"
14
+ ThreeDSecureVisaBypassedAuthentication = "fake-three-d-secure-visa-bypassed-authentication-id"
15
+ ThreeDSecureTwoVisaSuccessfulFrictionlessAuthentication = "fake-three-d-secure-two-visa-successful-frictionless-authentication-id"
16
+ ThreeDSecureTwoVisaSuccessfulStepUpAuthentication = "fake-three-d-secure-two-visa-successful-step-up-authentication-id"
17
+ ThreeDSecureTwoVisaErrorOnLookup = "fake-three-d-secure-two-visa-error-on-lookup-id"
18
+ ThreeDSecureTwoVisaTimeoutOnLookup = "fake-three-d-secure-two-visa-timeout-on-lookup-id"
19
+ end
20
+ end
21
+ end
@@ -40,6 +40,7 @@ module Braintree
40
40
  VisaPrepaid = "4500600000000061"
41
41
 
42
42
  Fraud = "4000111111111511"
43
+ RiskThreshold = "4111130000000003"
43
44
 
44
45
  Visas = %w[4009348888881881 4012888888881881 4111111111111111 4000111111111115 4500600000000061]
45
46
  Unknowns = %w[1000000000000008]
@@ -13,14 +13,30 @@ module Braintree
13
13
  AbstractTransactable = "fake-abstract-transactable-nonce"
14
14
  Europe = "fake-europe-bank-account-nonce"
15
15
  Coinbase = "fake-coinbase-nonce"
16
+ # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
16
17
  AndroidPayDiscover = "fake-android-pay-discover-nonce"
17
18
  AndroidPayVisa = "fake-android-pay-visa-nonce"
18
19
  AndroidPayMasterCard = "fake-android-pay-mastercard-nonce"
19
20
  AndroidPayAmEx = "fake-android-pay-amex-nonce"
21
+ # NEXT_MAJOR_VERSION Remove AmexExpressCheckout test nonces
20
22
  AmexExpressCheckout = "fake-amex-express-checkout-nonce"
21
23
  VenmoAccount = "fake-venmo-account-nonce"
22
24
  VenmoAccountTokenIssuanceError = "fake-token-issuance-error-venmo-account-nonce"
23
25
  ThreeDSecureVisaFullAuthentication = "fake-three-d-secure-visa-full-authentication-nonce"
26
+ ThreeDSecureVisaLookupTimeout = "fake-three-d-secure-visa-lookup-timeout-nonce"
27
+ ThreeDSecureVisaFailedSignature = "fake-three-d-secure-visa-failed-signature-nonce"
28
+ ThreeDSecureVisaFailedAuthentication = "fake-three-d-secure-visa-failed-authentication-nonce"
29
+ ThreeDSecureVisaAttemptsNonParticipating = "fake-three-d-secure-visa-attempts-non-participating-nonce"
30
+ ThreeDSecureVisaNoteEnrolled = "fake-three-d-secure-visa-not-enrolled-nonce"
31
+ ThreeDSecureVisaUnavailable = "fake-three-d-secure-visa-unavailable-nonce"
32
+ ThreeDSecureVisaMPILookupError = "fake-three-d-secure-visa-mpi-lookup-error-nonce"
33
+ ThreeDSecureVisaMPIAuthenticateError = "fake-three-d-secure-visa-mpi-authenticate-error-nonce"
34
+ ThreeDSecureVisaAuthenticationUnavailable = "fake-three-d-secure-visa-authentication-unavailable-nonce"
35
+ ThreeDSecureVisaBypassedAuthentication = "fake-three-d-secure-visa-bypassed-authentication-nonce"
36
+ ThreeDSecureTwoVisaSuccessfulFrictionlessAuthentication = "fake-three-d-secure-two-visa-successful-frictionless-authentication-nonce"
37
+ ThreeDSecureTwoVisaSuccessfulStepUpAuthentication = "fake-three-d-secure-two-visa-successful-step-up-authentication-nonce"
38
+ ThreeDSecureTwoVisaErrorOnLookup = "fake-three-d-secure-two-visa-error-on-lookup-nonce"
39
+ ThreeDSecureTwoVisaTimeoutOnLookup = "fake-three-d-secure-two-visa-timeout-on-lookup-nonce"
24
40
  TransactableVisa = "fake-valid-visa-nonce"
25
41
  TransactableAmEx = "fake-valid-amex-nonce"
26
42
  TransactableMasterCard = "fake-valid-mastercard-nonce"
@@ -48,6 +64,8 @@ module Braintree
48
64
  PayPalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce"
49
65
  SEPA = "fake-sepa-bank-account-nonce"
50
66
  GatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce"
67
+ GatewayRejectedRiskThresholds = "fake-gateway-rejected-risk-thresholds-nonce"
68
+ # NEXT_MAJOR_VERSION Remove Masterpass test nonces
51
69
  MasterpassAmEx = "fake-masterpass-amex-nonce"
52
70
  MasterpassDiscover = "fake-masterpass-discover-nonce"
53
71
  MasterpassMasterCard = "fake-masterpass-mastercard-nonce"
@@ -11,6 +11,7 @@ module Braintree
11
11
  attr_reader :eci_flag
12
12
  attr_reader :three_d_secure_version
13
13
  attr_reader :ds_transaction_id
14
+ attr_reader :three_d_secure_authentication_id
14
15
 
15
16
  alias_method :liability_shifted?, :liability_shifted
16
17
  alias_method :liability_shift_possible?, :liability_shift_possible
@@ -30,6 +31,7 @@ module Braintree
30
31
  :eci_flag,
31
32
  :three_d_secure_version,
32
33
  :ds_transaction_id,
34
+ :three_d_secure_authentication_id,
33
35
  ]
34
36
 
35
37
  formatted_attrs = attr_order.map do |attr|
@@ -25,6 +25,7 @@ module Braintree
25
25
  CVV = "cvv"
26
26
  Duplicate = "duplicate"
27
27
  Fraud = "fraud"
28
+ RiskThreshold = "risk_threshold"
28
29
  ThreeDSecure = "three_d_secure"
29
30
  TokenIssuance = "token_issuance"
30
31
  Unrecognized = "unrecognized"
@@ -91,8 +92,11 @@ module Braintree
91
92
 
92
93
  attr_reader :add_ons
93
94
  attr_reader :additional_processor_response # The raw response from the processor.
95
+ # NEXT_MAJOR_VERSION Remove this class.
96
+ # DEPRECATED The American Express Checkout payment method is deprecated.
94
97
  attr_reader :amex_express_checkout_details
95
98
  attr_reader :amount
99
+ # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
96
100
  attr_reader :android_pay_details
97
101
  attr_reader :apple_pay_details
98
102
  attr_reader :authorization_adjustments
@@ -119,11 +123,14 @@ module Braintree
119
123
  attr_reader :facilitated_details
120
124
  attr_reader :facilitator_details
121
125
  attr_reader :gateway_rejection_reason
126
+ attr_reader :graphql_id
122
127
  attr_reader :id
123
128
  # NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
124
129
  # DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
125
130
  attr_reader :ideal_payment_details
126
131
  attr_reader :local_payment_details
132
+ # NEXT_MAJOR_VERSION Remove this class.
133
+ # DEPRECATED The Masterpass Card payment method is deprecated.
127
134
  attr_reader :masterpass_card_details
128
135
  attr_reader :merchant_account_id
129
136
  attr_reader :network_response_code # Response code from the card network
@@ -141,6 +148,7 @@ module Braintree
141
148
  attr_reader :processor_response_type # Response type from the processor.
142
149
  attr_reader :processor_settlement_response_code # Settlement response code from the processor.
143
150
  attr_reader :processor_settlement_response_text # Settlement response text from the processor.
151
+ attr_reader :product_sku
144
152
  attr_reader :purchase_order_number
145
153
  attr_reader :recurring
146
154
  attr_reader :refund_ids
@@ -165,6 +173,7 @@ module Braintree
165
173
  attr_reader :venmo_account_details
166
174
  attr_reader :visa_checkout_card_details
167
175
  attr_reader :voice_referral_number
176
+ attr_reader :retrieval_reference_number
168
177
 
169
178
  def self.create(*args)
170
179
  Configuration.gateway.transaction.create(*args)
@@ -304,6 +313,7 @@ module Braintree
304
313
  @paypal_details = PayPalDetails.new(@paypal)
305
314
  @paypal_here_details = PayPalHereDetails.new(@paypal_here)
306
315
  @apple_pay_details = ApplePayDetails.new(@apple_pay)
316
+ # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
307
317
  @android_pay_details = AndroidPayDetails.new(@android_pay_card)
308
318
  @amex_express_checkout_details = AmexExpressCheckoutDetails.new(@amex_express_checkout_card)
309
319
  @venmo_account_details = VenmoAccountDetails.new(@venmo_account)
@@ -437,6 +447,10 @@ module Braintree
437
447
  return_object_or_raise(:transaction) { void }
438
448
  end
439
449
 
450
+ def processed_with_network_token?
451
+ @processed_with_network_token
452
+ end
453
+
440
454
  class << self
441
455
  protected :new
442
456
  def _new(*args) # :nodoc:
@@ -445,7 +459,7 @@ module Braintree
445
459
  end
446
460
 
447
461
  def self._attributes # :nodoc:
448
- [:amount, :created_at, :credit_card_details, :customer_details, :id, :status, :subscription_details, :type, :updated_at]
462
+ [:amount, :created_at, :credit_card_details, :customer_details, :id, :status, :subscription_details, :type, :updated_at, :processed_with_network_token?]
449
463
  end
450
464
  end
451
465
  end
@@ -3,6 +3,15 @@ module Braintree
3
3
  class AddressDetails # :nodoc:
4
4
  include BaseModule
5
5
 
6
+ module ShippingMethod
7
+ SameDay = "same_day"
8
+ NextDay = "next_day"
9
+ Priority = "priority"
10
+ Ground = "ground"
11
+ Electronic = "electronic"
12
+ ShipToStore = "ship_to_store"
13
+ end
14
+
6
15
  attr_reader :company
7
16
  attr_reader :country_code_alpha2
8
17
  attr_reader :country_code_alpha3
@@ -13,8 +22,10 @@ module Braintree
13
22
  attr_reader :id
14
23
  attr_reader :last_name
15
24
  attr_reader :locality
25
+ attr_reader :phone_number
16
26
  attr_reader :postal_code
17
27
  attr_reader :region
28
+ attr_reader :shipping_method
18
29
  attr_reader :street_address
19
30
 
20
31
  def initialize(attributes)
@@ -3,6 +3,7 @@ module Braintree
3
3
  class AndroidPayDetails
4
4
  include BaseModule
5
5
 
6
+ attr_reader :bin
6
7
  attr_reader :card_type
7
8
  attr_reader :expiration_month
8
9
  attr_reader :expiration_year
@@ -31,6 +32,10 @@ module Braintree
31
32
  @card_type = @virtual_card_type
32
33
  @last_4 = @virtual_card_last_4
33
34
  end
35
+
36
+ def is_network_tokenized?
37
+ @is_network_tokenized
38
+ end
34
39
  end
35
40
  end
36
41
  end
@@ -3,6 +3,7 @@ module Braintree
3
3
  class ApplePayDetails
4
4
  include BaseModule
5
5
 
6
+ attr_reader :bin
6
7
  attr_reader :card_type
7
8
  attr_reader :cardholder_name
8
9
  attr_reader :expiration_month
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class Transaction
3
+ # NEXT_MAJOR_VERSION Remove this class.
4
+ # DEPRECATED The Masterpass Card payment method is deprecated.
3
5
  class MasterpassCardDetails # :nodoc:
4
6
  include BaseModule
5
7
 
@@ -9,6 +9,8 @@ module Braintree
9
9
  attr_reader :debug_id
10
10
  attr_reader :description
11
11
  attr_reader :image_url
12
+ attr_reader :implicitly_vaulted_payment_method_global_id
13
+ attr_reader :implicitly_vaulted_payment_method_token
12
14
  attr_reader :payee_email
13
15
  attr_reader :payee_id
14
16
  attr_reader :payer_email
@@ -188,17 +188,18 @@ module Braintree
188
188
  :purchase_order_number, :recurring, :transaction_source, :shipping_address_id, :type, :tax_amount, :tax_exempt,
189
189
  :venmo_sdk_payment_method_code, :device_session_id, :service_fee_amount, :device_data, :fraud_merchant_id,
190
190
  :shipping_amount, :discount_amount, :ships_from_postal_code,
191
- :billing_address_id, :payment_method_nonce, :three_d_secure_token,
191
+ :billing_address_id, :payment_method_nonce, :three_d_secure_token, :three_d_secure_authentication_id,
192
192
  :shared_payment_method_token, :shared_billing_address_id, :shared_customer_id, :shared_shipping_address_id, :shared_payment_method_nonce,
193
+ :product_sku,
193
194
  {:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
194
- {:risk_data => [:customer_browser, :customer_ip]},
195
+ {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
195
196
  {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number]},
196
197
  {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
197
198
  {
198
199
  :billing => AddressGateway._shared_signature
199
200
  },
200
201
  {
201
- :shipping => AddressGateway._shared_signature
202
+ :shipping => AddressGateway._shared_signature + [:shipping_method],
202
203
  },
203
204
  {
204
205
  :three_d_secure_pass_thru => [
@@ -255,6 +256,7 @@ module Braintree
255
256
  ]},
256
257
  ]},
257
258
  {:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
259
+ # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
258
260
  {:android_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]}
259
261
  ]
260
262
  end
@@ -263,6 +265,13 @@ module Braintree
263
265
  [
264
266
  :order_id,
265
267
  {:descriptor => [:name, :phone, :url]},
268
+ :purchase_order_number,
269
+ :tax_amount,
270
+ :tax_exempt,
271
+ :discount_amount,
272
+ :shipping_amount,
273
+ :ships_from_postal_code,
274
+ :line_items => [:commodity_code, :description, :discount_amount, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :url, :tax_amount],
266
275
  ]
267
276
  end
268
277
 
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 99
4
+ Minor = 104
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -13,6 +13,9 @@ module Braintree
13
13
  DisputeOpened = "dispute_opened"
14
14
  DisputeLost = "dispute_lost"
15
15
  DisputeWon = "dispute_won"
16
+ DisputeAccepted = "dispute_accepted"
17
+ DisputeDisputed = "dispute_disputed"
18
+ DisputeExpired = "dispute_expired"
16
19
 
17
20
  SubscriptionCanceled = "subscription_canceled"
18
21
  SubscriptionChargedSuccessfully = "subscription_charged_successfully"
@@ -40,6 +40,12 @@ module Braintree
40
40
  _dispute_lost_sample_xml(id)
41
41
  when Braintree::WebhookNotification::Kind::DisputeWon
42
42
  _dispute_won_sample_xml(id)
43
+ when Braintree::WebhookNotification::Kind::DisputeAccepted
44
+ _dispute_accepted_sample_xml(id)
45
+ when Braintree::WebhookNotification::Kind::DisputeDisputed
46
+ _dispute_disputed_sample_xml(id)
47
+ when Braintree::WebhookNotification::Kind::DisputeExpired
48
+ _dispute_expired_sample_xml(id)
43
49
  when Braintree::WebhookNotification::Kind::PartnerMerchantConnected
44
50
  _partner_merchant_connected_sample_xml(id)
45
51
  when Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected
@@ -309,6 +315,30 @@ module Braintree
309
315
  end
310
316
  end
311
317
 
318
+ def _dispute_accepted_sample_xml(id)
319
+ if id == "legacy_dispute_id"
320
+ _old_dispute_accepted_sample_xml(id)
321
+ else
322
+ _new_dispute_accepted_sample_xml(id)
323
+ end
324
+ end
325
+
326
+ def _dispute_disputed_sample_xml(id)
327
+ if id == "legacy_dispute_id"
328
+ _old_dispute_disputed_sample_xml(id)
329
+ else
330
+ _new_dispute_disputed_sample_xml(id)
331
+ end
332
+ end
333
+
334
+ def _dispute_expired_sample_xml(id)
335
+ if id == "legacy_dispute_id"
336
+ _old_dispute_expired_sample_xml(id)
337
+ else
338
+ _new_dispute_expired_sample_xml(id)
339
+ end
340
+ end
341
+
312
342
  def _old_dispute_opened_sample_xml(id)
313
343
  <<-XML
314
344
  <dispute>
@@ -370,6 +400,66 @@ module Braintree
370
400
  XML
371
401
  end
372
402
 
403
+ def _old_dispute_accepted_sample_xml(id)
404
+ <<-XML
405
+ <dispute>
406
+ <amount>100.00</amount>
407
+ <currency-iso-code>USD</currency-iso-code>
408
+ <received-date type="date">2014-03-01</received-date>
409
+ <reply-by-date type="date">2014-03-21</reply-by-date>
410
+ <kind>chargeback</kind>
411
+ <status>accepted</status>
412
+ <reason>fraud</reason>
413
+ <id>#{id}</id>
414
+ <transaction>
415
+ <id>#{id}</id>
416
+ <amount>100.00</amount>
417
+ </transaction>
418
+ <date-opened type=\"date\">2014-03-21</date-opened>
419
+ </dispute>
420
+ XML
421
+ end
422
+
423
+ def _old_dispute_disputed_sample_xml(id)
424
+ <<-XML
425
+ <dispute>
426
+ <amount>100.00</amount>
427
+ <currency-iso-code>USD</currency-iso-code>
428
+ <received-date type="date">2014-03-01</received-date>
429
+ <reply-by-date type="date">2014-03-21</reply-by-date>
430
+ <kind>chargeback</kind>
431
+ <status>disputed</status>
432
+ <reason>fraud</reason>
433
+ <id>#{id}</id>
434
+ <transaction>
435
+ <id>#{id}</id>
436
+ <amount>100.00</amount>
437
+ </transaction>
438
+ <date-opened type=\"date\">2014-03-21</date-opened>
439
+ </dispute>
440
+ XML
441
+ end
442
+
443
+ def _old_dispute_expired_sample_xml(id)
444
+ <<-XML
445
+ <dispute>
446
+ <amount>100.00</amount>
447
+ <currency-iso-code>USD</currency-iso-code>
448
+ <received-date type="date">2014-03-01</received-date>
449
+ <reply-by-date type="date">2014-03-21</reply-by-date>
450
+ <kind>chargeback</kind>
451
+ <status>expired</status>
452
+ <reason>fraud</reason>
453
+ <id>#{id}</id>
454
+ <transaction>
455
+ <id>#{id}</id>
456
+ <amount>100.00</amount>
457
+ </transaction>
458
+ <date-opened type=\"date\">2014-03-21</date-opened>
459
+ </dispute>
460
+ XML
461
+ end
462
+
373
463
  def _new_dispute_opened_sample_xml(id)
374
464
  <<-XML
375
465
  <dispute>
@@ -535,6 +625,159 @@ module Braintree
535
625
  XML
536
626
  end
537
627
 
628
+ def _new_dispute_accepted_sample_xml(id)
629
+ <<-XML
630
+ <dispute>
631
+ <id>#{id}</id>
632
+ <amount>100.00</amount>
633
+ <amount-disputed>100.00</amount-disputed>
634
+ <amount-won>95.00</amount-won>
635
+ <case-number>CASE-12345</case-number>
636
+ <created-at type="datetime">2017-06-16T20:44:41Z</created-at>
637
+ <currency-iso-code>USD</currency-iso-code>
638
+ <forwarded-comments nil="true"/>
639
+ <kind>chargeback</kind>
640
+ <merchant-account-id>ytnlulaloidoqwvzxjrdqputg</merchant-account-id>
641
+ <reason>fraud</reason>
642
+ <reason-code nil="true"/>
643
+ <reason-description nil="true"/>
644
+ <received-date type="date">2016-02-15</received-date>
645
+ <reference-number>REF-9876</reference-number>
646
+ <reply-by-date type="date">2016-02-22</reply-by-date>
647
+ <status>accepted</status>
648
+ <updated-at type="datetime">2017-06-16T20:44:41Z</updated-at>
649
+ <original-dispute-id>9qde5qgp</original-dispute-id>
650
+ <status-history type="array">
651
+ <status-history>
652
+ <status>open</status>
653
+ <timestamp type="datetime">2017-06-16T20:44:41Z</timestamp>
654
+ </status-history>
655
+ <status-history>
656
+ <status>accepted</status>
657
+ <timestamp type="datetime">2017-06-25T20:50:55Z</timestamp>
658
+ </status-history>
659
+ </status-history>
660
+ <evidence type="array"/>
661
+ <transaction>
662
+ <id>#{id}</id>
663
+ <amount>100.00</amount>
664
+ <created-at>2017-06-21T20:44:41Z</created-at>
665
+ <order-id nil="true"/>
666
+ <purchase-order-number nil="true"/>
667
+ <payment-instrument-subtype>Visa</payment-instrument-subtype>
668
+ </transaction>
669
+ <date-opened type=\"date\">2014-03-21</date-opened>
670
+ </dispute>
671
+ XML
672
+ end
673
+
674
+ def _new_dispute_disputed_sample_xml(id)
675
+ <<-XML
676
+ <dispute>
677
+ <id>#{id}</id>
678
+ <amount>100.00</amount>
679
+ <amount-disputed>100.00</amount-disputed>
680
+ <amount-won>95.00</amount-won>
681
+ <case-number>CASE-12345</case-number>
682
+ <created-at type="datetime">2017-06-16T20:44:41Z</created-at>
683
+ <currency-iso-code>USD</currency-iso-code>
684
+ <forwarded-comments nil="true"/>
685
+ <kind>chargeback</kind>
686
+ <merchant-account-id>ytnlulaloidoqwvzxjrdqputg</merchant-account-id>
687
+ <reason>fraud</reason>
688
+ <reason-code nil="true"/>
689
+ <reason-description nil="true"/>
690
+ <received-date type="date">2016-02-15</received-date>
691
+ <reference-number>REF-9876</reference-number>
692
+ <reply-by-date type="date">2016-02-22</reply-by-date>
693
+ <status>disputed</status>
694
+ <updated-at type="datetime">2017-06-21T20:44:41Z</updated-at>
695
+ <original-dispute-id>9qde5qgp</original-dispute-id>
696
+ <status-history type="array">
697
+ <status-history>
698
+ <status>open</status>
699
+ <timestamp type="datetime">2017-06-16T20:44:41Z</timestamp>
700
+ </status-history>
701
+ <status-history>
702
+ <status>disputed</status>
703
+ <timestamp type="datetime">2017-06-25T20:50:55Z</timestamp>
704
+ </status-history>
705
+ </status-history>
706
+ <evidence type="array">
707
+ <evidence>
708
+ <id>rxtngk9j5j93tsrq</id>
709
+ <comments nil="true"/>
710
+ <created-at type="datetime">2017-06-21T20:44:42Z</created-at>
711
+ <sent-to-processor-at nil="true"/>
712
+ <url>s3.amazonaws.com/foo.jpg</url>
713
+ </evidence>
714
+ <evidence>
715
+ <id>88cfb8dd</id>
716
+ <comments>text evidence</comments>
717
+ <created-at type="datetime">2017-06-21T20:44:42Z</created-at>
718
+ <sent-to-processor-at nil="true"/>
719
+ <url nil="true"/>
720
+ </evidence>
721
+ </evidence>
722
+ <transaction>
723
+ <id>#{id}</id>
724
+ <amount>100.00</amount>
725
+ <created-at>2017-06-21T20:44:41Z</created-at>
726
+ <order-id nil="true"/>
727
+ <purchase-order-number nil="true"/>
728
+ <payment-instrument-subtype>Visa</payment-instrument-subtype>
729
+ </transaction>
730
+ <date-opened type=\"date\">2014-03-21</date-opened>
731
+ </dispute>
732
+ XML
733
+ end
734
+
735
+ def _new_dispute_expired_sample_xml(id)
736
+ <<-XML
737
+ <dispute>
738
+ <id>#{id}</id>
739
+ <amount>100.00</amount>
740
+ <amount-disputed>100.00</amount-disputed>
741
+ <amount-won>95.00</amount-won>
742
+ <case-number>CASE-12345</case-number>
743
+ <created-at type="datetime">2017-06-16T20:44:41Z</created-at>
744
+ <currency-iso-code>USD</currency-iso-code>
745
+ <forwarded-comments nil="true"/>
746
+ <kind>chargeback</kind>
747
+ <merchant-account-id>ytnlulaloidoqwvzxjrdqputg</merchant-account-id>
748
+ <reason>fraud</reason>
749
+ <reason-code nil="true"/>
750
+ <reason-description nil="true"/>
751
+ <received-date type="date">2016-02-15</received-date>
752
+ <reference-number>REF-9876</reference-number>
753
+ <reply-by-date type="date">2016-02-22</reply-by-date>
754
+ <status>expired</status>
755
+ <updated-at type="datetime">2017-06-16T20:44:41Z</updated-at>
756
+ <original-dispute-id>9qde5qgp</original-dispute-id>
757
+ <status-history type="array">
758
+ <status-history>
759
+ <status>open</status>
760
+ <timestamp type="datetime">2017-06-16T20:44:41Z</timestamp>
761
+ </status-history>
762
+ <status-history>
763
+ <status>expired</status>
764
+ <timestamp type="datetime">2017-06-25T20:50:55Z</timestamp>
765
+ </status-history>
766
+ </status-history>
767
+ <evidence type="array"/>
768
+ <transaction>
769
+ <id>#{id}</id>
770
+ <amount>100.00</amount>
771
+ <created-at>2017-06-21T20:44:41Z</created-at>
772
+ <order-id nil="true"/>
773
+ <purchase-order-number nil="true"/>
774
+ <payment-instrument-subtype>Visa</payment-instrument-subtype>
775
+ </transaction>
776
+ <date-opened type=\"date\">2014-03-21</date-opened>
777
+ </dispute>
778
+ XML
779
+ end
780
+
538
781
  def _disbursement_exception_sample_xml(id)
539
782
 
540
783
  <<-XML