braintree 4.23.0 → 4.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/address_gateway.rb +5 -0
  3. data/lib/braintree/apple_pay_card.rb +6 -0
  4. data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
  5. data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
  6. data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
  7. data/lib/braintree/bin_data.rb +8 -2
  8. data/lib/braintree/configuration.rb +1 -1
  9. data/lib/braintree/credit_card.rb +12 -5
  10. data/lib/braintree/credit_card_gateway.rb +1 -0
  11. data/lib/braintree/credit_card_verification_gateway.rb +5 -2
  12. data/lib/braintree/customer_session_gateway.rb +195 -0
  13. data/lib/braintree/dispute.rb +1 -0
  14. data/lib/braintree/error_codes.rb +58 -104
  15. data/lib/braintree/error_result.rb +1 -1
  16. data/lib/braintree/errors.rb +2 -1
  17. data/lib/braintree/gateway.rb +12 -0
  18. data/lib/braintree/google_pay_card.rb +5 -0
  19. data/lib/braintree/graphql/enums/recommendations.rb +9 -0
  20. data/lib/braintree/graphql/enums/recommended_payment_option.rb +10 -0
  21. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +44 -0
  22. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +40 -0
  23. data/lib/braintree/graphql/inputs/customer_session_input.rb +45 -0
  24. data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
  25. data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
  26. data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
  27. data/lib/braintree/graphql/inputs/phone_input.rb +34 -0
  28. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +42 -0
  29. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +129 -0
  30. data/lib/braintree/graphql/types/payment_options.rb +35 -0
  31. data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
  32. data/lib/braintree/graphql/unions/customer_recommendations.rb +47 -0
  33. data/lib/braintree/graphql_client.rb +16 -0
  34. data/lib/braintree/merchant_account.rb +1 -25
  35. data/lib/braintree/merchant_account_gateway.rb +0 -81
  36. data/lib/braintree/meta_checkout_card.rb +11 -6
  37. data/lib/braintree/meta_checkout_token.rb +11 -6
  38. data/lib/braintree/payment_method_gateway.rb +9 -0
  39. data/lib/braintree/paypal_payment_resource.rb +22 -0
  40. data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
  41. data/lib/braintree/successful_result.rb +3 -0
  42. data/lib/braintree/test/credit_card.rb +5 -0
  43. data/lib/braintree/transaction/apple_pay_details.rb +7 -0
  44. data/lib/braintree/transaction/credit_card_details.rb +22 -10
  45. data/lib/braintree/transaction/google_pay_details.rb +16 -10
  46. data/lib/braintree/transaction/meta_checkout_card_details.rb +11 -2
  47. data/lib/braintree/transaction/meta_checkout_token_details.rb +13 -3
  48. data/lib/braintree/transaction/paypal_details.rb +2 -0
  49. data/lib/braintree/transaction/visa_checkout_card_details.rb +10 -2
  50. data/lib/braintree/transaction.rb +3 -26
  51. data/lib/braintree/transaction_gateway.rb +52 -31
  52. data/lib/braintree/us_bank_account_verification.rb +3 -1
  53. data/lib/braintree/version.rb +1 -1
  54. data/lib/braintree/visa_checkout_card.rb +10 -5
  55. data/lib/braintree/webhook_notification.rb +1 -4
  56. data/lib/braintree/webhook_testing_gateway.rb +16 -33
  57. data/lib/braintree/xml/{libxml.rb → nokogiri.rb} +18 -16
  58. data/lib/braintree/xml/parser.rb +4 -4
  59. data/lib/braintree.rb +21 -4
  60. data/spec/integration/braintree/advanced_search_spec.rb +7 -4
  61. data/spec/integration/braintree/apple_pay_spec.rb +6 -7
  62. data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
  63. data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
  64. data/spec/integration/braintree/credit_card_spec.rb +115 -1
  65. data/spec/integration/braintree/credit_card_verification_spec.rb +149 -0
  66. data/spec/integration/braintree/customer_session_spec.rb +154 -0
  67. data/spec/integration/braintree/customer_spec.rb +94 -10
  68. data/spec/integration/braintree/disbursement_spec.rb +1 -1
  69. data/spec/integration/braintree/dispute_spec.rb +13 -2
  70. data/spec/integration/braintree/merchant_account_spec.rb +19 -359
  71. data/spec/integration/braintree/merchant_spec.rb +4 -4
  72. data/spec/integration/braintree/payment_method_nonce_spec.rb +55 -0
  73. data/spec/integration/braintree/payment_method_spec.rb +57 -7
  74. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
  75. data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
  76. data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
  77. data/spec/integration/braintree/transaction_search_spec.rb +38 -33
  78. data/spec/integration/braintree/transaction_spec.rb +266 -350
  79. data/spec/integration/braintree/transaction_transfer_type_spec.rb +325 -0
  80. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
  81. data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
  82. data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
  83. data/spec/spec_helper.rb +46 -12
  84. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -0
  85. data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
  86. data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
  87. data/spec/unit/braintree/client_token_spec.rb +11 -0
  88. data/spec/unit/braintree/configuration_spec.rb +1 -1
  89. data/spec/unit/braintree/credit_card_spec.rb +27 -2
  90. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
  91. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
  92. data/spec/unit/braintree/customer_session_gateway_spec.rb +122 -0
  93. data/spec/unit/braintree/customer_spec.rb +2 -1
  94. data/spec/unit/braintree/dispute_spec.rb +6 -0
  95. data/spec/unit/braintree/error_result_spec.rb +28 -0
  96. data/spec/unit/braintree/google_pay_card_spec.rb +28 -0
  97. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +102 -0
  98. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +80 -0
  99. data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
  100. data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
  101. data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
  102. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +107 -0
  103. data/spec/unit/braintree/graphql_client_spec.rb +37 -0
  104. data/spec/unit/braintree/meta_checkout_card_spec.rb +61 -51
  105. data/spec/unit/braintree/meta_checkout_token_spec.rb +7 -1
  106. data/spec/unit/braintree/payment_method_nonce_spec.rb +11 -1
  107. data/spec/unit/braintree/payment_method_spec.rb +12 -0
  108. data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
  109. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +37 -0
  110. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +15 -1
  111. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +37 -0
  112. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +28 -0
  113. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +28 -0
  114. data/spec/unit/braintree/transaction/paypal_details_spec.rb +5 -0
  115. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +28 -0
  116. data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
  117. data/spec/unit/braintree/transaction_gateway_spec.rb +58 -11
  118. data/spec/unit/braintree/transaction_spec.rb +66 -0
  119. data/spec/unit/braintree/visa_checkout_card_spec.rb +28 -0
  120. data/spec/unit/braintree/webhook_notification_spec.rb +15 -51
  121. data/spec/unit/braintree/xml/{libxml_spec.rb → nokogiri_spec.rb} +7 -7
  122. data/spec/unit/braintree/xml/parser_spec.rb +57 -0
  123. data/spec/unit/credit_card_details_spec.rb +28 -0
  124. metadata +49 -10
  125. data/lib/braintree/merchant_account/business_details.rb +0 -17
  126. data/lib/braintree/merchant_account/funding_details.rb +0 -18
  127. data/lib/braintree/merchant_account/individual_details.rb +0 -20
  128. data/lib/ssl/securetrust_ca.crt +0 -44
  129. data/spec/unit/braintree/disbursement_spec.rb +0 -131
  130. data/spec/unit/braintree/merchant_account_spec.rb +0 -33
@@ -0,0 +1,129 @@
1
+ # Represents the customer recommendations information associated with a PayPal customer session.
2
+
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
5
+ module Braintree
6
+ class CustomerRecommendationsPayload
7
+ include BaseModule
8
+
9
+ attr_reader :attrs
10
+ attr_reader :session_id
11
+ attr_reader :is_in_paypal_network
12
+ attr_reader :recommendations
13
+
14
+ def initialize(attributes)
15
+ @attrs = [:session_id, :is_in_paypal_network, :recommendations]
16
+
17
+ if attributes.key?(:response)
18
+ response = attributes[:response]
19
+ # Constructor for response map
20
+ begin
21
+ @session_id = _get_value(response, "generateCustomerRecommendations.sessionId")
22
+ @is_in_paypal_network = _get_value(response, "generateCustomerRecommendations.isInPayPalNetwork")
23
+ @recommendations = _extract_recommendations(response)
24
+ rescue => e
25
+ puts e.backtrace.join("\n")
26
+ raise
27
+ end
28
+ else
29
+ @session_id = attributes[:session_id]
30
+ @is_in_paypal_network = attributes[:is_in_paypal_network]
31
+ @recommendations = attributes[:recommendations]
32
+ end
33
+ end
34
+
35
+ def _extract_recommendations(response)
36
+ begin
37
+ payment_recommendations = _get_value(response, "generateCustomerRecommendations.paymentRecommendations")
38
+
39
+ payment_options_list = []
40
+ payment_recommendations_list = []
41
+
42
+ payment_recommendations.each_with_index do |recommendation, _i|
43
+ recommended_priority = _get_value(recommendation, "recommendedPriority")
44
+ payment_option_string = _get_value(recommendation, "paymentOption")
45
+
46
+ begin
47
+ payment_option = payment_option_string
48
+
49
+ payment_option_obj = Braintree::PaymentOptions._new({
50
+ paymentOption: payment_option,
51
+ recommendedPriority: recommended_priority
52
+ })
53
+
54
+ payment_recommendation_obj = Braintree::PaymentRecommendations._new({
55
+ paymentOption: payment_option,
56
+ recommendedPriority: recommended_priority
57
+ })
58
+
59
+ payment_options_list << payment_option_obj
60
+ payment_recommendations_list << payment_recommendation_obj
61
+ rescue => e
62
+ puts e.backtrace.join("\n")
63
+ raise
64
+ end
65
+ end
66
+
67
+ customer_recommendations = CustomerRecommendations._new({
68
+ payment_recommendations: payment_recommendations_list
69
+ })
70
+
71
+ return customer_recommendations
72
+ rescue => e
73
+ puts e.backtrace.join("\n")
74
+ raise ServerError.new("Error extracting recommendations: #{e.message}")
75
+ end
76
+ end
77
+
78
+ def _get_value(response, key)
79
+ current_map = response
80
+ key_parts = key.split(".")
81
+
82
+ # Navigate through nested dictionaries for all but last key
83
+ (0...key_parts.length - 1).each do |i|
84
+ sub_key = key_parts[i]
85
+ current_map = _pop_value(current_map, sub_key)
86
+ end
87
+
88
+ # Get the final value
89
+ last_key = key_parts[-1]
90
+ value = _pop_value(current_map, last_key)
91
+ return value
92
+ end
93
+
94
+ def _pop_value(response, key)
95
+
96
+ # Try as string first
97
+ if response.key?(key)
98
+ return response[key]
99
+ end
100
+
101
+ # Then try as symbol
102
+ symkey = key.to_sym
103
+ if response.key?(symkey)
104
+ return response[symkey]
105
+ end
106
+
107
+ # Finally try as string with string keys
108
+ if response.key?(key.to_s)
109
+ return response[key.to_s]
110
+ end
111
+
112
+ raise ServerError.new("Couldn't parse response")
113
+ end
114
+ def inspect
115
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
116
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
117
+ end
118
+
119
+ class << self
120
+ protected :new
121
+ end
122
+
123
+ def self._new(*args)
124
+ self.new(*args)
125
+ end
126
+ end
127
+ end
128
+
129
+
@@ -0,0 +1,35 @@
1
+ # Represents the payment method and priority associated with a PayPal customer session.
2
+
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
5
+ module Braintree
6
+ class PaymentOptions
7
+ include BaseModule
8
+
9
+ attr_reader :attrs
10
+ attr_reader :payment_option
11
+ attr_reader :recommended_priority
12
+
13
+ def initialize(attributes)
14
+ @attrs = [:payment_option, :recommended_priority]
15
+ @payment_option = attributes[:paymentOption] if attributes[:paymentOption]
16
+ @recommended_priority = attributes[:recommendedPriority] if attributes[:recommendedPriority]
17
+
18
+ end
19
+
20
+ def inspect
21
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
22
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
23
+ end
24
+
25
+ class << self
26
+ protected :new
27
+ end
28
+
29
+ def self._new(*args)
30
+ self.new(*args)
31
+ end
32
+ end
33
+ end
34
+
35
+
@@ -0,0 +1,35 @@
1
+ # Represents the payment method and priority associated with a PayPal customer session.
2
+
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
5
+ module Braintree
6
+ class PaymentRecommendations
7
+ include BaseModule
8
+
9
+ attr_reader :attrs
10
+ attr_reader :payment_option
11
+ attr_reader :recommended_priority
12
+
13
+ def initialize(attributes)
14
+ @attrs = [:payment_option, :recommended_priority]
15
+ @payment_option = attributes[:paymentOption] if attributes[:paymentOption]
16
+ @recommended_priority = attributes[:recommendedPriority] if attributes[:recommendedPriority]
17
+
18
+ end
19
+
20
+ def inspect
21
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
22
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
23
+ end
24
+
25
+ class << self
26
+ protected :new
27
+ end
28
+
29
+ def self._new(*args)
30
+ self.new(*args)
31
+ end
32
+ end
33
+ end
34
+
35
+
@@ -0,0 +1,47 @@
1
+ # A union of all possible customer recommendations associated with a PayPal customer session.
2
+
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
5
+ module Braintree
6
+ class CustomerRecommendations
7
+ include BaseModule
8
+
9
+ attr_reader :payment_options, :payment_recommendations
10
+
11
+ def initialize(attributes = {})
12
+ @payment_recommendations = initialize_payment_recommendations(attributes[:payment_recommendations])
13
+
14
+ # Always derive payment_options from payment_recommendations
15
+ @payment_options = @payment_recommendations.map do |recommendation|
16
+ PaymentOptions._new(
17
+ paymentOption: recommendation.payment_option,
18
+ recommendedPriority: recommendation.recommended_priority,
19
+ )
20
+ end
21
+ end
22
+
23
+ def inspect
24
+ "#<#{self.class} payment_options: #{payment_options.inspect}, payment_recommendations: #{payment_recommendations.inspect}>"
25
+ end
26
+
27
+ private
28
+
29
+ def initialize_payment_recommendations(payment_recommendations)
30
+ return [] if payment_recommendations.nil?
31
+
32
+ payment_recommendations.map do |recommendation_hash|
33
+ if recommendation_hash.is_a?(PaymentRecommendations)
34
+ recommendation_hash
35
+ else
36
+ PaymentRecommendations._new(recommendation_hash)
37
+ end
38
+ end
39
+ end
40
+
41
+ class << self
42
+ def _new(attributes = {})
43
+ new(attributes)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -30,5 +30,21 @@ module Braintree
30
30
  body = Zlib::GzipReader.new(StringIO.new(body)).read if response.header["Content-Encoding"] == "gzip"
31
31
  JSON.parse(body, :symbolize_names => true)
32
32
  end
33
+
34
+ def self.get_validation_errors(response)
35
+ return nil unless response.key?(:errors) && response[:errors].is_a?(Array)
36
+ validation_errors = response[:errors].map do |error|
37
+ {
38
+ :attribute => "",
39
+ :code => get_validation_error_code(error),
40
+ :message => error[:message]
41
+ }
42
+ end
43
+ {errors: validation_errors}
44
+ end
45
+
46
+ def self.get_validation_error_code(error)
47
+ error[:extensions] && error[:extensions][:legacyCode] rescue nil
48
+ end
33
49
  end
34
50
  end
@@ -18,44 +18,20 @@ module Braintree
18
18
  include Braintree::MerchantAccount::FundingDestination
19
19
  end
20
20
 
21
- attr_reader :business_details
22
21
  attr_reader :currency_iso_code
23
22
  attr_reader :default
24
- attr_reader :funding_details
25
23
  attr_reader :id
26
- attr_reader :individual_details
27
- attr_reader :master_merchant_account
28
24
  attr_reader :status
29
25
 
30
26
  alias_method :default?, :default
31
27
 
32
- def self.create(*args)
33
- Configuration.gateway.merchant_account.create(*args)
34
- end
35
-
36
- def self.create!(*args)
37
- Configuration.gateway.merchant_account.create!(*args)
38
- end
39
-
40
28
  def self.find(*args)
41
29
  Configuration.gateway.merchant_account.find(*args)
42
30
  end
43
31
 
44
- def self.update(*args)
45
- Configuration.gateway.merchant_account.update(*args)
46
- end
47
-
48
- def self.update!(*args)
49
- Configuration.gateway.merchant_account.update!(*args)
50
- end
51
-
52
32
  def initialize(gateway, attributes)
53
33
  @gateway = gateway
54
34
  set_instance_variables_from_hash(attributes)
55
- @individual_details = IndividualDetails.new(@individual)
56
- @business_details = BusinessDetails.new(@business)
57
- @funding_details = FundingDetails.new(@funding)
58
- @master_merchant_account = MerchantAccount._new(@gateway, attributes.delete(:master_merchant_account)) if attributes[:master_merchant_account]
59
35
  end
60
36
 
61
37
  class << self
@@ -66,7 +42,7 @@ module Braintree
66
42
  end
67
43
 
68
44
  def inspect
69
- order = [:id, :status, :master_merchant_account]
45
+ order = [:id, :status]
70
46
  nice_attributes = order.map do |attr|
71
47
  "#{attr}: #{send(attr).inspect}"
72
48
  end
@@ -20,16 +20,6 @@ module Braintree
20
20
  PaginatedResult.new(body[:total_items], body[:page_size], merchant_accounts)
21
21
  end
22
22
 
23
- def create(attributes)
24
- signature = MerchantAccountGateway._detect_signature(attributes)
25
- Util.verify_keys(signature, attributes)
26
- _do_create "/merchant_accounts/create_via_api", :merchant_account => attributes
27
- end
28
-
29
- def create!(*args)
30
- return_object_or_raise(:merchant_account) { create(*args) }
31
- end
32
-
33
23
  def find(merchant_account_id)
34
24
  raise ArgumentError if merchant_account_id.nil? || merchant_account_id.to_s.strip == ""
35
25
  response = @config.http.get("#{@config.base_merchant_path}/merchant_accounts/#{merchant_account_id}")
@@ -38,37 +28,10 @@ module Braintree
38
28
  raise NotFoundError, "Merchant account with id #{merchant_account_id} not found"
39
29
  end
40
30
 
41
- def update(merchant_account_id, attributes)
42
- Util.verify_keys(MerchantAccountGateway._update_signature, attributes)
43
- _do_update "/merchant_accounts/#{merchant_account_id}/update_via_api", :merchant_account => attributes
44
- end
45
-
46
- def update!(*args)
47
- return_object_or_raise(:merchant_account) { update(*args) }
48
- end
49
-
50
31
  def create_for_currency(params)
51
32
  _create_for_currency(params)
52
33
  end
53
34
 
54
- def _do_create(path, params=nil)
55
- response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
56
- if response[:api_error_response]
57
- ErrorResult.new(@gateway, response[:api_error_response])
58
- else
59
- SuccessfulResult.new(:merchant_account => MerchantAccount._new(@gateway, response[:merchant_account]))
60
- end
61
- end
62
-
63
- def _do_update(path, params=nil)
64
- response = @config.http.put("#{@config.base_merchant_path}#{path}", params)
65
- if response[:api_error_response]
66
- ErrorResult.new(@gateway, response[:api_error_response])
67
- else
68
- SuccessfulResult.new(:merchant_account => MerchantAccount._new(@gateway, response[:merchant_account]))
69
- end
70
- end
71
-
72
35
  def _create_for_currency(params)
73
36
  response = @config.http.post("#{@config.base_merchant_path}/merchant_accounts/create_for_currency", :merchant_account => params)
74
37
 
@@ -82,49 +45,5 @@ module Braintree
82
45
  raise UnexpectedError, "expected :merchant or :api_error_response"
83
46
  end
84
47
  end
85
-
86
- # NEXT_MAJOR_VERSION this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code
87
- def self._detect_signature(attributes)
88
- if attributes.has_key?(:applicant_details)
89
- warn "[DEPRECATED] Passing :applicant_details to create is deprecated. Please use :individual, :business, and :funding."
90
- MerchantAccountGateway._deprecated_create_signature
91
- else
92
- MerchantAccountGateway._create_signature
93
- end
94
- end
95
-
96
- # NEXT_MAJOR_VERSION this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code
97
- def self._deprecated_create_signature
98
- [
99
- {:applicant_details => [
100
- :first_name, :last_name, :email, :date_of_birth, :ssn, :routing_number,
101
- :account_number, :tax_id, :company_name, :phone,
102
- {:address => [:street_address, :postal_code, :locality, :region]}]
103
- },
104
- :tos_accepted, :master_merchant_account_id, :id
105
- ]
106
- end
107
-
108
- def self._signature
109
- [
110
- {:individual => [
111
- :first_name, :last_name, :email, :date_of_birth, :ssn, :phone,
112
- {:address => [:street_address, :locality, :region, :postal_code]}]
113
- },
114
- {:business => [
115
- :dba_name, :legal_name, :tax_id,
116
- {:address => [:street_address, :locality, :region, :postal_code]}]
117
- },
118
- {:funding => [:destination, :email, :mobile_phone, :routing_number, :account_number, :descriptor]}
119
- ]
120
- end
121
-
122
- def self._create_signature
123
- _signature + [:tos_accepted, :master_merchant_account_id, :id]
124
- end
125
-
126
- def self._update_signature
127
- _signature
128
- end
129
48
  end
130
49
  end
@@ -4,10 +4,13 @@ module Braintree
4
4
  include Braintree::Util::TokenEquality
5
5
 
6
6
  attr_reader :bin
7
- attr_reader :container_id
7
+ attr_reader :business
8
8
  attr_reader :card_type
9
9
  attr_reader :cardholder_name
10
10
  attr_reader :commercial
11
+ attr_reader :consumer
12
+ attr_reader :container_id
13
+ attr_reader :corporate
11
14
  attr_reader :country_of_issuance
12
15
  attr_reader :created_at
13
16
  attr_reader :customer_id
@@ -22,7 +25,9 @@ module Braintree
22
25
  attr_reader :last_4
23
26
  attr_reader :payroll
24
27
  attr_reader :prepaid
28
+ attr_reader :prepaid_reloadable
25
29
  attr_reader :product_id
30
+ attr_reader :purchase
26
31
  attr_reader :subscriptions
27
32
  attr_reader :token
28
33
  attr_reader :unique_number_identifier
@@ -74,11 +79,11 @@ module Braintree
74
79
 
75
80
  def self._attributes # :nodoc:
76
81
  [
77
- :bin, :card_type, :cardholder_name, :created_at,
78
- :customer_id, :customer_location, :expiration_month, :expiration_year,
79
- :last_4, :token, :updated_at, :prepaid, :payroll, :product_id,
80
- :commercial, :debit, :durbin_regulated, :healthcare,
81
- :country_of_issuance, :issuing_bank, :image_url, :container_id
82
+ :bin, :business, :card_type, :cardholder_name, :commercial,
83
+ :consumer, :container_id, :corporate, :country_of_issuance, :created_at, :customer_id,
84
+ :customer_location, :debit, :durbin_regulated, :expiration_month,
85
+ :expiration_year, :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid,
86
+ :prepaid_reloadable, :product_id, :purchase, :token, :updated_at
82
87
  ]
83
88
  end
84
89
 
@@ -4,10 +4,13 @@ module Braintree
4
4
  include Braintree::Util::TokenEquality
5
5
 
6
6
  attr_reader :bin
7
- attr_reader :container_id
7
+ attr_reader :business
8
8
  attr_reader :card_type
9
9
  attr_reader :cardholder_name
10
10
  attr_reader :commercial
11
+ attr_reader :consumer
12
+ attr_reader :container_id
13
+ attr_reader :corporate
11
14
  attr_reader :country_of_issuance
12
15
  attr_reader :created_at
13
16
  attr_reader :cryptogram
@@ -24,7 +27,9 @@ module Braintree
24
27
  attr_reader :last_4
25
28
  attr_reader :payroll
26
29
  attr_reader :prepaid
30
+ attr_reader :prepaid_reloadable
27
31
  attr_reader :product_id
32
+ attr_reader :purchase
28
33
  attr_reader :token
29
34
  attr_reader :unique_number_identifier
30
35
  attr_reader :updated_at
@@ -73,11 +78,11 @@ module Braintree
73
78
 
74
79
  def self._attributes # :nodoc:
75
80
  [
76
- :bin, :card_type, :cardholder_name, :created_at,
77
- :customer_id, :customer_location, :expiration_month, :expiration_year,
78
- :last_4, :token, :updated_at, :prepaid, :payroll, :product_id,
79
- :commercial, :debit, :durbin_regulated, :healthcare, :ecommerce_indicator,
80
- :country_of_issuance, :issuing_bank, :image_url, :container_id, :cryptogram
81
+ :bin, :business, :card_type, :cardholder_name, :commercial, :consumer, :container_id,
82
+ :corporate, :country_of_issuance, :created_at, :cryptogram, :customer_id, :customer_location,
83
+ :debit, :durbin_regulated, :ecommerce_indicator, :expiration_month, :expiration_year,
84
+ :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
85
+ :product_id, :purchase, :token, :updated_at
81
86
  ]
82
87
  end
83
88
 
@@ -160,6 +160,7 @@ module Braintree
160
160
  # NEXT_MAJOR_VERSION Remove venmo_sdk_session
161
161
  # The old venmo SDK class has been deprecated
162
162
  options = [
163
+ :account_information_inquiry,
163
164
  :make_default,
164
165
  :skip_advanced_fraud_checking,
165
166
  :us_bank_account_verification_method,
@@ -200,16 +201,24 @@ module Braintree
200
201
  :ds_transaction_id,
201
202
  ]
202
203
  }
204
+ signature << {
205
+ :us_bank_account => [
206
+ :ach_mandate_text,
207
+ :ach_mandate_accepted_at,
208
+ ]
209
+ }
203
210
 
204
211
  case type
205
212
  when :create
206
213
  options << :fail_on_duplicate_payment_method
207
214
  options << :fail_on_duplicate_payment_method_for_customer
215
+ options << :accountInformationInquiry
208
216
  signature << :customer_id
209
217
  signature << :paypal_refresh_token
210
218
  when :update
211
219
  options << :fail_on_duplicate_payment_method
212
220
  options << :fail_on_duplicate_payment_method_for_customer
221
+ options << :accountInformationInquiry
213
222
  billing_address_params << {:options => [:update_existing]}
214
223
  else
215
224
  raise ArgumentError
@@ -0,0 +1,22 @@
1
+ module Braintree
2
+ class PayPalPaymentResource
3
+ include BaseModule
4
+
5
+ def self.update(*args)
6
+ Configuration.gateway.paypal_payment_resource.update(*args)
7
+ end
8
+
9
+ class << self
10
+ protected :new
11
+ def _new(*args)
12
+ self.new(*args)
13
+ end
14
+ end
15
+
16
+ def initialize(gateway, attributes)
17
+ @gateway = gateway
18
+ set_instance_variables_from_hash(attributes)
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,36 @@
1
+ module Braintree
2
+ class PayPalPaymentResourceGateway
3
+ include BaseModule
4
+
5
+ def initialize(gateway)
6
+ @gateway = gateway
7
+ @config = gateway.config
8
+ @config.assert_has_access_token_or_keys
9
+ end
10
+
11
+ def update(attributes)
12
+ Util.verify_keys(PayPalPaymentResourceGateway._update_signature, attributes)
13
+ response = @config.http.put("#{@config.base_merchant_path}/paypal/payment_resource", :paypal_payment_resource => attributes)
14
+ if response[:payment_method_nonce]
15
+ SuccessfulResult.new(:payment_method_nonce => PaymentMethodNonce._new(@gateway, response[:payment_method_nonce]))
16
+ elsif response[:api_error_response]
17
+ ErrorResult.new(@gateway, response[:api_error_response])
18
+ else
19
+ raise UnexpectedError, "expected :paypal_payment_resource or :api_error_response"
20
+ end
21
+ end
22
+
23
+ def self._update_signature
24
+ [
25
+ :amount,
26
+ {:amount_breakdown => [:discount, :handling, :insurance, :item_total, :shipping, :shipping_discount, :tax_total]},
27
+ :currency_iso_code, :custom_field, :description,
28
+ {:line_items => [:description, :image_url, :kind, :name, :product_code, :quantity, :total_amount, :unit_amount, :unit_tax_amount, :url]},
29
+ :order_id, :payee_email, :payment_method_nonce,
30
+ {:shipping => [:country_name, :country_code_alpha2, :country_code_alpha3, :country_code_numeric, :extended_address, :first_name, {:international_phone => [:country_code, :national_number]},
31
+ :last_name, :locality, :postal_code, :region, :street_address]},
32
+ {:shipping_options => [:amount, :id, :label, :selected, :type]}
33
+ ]
34
+ end
35
+ end
36
+ end
@@ -23,7 +23,10 @@ module Braintree
23
23
  attr_reader :subscription
24
24
  attr_reader :supported_networks
25
25
  attr_reader :transaction
26
+ attr_reader :bank_account_instant_verification_jwt
26
27
  attr_reader :us_bank_account_verification
28
+ attr_reader :session_id
29
+ attr_reader :customer_recommendations
27
30
 
28
31
  def initialize(attributes = {})
29
32
  @attrs = attributes.keys
@@ -3,8 +3,13 @@ module Braintree
3
3
  module CreditCardNumbers
4
4
  module CardTypeIndicators
5
5
  Prepaid = "4111111111111210"
6
+ PrepaidReloadable = "4229989900000002"
7
+ Business = "4229989800000003"
6
8
  Commercial = "4111111111131010"
9
+ Consumer = "4229989700000004"
10
+ Corporate = "4229989100000000"
7
11
  Payroll = "4111111114101010"
12
+ Purchase = "4229989500000006"
8
13
  Healthcare = "4111111510101010"
9
14
  DurbinRegulated = "4111161010101010"
10
15
  Debit = "4117101010101010"
@@ -4,9 +4,12 @@ module Braintree
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :bin
7
+ attr_reader :business
7
8
  attr_reader :card_type
8
9
  attr_reader :cardholder_name
9
10
  attr_reader :commercial
11
+ attr_reader :consumer
12
+ attr_reader :corporate
10
13
  attr_reader :country_of_issuance
11
14
  attr_reader :debit
12
15
  attr_reader :durbin_regulated
@@ -15,13 +18,17 @@ module Braintree
15
18
  attr_reader :global_id
16
19
  attr_reader :healthcare
17
20
  attr_reader :image_url
21
+ attr_reader :is_device_token
18
22
  attr_reader :issuing_bank
19
23
  attr_reader :last_4
20
24
  attr_reader :merchant_token_identifier
25
+ attr_reader :payment_account_reference
21
26
  attr_reader :payment_instrument_name
22
27
  attr_reader :payroll
23
28
  attr_reader :prepaid
29
+ attr_reader :prepaid_reloadable
24
30
  attr_reader :product_id
31
+ attr_reader :purchase
25
32
  attr_reader :source_card_last4
26
33
  attr_reader :source_description
27
34
  attr_reader :token