braintree 2.104.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +7 -4
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -23
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +11 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/base_module.rb +6 -0
  11. data/lib/braintree/bin_data.rb +9 -2
  12. data/lib/braintree/client_token.rb +1 -1
  13. data/lib/braintree/configuration.rb +12 -12
  14. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  15. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  16. data/lib/braintree/credit_card.rb +2 -77
  17. data/lib/braintree/credit_card_gateway.rb +17 -36
  18. data/lib/braintree/credit_card_verification.rb +18 -5
  19. data/lib/braintree/credit_card_verification_search.rb +1 -1
  20. data/lib/braintree/customer.rb +9 -78
  21. data/lib/braintree/customer_gateway.rb +2 -23
  22. data/lib/braintree/customer_search.rb +1 -1
  23. data/lib/braintree/disbursement.rb +1 -1
  24. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  25. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  26. data/lib/braintree/dispute.rb +32 -8
  27. data/lib/braintree/dispute_gateway.rb +4 -9
  28. data/lib/braintree/dispute_search.rb +6 -3
  29. data/lib/braintree/document_upload.rb +1 -1
  30. data/lib/braintree/enriched_customer_data.rb +21 -0
  31. data/lib/braintree/error_codes.rb +150 -171
  32. data/lib/braintree/exceptions.rb +5 -3
  33. data/lib/braintree/exchange_rate.rb +13 -0
  34. data/lib/braintree/exchange_rate_quote.rb +24 -0
  35. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  36. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  37. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  38. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  39. data/lib/braintree/gateway.rb +4 -14
  40. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
  41. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  42. data/lib/braintree/graphql_client.rb +7 -7
  43. data/lib/braintree/http.rb +4 -3
  44. data/lib/braintree/local_payment_completed.rb +2 -2
  45. data/lib/braintree/local_payment_expired.rb +21 -0
  46. data/lib/braintree/local_payment_funded.rb +22 -0
  47. data/lib/braintree/local_payment_reversed.rb +19 -0
  48. data/lib/braintree/merchant.rb +1 -1
  49. data/lib/braintree/merchant_account.rb +1 -1
  50. data/lib/braintree/merchant_account_gateway.rb +3 -1
  51. data/lib/braintree/merchant_gateway.rb +1 -1
  52. data/lib/braintree/modification.rb +1 -1
  53. data/lib/braintree/oauth_credentials.rb +1 -1
  54. data/lib/braintree/oauth_gateway.rb +5 -5
  55. data/lib/braintree/payment_instrument_type.rb +10 -14
  56. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  57. data/lib/braintree/payment_method_gateway.rb +15 -17
  58. data/lib/braintree/payment_method_nonce.rb +7 -4
  59. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  60. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  61. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  62. data/lib/braintree/payment_method_parser.rb +1 -8
  63. data/lib/braintree/plan.rb +21 -1
  64. data/lib/braintree/plan_gateway.rb +100 -0
  65. data/lib/braintree/processor_response_types.rb +3 -3
  66. data/lib/braintree/resource_collection.rb +8 -3
  67. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  68. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  69. data/lib/braintree/risk_data.rb +5 -1
  70. data/lib/braintree/samsung_pay_card.rb +1 -1
  71. data/lib/braintree/settlement_batch_summary.rb +2 -2
  72. data/lib/braintree/subscription.rb +11 -11
  73. data/lib/braintree/successful_result.rb +3 -2
  74. data/lib/braintree/test/credit_card.rb +1 -0
  75. data/lib/braintree/test/nonce.rb +4 -23
  76. data/lib/braintree/three_d_secure_info.rb +22 -12
  77. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  78. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  79. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  80. data/lib/braintree/transaction/installment.rb +28 -0
  81. data/lib/braintree/transaction/paypal_details.rb +3 -0
  82. data/lib/braintree/transaction/subscription_details.rb +2 -0
  83. data/lib/braintree/transaction.rb +65 -120
  84. data/lib/braintree/transaction_gateway.rb +39 -27
  85. data/lib/braintree/transaction_line_item.rb +1 -1
  86. data/lib/braintree/transaction_review.rb +18 -0
  87. data/lib/braintree/transaction_search.rb +5 -3
  88. data/lib/braintree/unknown_payment_method.rb +1 -1
  89. data/lib/braintree/us_bank_account.rb +3 -3
  90. data/lib/braintree/us_bank_account_verification.rb +1 -1
  91. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  92. data/lib/braintree/util.rb +21 -6
  93. data/lib/braintree/venmo_account.rb +1 -1
  94. data/lib/braintree/venmo_profile_data.rb +23 -0
  95. data/lib/braintree/version.rb +2 -2
  96. data/lib/braintree/visa_checkout_card.rb +2 -2
  97. data/lib/braintree/webhook_notification.rb +44 -30
  98. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  99. data/lib/braintree/webhook_testing_gateway.rb +104 -43
  100. data/lib/braintree/xml/generator.rb +5 -4
  101. data/lib/braintree/xml/parser.rb +22 -35
  102. data/lib/braintree/xml/rexml.rb +4 -5
  103. data/lib/braintree.rb +28 -23
  104. data/spec/integration/braintree/add_on_spec.rb +1 -1
  105. data/spec/integration/braintree/address_spec.rb +30 -113
  106. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  107. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  108. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  109. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  110. data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
  111. data/spec/integration/braintree/credit_card_spec.rb +219 -593
  112. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  113. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  114. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  115. data/spec/integration/braintree/customer_spec.rb +484 -513
  116. data/spec/integration/braintree/dispute_search_spec.rb +35 -6
  117. data/spec/integration/braintree/dispute_spec.rb +6 -7
  118. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  119. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  120. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  121. data/spec/integration/braintree/http_spec.rb +2 -2
  122. data/spec/integration/braintree/merchant_account_spec.rb +28 -29
  123. data/spec/integration/braintree/merchant_spec.rb +14 -14
  124. data/spec/integration/braintree/oauth_spec.rb +11 -11
  125. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
  126. data/spec/integration/braintree/payment_method_spec.rb +535 -270
  127. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  128. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  129. data/spec/integration/braintree/plan_spec.rb +82 -0
  130. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  131. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  132. data/spec/integration/braintree/subscription_spec.rb +144 -149
  133. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  134. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  135. data/spec/integration/braintree/transaction_search_spec.rb +175 -70
  136. data/spec/integration/braintree/transaction_spec.rb +955 -894
  137. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  138. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  139. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  140. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  141. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  142. data/spec/integration/spec_helper.rb +16 -7
  143. data/spec/oauth_test_helper.rb +1 -1
  144. data/spec/script/httpsd.rb +6 -6
  145. data/spec/spec_helper.rb +8 -14
  146. data/spec/unit/braintree/address_spec.rb +1 -9
  147. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -1
  148. data/spec/unit/braintree/client_token_spec.rb +2 -2
  149. data/spec/unit/braintree/configuration_spec.rb +42 -42
  150. data/spec/unit/braintree/credit_card_spec.rb +13 -32
  151. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  152. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  153. data/spec/unit/braintree/customer_spec.rb +21 -22
  154. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  155. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  156. data/spec/unit/braintree/dispute_spec.rb +75 -21
  157. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  158. data/spec/unit/braintree/error_result_spec.rb +5 -5
  159. data/spec/unit/braintree/errors_spec.rb +8 -8
  160. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  161. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  162. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  163. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  164. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  165. data/spec/unit/braintree/http_spec.rb +10 -8
  166. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  167. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  168. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  169. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  170. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  171. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  172. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  173. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  174. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  175. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  176. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  177. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  178. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  179. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  180. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  181. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  182. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  183. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  184. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  185. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  186. data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
  187. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  188. data/spec/unit/braintree/transaction_spec.rb +36 -54
  189. data/spec/unit/braintree/util_spec.rb +55 -21
  190. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  191. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  192. data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
  193. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  194. data/spec/unit/braintree/xml_spec.rb +31 -31
  195. metadata +62 -30
  196. data/lib/braintree/amex_express_checkout_card.rb +0 -40
  197. data/lib/braintree/coinbase_account.rb +0 -34
  198. data/lib/braintree/europe_bank_account.rb +0 -36
  199. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  200. data/lib/braintree/ideal_payment.rb +0 -61
  201. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  202. data/lib/braintree/masterpass_card.rb +0 -83
  203. data/lib/braintree/settlement_batch.rb +0 -0
  204. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  205. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  206. data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
  207. data/lib/braintree/transparent_redirect.rb +0 -40
  208. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  209. data/spec/hacks/tcp_socket.rb +0 -18
  210. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  211. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  212. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  213. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -0,0 +1,37 @@
1
+ module Braintree
2
+ class PaymentMethodNonceDetails # :nodoc:
3
+ include BaseModule
4
+
5
+ attr_reader :bin
6
+ attr_reader :card_type
7
+ attr_reader :expiration_month
8
+ attr_reader :expiration_year
9
+ attr_reader :is_network_tokenized
10
+ attr_reader :last_two
11
+ attr_reader :payer_info
12
+
13
+ alias_method :is_network_tokenized?, :is_network_tokenized
14
+
15
+ def initialize(attributes)
16
+ set_instance_variables_from_hash attributes unless attributes.nil?
17
+ @payer_info = PaymentMethodNonceDetailsPayerInfo.new(attributes[:payer_info]) if attributes[:payer_info]
18
+ end
19
+
20
+ def inspect
21
+ attr_order = [
22
+ :bin,
23
+ :card_type,
24
+ :expiration_month,
25
+ :expiration_year,
26
+ :is_network_tokenized,
27
+ :last_two,
28
+ :payer_info,
29
+ ]
30
+
31
+ formatted_attrs = attr_order.map do |attr|
32
+ "#{attr}: #{send(attr).inspect}"
33
+ end
34
+ "#<PaymentMethodNonceDetails #{formatted_attrs.join(", ")}>"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ module Braintree
2
+ class PaymentMethodNonceDetailsPayerInfo # :nodoc:
3
+ include BaseModule
4
+
5
+ attr_reader :billing_agreement_id
6
+ attr_reader :country_code
7
+ attr_reader :email
8
+ attr_reader :first_name
9
+ attr_reader :last_name
10
+ attr_reader :payer_id
11
+
12
+ def initialize(attributes)
13
+ set_instance_variables_from_hash attributes unless attributes.nil?
14
+ end
15
+
16
+ def inspect
17
+ attr_order = [
18
+ :billing_agreement_id,
19
+ :country_code,
20
+ :email,
21
+ :first_name,
22
+ :last_name,
23
+ :payer_id,
24
+ ]
25
+
26
+ formatted_attrs = attr_order.map do |attr|
27
+ "#{attr}: #{send(attr).inspect}"
28
+ end
29
+ "#<PaymentMethodNonceDetailsPayerInfo #{formatted_attrs.join(", ")}>"
30
+ end
31
+ end
32
+ end
@@ -8,7 +8,7 @@ module Braintree
8
8
  @config.assert_has_access_token_or_keys
9
9
  end
10
10
 
11
- def create(payment_method_token, args = { payment_method_nonce: {} })
11
+ def create(payment_method_token, args = {payment_method_nonce: {}})
12
12
  Util.verify_keys(PaymentMethodNonceGateway._create_signature, args)
13
13
 
14
14
  response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces", args)
@@ -6,23 +6,16 @@ module Braintree
6
6
  CreditCard._new(gateway, attributes[:credit_card])
7
7
  elsif attributes[:paypal_account]
8
8
  PayPalAccount._new(gateway, attributes[:paypal_account])
9
- elsif attributes[:coinbase_account]
10
- CoinbaseAccount._new(gateway, attributes[:coinbase_account])
11
9
  elsif attributes[:us_bank_account]
12
10
  UsBankAccount._new(gateway, attributes[:us_bank_account])
13
11
  elsif attributes[:apple_pay_card]
14
12
  ApplePayCard._new(gateway, attributes[:apple_pay_card])
15
13
  elsif attributes[:android_pay_card]
16
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
17
- AndroidPayCard._new(gateway, attributes[:android_pay_card])
18
- elsif attributes[:amex_express_checkout_card]
19
- AmexExpressCheckoutCard._new(gateway, attributes[:amex_express_checkout_card])
14
+ GooglePayCard._new(gateway, attributes[:android_pay_card])
20
15
  elsif attributes[:venmo_account]
21
16
  VenmoAccount._new(gateway, attributes[:venmo_account])
22
17
  elsif attributes[:visa_checkout_card]
23
18
  VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
24
- elsif attributes[:masterpass_card]
25
- MasterpassCard._new(gateway, attributes[:masterpass_card])
26
19
  elsif attributes[:samsung_pay_card]
27
20
  SamsungPayCard._new(gateway, attributes[:samsung_pay_card])
28
21
  else
@@ -33,10 +33,30 @@ module Braintree
33
33
 
34
34
  class << self
35
35
  protected :new
36
+
37
+ def create(*args)
38
+ Configuration.gateway.plan.create(*args)
39
+ end
40
+
41
+ def create!(*args)
42
+ Configuration.gateway.plan.create!(*args)
43
+ end
44
+
45
+ def find(*args)
46
+ Configuration.gateway.plan.find(*args)
47
+ end
48
+
49
+ def update(*args)
50
+ Configuration.gateway.plan.update(*args)
51
+ end
52
+
53
+ def update!(*args)
54
+ Configuration.gateway.plan.update!(*args)
55
+ end
36
56
  end
37
57
 
38
58
  def self._new(*args)
39
- self.new *args
59
+ self.new(*args)
40
60
  end
41
61
  end
42
62
  end
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class PlanGateway # :nodoc:
3
+ include BaseModule
4
+
3
5
  def initialize(gateway)
4
6
  @gateway = gateway
5
7
  @config = gateway.config
@@ -13,5 +15,103 @@ module Braintree
13
15
  Plan._new(@gateway, attributes)
14
16
  end
15
17
  end
18
+
19
+ def create(attributes)
20
+ Util.verify_keys(PlanGateway._create_signature, attributes)
21
+ _do_create "/plans", :plan => attributes
22
+ end
23
+
24
+ def create!(*args)
25
+ return_object_or_raise(:plan) { create(*args) }
26
+ end
27
+
28
+ def find(id)
29
+ raise ArgumentError if id.nil? || id.to_s.strip == ""
30
+ response = @config.http.get("#{@config.base_merchant_path}/plans/#{id}")
31
+ Plan._new(@gateway, response[:plan])
32
+ rescue NotFoundError
33
+ raise NotFoundError, "plan with id #{id.inspect} not found"
34
+ end
35
+
36
+ def update(plan_id, attributes)
37
+ Util.verify_keys(PlanGateway._update_signature, attributes)
38
+ response = @config.http.put("#{@config.base_merchant_path}/plans/#{plan_id}", :plan => attributes)
39
+ if response[:plan]
40
+ SuccessfulResult.new(:plan => Plan._new(@gateway, response[:plan]))
41
+ elsif response[:api_error_response]
42
+ ErrorResult.new(@gateway, response[:api_error_response])
43
+ else
44
+ raise UnexpectedError, "expected :plan or :api_error_response"
45
+ end
46
+ end
47
+
48
+ def update!(*args)
49
+ return_object_or_raise(:plan) { update(*args) }
50
+ end
51
+
52
+ def self._create_signature
53
+ [
54
+ :billing_day_of_month,
55
+ :billing_frequency,
56
+ :currency_iso_code,
57
+ :description,
58
+ :id,
59
+ :merchant_id,
60
+ :name,
61
+ :number_of_billing_cycles,
62
+ :price,
63
+ :trial_duration,
64
+ :trial_duration_unit,
65
+ :trial_period
66
+ ] + _add_on_discount_signature
67
+ end
68
+
69
+ def self._update_signature
70
+ [
71
+ :billing_day_of_month,
72
+ :billing_frequency,
73
+ :currency_iso_code,
74
+ :description,
75
+ :id,
76
+ :merchant_id,
77
+ :name,
78
+ :number_of_billing_cycles,
79
+ :price,
80
+ :trial_duration,
81
+ :trial_duration_unit,
82
+ :trial_period
83
+ ] + _add_on_discount_signature
84
+ end
85
+
86
+ def self._add_on_discount_signature
87
+ [
88
+ {
89
+ :add_ons => [
90
+ {:add => [:amount, :inherited_from_id, :never_expires, :number_of_billing_cycles, :quantity]},
91
+ {:update => [:amount, :existing_id, :never_expires, :number_of_billing_cycles, :quantity]},
92
+ {:remove => [:_any_key_]}
93
+ ]
94
+ },
95
+ {
96
+ :discounts => [
97
+ {:add => [:amount, :inherited_from_id, :never_expires, :number_of_billing_cycles, :quantity]},
98
+ {:update => [:amount, :existing_id, :never_expires, :number_of_billing_cycles, :quantity]},
99
+ {:remove => [:_any_key_]}
100
+ ]
101
+ }
102
+ ]
103
+ end
104
+
105
+ def _do_create(path, params) # :nodoc:
106
+ response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
107
+ if response[:plan]
108
+ SuccessfulResult.new(:plan => Plan._new(@gateway, response[:plan]))
109
+ elsif response[:api_error_response]
110
+ ErrorResult.new(@gateway, response[:api_error_response])
111
+ else
112
+ raise UnexpectedError, "expected :plan or :api_error_response"
113
+ end
114
+ end
16
115
  end
17
116
  end
117
+
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module ProcessorResponseTypes
3
- Approved = 'approved'
4
- SoftDeclined = 'soft_declined'
5
- HardDeclined = 'hard_declined'
3
+ Approved = "approved"
4
+ SoftDeclined = "soft_declined"
5
+ HardDeclined = "hard_declined"
6
6
  end
7
7
  end
@@ -22,9 +22,14 @@ module Braintree
22
22
  @ids.empty?
23
23
  end
24
24
 
25
- # Returns the first item in the collection or nil if the collection is empty
26
- def first
27
- @paging_block.call([@ids.first]).first
25
+ # Returns the first or the first N items in the collection or nil if the collection is empty
26
+ def first(amount = 1)
27
+ return nil if @ids.empty?
28
+ return @paging_block.call([@ids.first]).first if amount == 1
29
+
30
+ @ids.first(amount).each_slice(@page_size).flat_map do |page_of_ids|
31
+ @paging_block.call(page_of_ids)
32
+ end
28
33
  end
29
34
 
30
35
  # Only the maximum size of a resource collection can be determined since the data on the server can change while
@@ -15,7 +15,7 @@ module Braintree
15
15
  class << self
16
16
  protected :new
17
17
  def _new(*args) # :nodoc:
18
- self.new *args
18
+ self.new(*args)
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,22 @@
1
+ module Braintree
2
+ class RiskData
3
+ class LiabilityShift
4
+ include BaseModule
5
+
6
+ attr_reader :responsible_party
7
+ attr_reader :conditions
8
+
9
+ def initialize(attributes)
10
+ set_instance_variables_from_hash attributes unless attributes.nil?
11
+ end
12
+
13
+ def inspect
14
+ attr_order = [:responsible_party, :conditions]
15
+ formatted_attrs = attr_order.map do |attr|
16
+ "#{attr}: #{send(attr).inspect}"
17
+ end
18
+ "#<LiabilityShift #{formatted_attrs.join(", ")}>"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -6,16 +6,20 @@ module Braintree
6
6
  attr_reader :customer_location_zip
7
7
  attr_reader :customer_tenure
8
8
  attr_reader :decision
9
+ attr_reader :decision_reasons
9
10
  attr_reader :device_data_captured
10
11
  attr_reader :fraud_service_provider
11
12
  attr_reader :id
13
+ attr_reader :liability_shift
14
+ attr_reader :transaction_risk_score
12
15
 
13
16
  def initialize(attributes)
14
17
  set_instance_variables_from_hash attributes unless attributes.nil?
18
+ @liability_shift = LiabilityShift.new(attributes[:liability_shift]) if attributes[:liability_shift]
15
19
  end
16
20
 
17
21
  def inspect
18
- attr_order = [:id, :decision, :device_data_captured, :fraud_service_provider]
22
+ attr_order = [:id, :decision, :decision_reasons, :device_data_captured, :fraud_service_provider, :liability_shift, :transaction_risk_score]
19
23
  formatted_attrs = attr_order.map do |attr|
20
24
  "#{attr}: #{send(attr).inspect}"
21
25
  end
@@ -77,7 +77,7 @@ module Braintree
77
77
  end
78
78
 
79
79
  def self._new(*args) # :nodoc:
80
- self.new *args
80
+ self.new(*args)
81
81
  end
82
82
  end
83
83
  end
@@ -1,11 +1,11 @@
1
1
  module Braintree
2
2
  class SettlementBatchSummary
3
3
  include BaseModule
4
-
4
+
5
5
  attr_reader :records
6
6
 
7
7
  def self.generate(settlement_date, group_by_custom_field = nil)
8
- criteria = { :settlement_date => settlement_date }
8
+ criteria = {:settlement_date => settlement_date}
9
9
  criteria.merge!({:group_by_custom_field => group_by_custom_field}) if group_by_custom_field
10
10
  Configuration.gateway.settlement_batch_summary.generate(criteria)
11
11
  end
@@ -11,11 +11,11 @@ module Braintree
11
11
  end
12
12
 
13
13
  module Status
14
- Active = 'Active'
15
- Canceled = 'Canceled'
16
- Expired = 'Expired'
17
- PastDue = 'Past Due'
18
- Pending = 'Pending'
14
+ Active = "Active"
15
+ Canceled = "Canceled"
16
+ Expired = "Expired"
17
+ PastDue = "Past Due"
18
+ Pending = "Pending"
19
19
 
20
20
  All = constants.map { |c| const_get(c) }
21
21
  end
@@ -101,11 +101,11 @@ module Braintree
101
101
  add_ons.map! { |attrs| AddOn._new(attrs) }
102
102
  discounts.map! { |attrs| Discount._new(attrs) }
103
103
  @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
104
- end
105
-
106
- def next_bill_amount
107
- warn "[DEPRECATED] Subscription.next_bill_amount is deprecated. Please use Subscription.next_billing_period_amount"
108
- @next_bill_amount
104
+ @first_billing_date = Date.parse(first_billing_date) unless first_billing_date.nil?
105
+ @next_billing_date = Date.parse(next_billing_date) unless next_billing_date.nil?
106
+ @billing_period_start_date = Date.parse(billing_period_start_date) unless billing_period_start_date.nil?
107
+ @billing_period_end_date = Date.parse(billing_period_end_date) unless billing_period_end_date.nil?
108
+ @paid_through_date = Date.parse(paid_through_date) unless paid_through_date.nil?
109
109
  end
110
110
 
111
111
  def never_expires?
@@ -115,7 +115,7 @@ module Braintree
115
115
  class << self
116
116
  protected :new
117
117
  def _new(*args) # :nodoc:
118
- self.new *args
118
+ self.new(*args)
119
119
  end
120
120
  end
121
121
  end
@@ -6,23 +6,24 @@ module Braintree
6
6
  attr_reader :apple_pay_options
7
7
  attr_reader :credentials
8
8
  attr_reader :credit_card
9
+ attr_reader :credit_card_verification
9
10
  attr_reader :customer
10
11
  attr_reader :disputes
11
12
  attr_reader :document_upload
12
13
  attr_reader :evidence
14
+ attr_reader :exchange_rate_quote_payload
13
15
  attr_reader :merchant
14
16
  attr_reader :merchant_account
15
17
  attr_reader :merchant_accounts
16
- attr_reader :new_transaction
17
18
  attr_reader :payment_method
18
19
  attr_reader :payment_method_nonce
19
20
  attr_reader :paypal_account
21
+ attr_reader :plan
20
22
  attr_reader :settlement_batch_summary
21
23
  attr_reader :subscription
22
24
  attr_reader :supported_networks
23
25
  attr_reader :transaction
24
26
  attr_reader :us_bank_account_verification
25
- attr_reader :credit_card_verification
26
27
 
27
28
  def initialize(attributes = {}) # :nodoc:
28
29
  @attrs = attributes.keys
@@ -36,6 +36,7 @@ module Braintree
36
36
  Hipercard = "6062820524845321"
37
37
 
38
38
  Visa = "4012888888881881"
39
+ VisaCountryOfIssuanceIE = "4023490000000008"
39
40
  VisaInternational = "4009348888881881" # :nodoc:
40
41
  VisaPrepaid = "4500600000000061"
41
42
 
@@ -12,14 +12,10 @@ module Braintree
12
12
  ApplePayAmEx = "fake-apple-pay-amex-nonce"
13
13
  AbstractTransactable = "fake-abstract-transactable-nonce"
14
14
  Europe = "fake-europe-bank-account-nonce"
15
- Coinbase = "fake-coinbase-nonce"
16
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
17
- AndroidPayDiscover = "fake-android-pay-discover-nonce"
18
- AndroidPayVisa = "fake-android-pay-visa-nonce"
19
- AndroidPayMasterCard = "fake-android-pay-mastercard-nonce"
20
- AndroidPayAmEx = "fake-android-pay-amex-nonce"
21
- # NEXT_MAJOR_VERSION Remove AmexExpressCheckout test nonces
22
- AmexExpressCheckout = "fake-amex-express-checkout-nonce"
15
+ GooglePayDiscover = "fake-android-pay-discover-nonce"
16
+ GooglePayVisa = "fake-android-pay-visa-nonce"
17
+ GooglePayMasterCard = "fake-android-pay-mastercard-nonce"
18
+ GooglePayAmEx = "fake-android-pay-amex-nonce"
23
19
  VenmoAccount = "fake-venmo-account-nonce"
24
20
  VenmoAccountTokenIssuanceError = "fake-token-issuance-error-venmo-account-nonce"
25
21
  ThreeDSecureVisaFullAuthentication = "fake-three-d-secure-visa-full-authentication-nonce"
@@ -62,14 +58,8 @@ module Braintree
62
58
  ProcessorFailureJCB = "fake-processor-failure-jcb-nonce"
63
59
  LuhnInvalid = "fake-luhn-invalid-nonce"
64
60
  PayPalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce"
65
- SEPA = "fake-sepa-bank-account-nonce"
66
61
  GatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce"
67
62
  GatewayRejectedRiskThresholds = "fake-gateway-rejected-risk-thresholds-nonce"
68
- # NEXT_MAJOR_VERSION Remove Masterpass test nonces
69
- MasterpassAmEx = "fake-masterpass-amex-nonce"
70
- MasterpassDiscover = "fake-masterpass-discover-nonce"
71
- MasterpassMasterCard = "fake-masterpass-mastercard-nonce"
72
- MasterpassVisa = "fake-masterpass-visa-nonce"
73
63
  VisaCheckoutAmEx = "fake-visa-checkout-amex-nonce"
74
64
  VisaCheckoutDiscover = "fake-visa-checkout-discover-nonce"
75
65
  VisaCheckoutMasterCard = "fake-visa-checkout-mastercard-nonce"
@@ -78,15 +68,6 @@ module Braintree
78
68
  SamsungPayDiscover = "tokensam_fake_discover"
79
69
  SamsungPayMasterCard = "tokensam_fake_mastercard"
80
70
  SamsungPayVisa = "tokensam_fake_visa"
81
-
82
- def self.const_missing(const_name)
83
- if const_name == :AndroidPay
84
- warn "[DEPRECATED] Braintree::Test::Nonce::AndroidPay is deprecated. Use a card-specific nonce, e.g. Braintree::Test::Nonce::AndroidPayMasterCard"
85
- "fake-android-pay-nonce"
86
- else
87
- super
88
- end
89
- end
90
71
  end
91
72
  end
92
73
  end
@@ -2,16 +2,21 @@ module Braintree
2
2
  class ThreeDSecureInfo # :nodoc:
3
3
  include BaseModule
4
4
 
5
+ attr_reader :acs_transaction_id
6
+ attr_reader :cavv
7
+ attr_reader :ds_transaction_id
8
+ attr_reader :eci_flag
5
9
  attr_reader :enrolled
6
- attr_reader :liability_shifted
7
10
  attr_reader :liability_shift_possible
11
+ attr_reader :liability_shifted
12
+ attr_reader :pares_status
8
13
  attr_reader :status
9
- attr_reader :cavv
10
- attr_reader :xid
11
- attr_reader :eci_flag
12
- attr_reader :three_d_secure_version
13
- attr_reader :ds_transaction_id
14
14
  attr_reader :three_d_secure_authentication_id
15
+ attr_reader :three_d_secure_transaction_id
16
+ attr_reader :three_d_secure_version
17
+ attr_reader :xid
18
+ attr_reader :lookup
19
+ attr_reader :authentication
15
20
 
16
21
  alias_method :liability_shifted?, :liability_shifted
17
22
  alias_method :liability_shift_possible?, :liability_shift_possible
@@ -22,16 +27,21 @@ module Braintree
22
27
 
23
28
  def inspect
24
29
  attr_order = [
30
+ :acs_transaction_id,
31
+ :authentication,
32
+ :cavv,
33
+ :ds_transaction_id,
34
+ :eci_flag,
25
35
  :enrolled,
26
- :liability_shifted,
27
36
  :liability_shift_possible,
37
+ :liability_shifted,
38
+ :lookup,
39
+ :pares_status,
28
40
  :status,
29
- :cavv,
30
- :xid,
31
- :eci_flag,
32
- :three_d_secure_version,
33
- :ds_transaction_id,
34
41
  :three_d_secure_authentication_id,
42
+ :three_d_secure_transaction_id,
43
+ :three_d_secure_version,
44
+ :xid
35
45
  ]
36
46
 
37
47
  formatted_attrs = attr_order.map do |attr|
@@ -13,6 +13,7 @@ module Braintree
13
13
 
14
14
  def initialize(attributes)
15
15
  set_instance_variables_from_hash attributes unless attributes.nil?
16
+ @disbursement_date = Date.parse(disbursement_date) unless disbursement_date.nil?
16
17
  end
17
18
 
18
19
  def funds_held?
@@ -1,6 +1,6 @@
1
1
  module Braintree
2
2
  class Transaction
3
- class AndroidPayDetails
3
+ class GooglePayDetails
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :bin
@@ -0,0 +1,33 @@
1
+ module Braintree
2
+ class Transaction
3
+ class Installment
4
+ class Adjustment
5
+ include BaseModule
6
+
7
+ module Kind
8
+ Refund = "REFUND"
9
+ Dispute = "DISPUTE"
10
+ end
11
+
12
+ attr_reader :amount
13
+ attr_reader :kind
14
+ attr_reader :projected_disbursement_date
15
+ attr_reader :actual_disbursement_date
16
+
17
+ def initialize(attributes)
18
+ set_instance_variables_from_hash attributes unless attributes.nil?
19
+ @amount = Util.to_big_decimal(amount)
20
+ end
21
+
22
+ def inspect
23
+ attrs = [:amount, :kind, :projected_disbursement_date, :actual_disbursement_date]
24
+ formatted_attrs = attrs.map do |attr|
25
+ "#{attr}: #{send(attr).inspect}"
26
+ end
27
+
28
+ "#<#{formatted_attrs.join(", ")}>"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ module Braintree
2
+ class Transaction
3
+ class Installment
4
+ include BaseModule
5
+
6
+ attr_reader :id
7
+ attr_reader :amount
8
+ attr_reader :projected_disbursement_date
9
+ attr_reader :actual_disbursement_date
10
+ attr_reader :adjustments
11
+
12
+ def initialize(attributes)
13
+ set_instance_variables_from_hash attributes unless attributes.nil?
14
+ @amount = Util.to_big_decimal(amount)
15
+ adjustments.map! { |attrs| Adjustment.new(attrs) } if adjustments
16
+ end
17
+
18
+ def inspect
19
+ attrs = [:id, :amount, :projected_disbursement_date, :actual_disbursement_date, :adjustments]
20
+ formatted_attrs = attrs.map do |attr|
21
+ "#{attr}: #{send(attr).inspect}"
22
+ end
23
+
24
+ "#<#{formatted_attrs.join(", ")}>"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -4,6 +4,7 @@ module Braintree
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :authorization_id
7
+ attr_reader :billing_agreement_id
7
8
  attr_reader :capture_id
8
9
  attr_reader :custom_field
9
10
  attr_reader :debug_id
@@ -23,6 +24,8 @@ module Braintree
23
24
  attr_reader :refund_from_transaction_fee_currency_iso_code
24
25
  attr_reader :refund_id
25
26
  attr_reader :seller_protection_status
27
+ attr_reader :tax_id
28
+ attr_reader :tax_id_type
26
29
  attr_reader :token
27
30
  attr_reader :transaction_fee_amount
28
31
  attr_reader :transaction_fee_currency_iso_code
@@ -8,6 +8,8 @@ module Braintree
8
8
 
9
9
  def initialize(attributes)
10
10
  set_instance_variables_from_hash attributes unless attributes.nil?
11
+ @billing_period_start_date = Date.parse(billing_period_start_date) unless billing_period_start_date.nil?
12
+ @billing_period_end_date = Date.parse(billing_period_end_date) unless billing_period_end_date.nil?
11
13
  end
12
14
  end
13
15
  end