braintree 4.27.0 → 4.28.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/apple_pay_card.rb +4 -0
  3. data/lib/braintree/bin_data.rb +7 -2
  4. data/lib/braintree/credit_card.rb +11 -5
  5. data/lib/braintree/credit_card_gateway.rb +1 -0
  6. data/lib/braintree/credit_card_verification_gateway.rb +1 -0
  7. data/lib/braintree/customer_session_gateway.rb +11 -10
  8. data/lib/braintree/google_pay_card.rb +4 -0
  9. data/lib/braintree/graphql/enums/recommendations.rb +2 -0
  10. data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
  11. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
  12. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
  13. data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -0
  14. data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
  15. data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
  16. data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
  17. data/lib/braintree/graphql/inputs/phone_input.rb +2 -0
  18. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
  19. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
  20. data/lib/braintree/graphql/types/payment_options.rb +2 -0
  21. data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
  22. data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
  23. data/lib/braintree/meta_checkout_card.rb +8 -4
  24. data/lib/braintree/meta_checkout_token.rb +10 -6
  25. data/lib/braintree/payment_method_gateway.rb +3 -0
  26. data/lib/braintree/test/credit_card.rb +4 -0
  27. data/lib/braintree/transaction/apple_pay_details.rb +4 -0
  28. data/lib/braintree/transaction/credit_card_details.rb +8 -0
  29. data/lib/braintree/transaction/google_pay_details.rb +4 -0
  30. data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
  31. data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
  32. data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
  33. data/lib/braintree/version.rb +1 -1
  34. data/lib/braintree/visa_checkout_card.rb +9 -4
  35. data/lib/braintree.rb +4 -0
  36. data/spec/integration/braintree/credit_card_spec.rb +101 -0
  37. data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
  38. data/spec/integration/braintree/customer_session_spec.rb +59 -49
  39. data/spec/integration/braintree/customer_spec.rb +71 -4
  40. data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
  41. data/spec/integration/braintree/payment_method_spec.rb +47 -0
  42. data/spec/integration/braintree/transaction_spec.rb +61 -25
  43. data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
  44. data/spec/unit/braintree/credit_card_spec.rb +22 -2
  45. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
  46. data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
  47. data/spec/unit/braintree/customer_spec.rb +2 -1
  48. data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
  49. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
  50. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
  51. data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
  52. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
  53. data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
  54. data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
  55. data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
  56. data/spec/unit/braintree/payment_method_spec.rb +12 -0
  57. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
  58. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
  59. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
  60. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
  61. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
  62. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
  63. data/spec/unit/braintree/transaction_spec.rb +8 -0
  64. data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
  65. data/spec/unit/credit_card_details_spec.rb +20 -0
  66. metadata +7 -2
@@ -1,34 +1,47 @@
1
1
  # A union of all possible customer recommendations associated with a PayPal customer session.
2
2
 
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
3
5
  module Braintree
4
- class CustomerRecommendations
5
- include BaseModule
6
-
7
- attr_reader :attrs
8
- attr_reader :payment_options
9
-
10
- def initialize(attributes)
11
- @attrs = [:payment_options]
12
- if attributes.nil?
13
- @payment_options = []
14
- else
15
- @payment_options = (attributes[:paymentOptions] || []).map { |payment_options_hash| PaymentOptions._new(payment_options_hash) }
16
- end
17
- end
6
+ class CustomerRecommendations
7
+ include BaseModule
18
8
 
19
- def inspect
20
- inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
21
- "#<#{self.class} #{inspected_attributes.join(" ")}>"
22
- end
9
+ attr_reader :payment_options, :payment_recommendations
23
10
 
24
- class << self
25
- protected :new
26
- end
11
+ def initialize(attributes = {})
12
+ @payment_recommendations = initialize_payment_recommendations(attributes[:payment_recommendations])
27
13
 
28
- def self._new(*args)
29
- self.new(*args)
30
- end
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}>"
31
25
  end
32
- end
33
26
 
27
+ private
34
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
@@ -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
@@ -24,6 +27,7 @@ module Braintree
24
27
  attr_reader :prepaid
25
28
  attr_reader :prepaid_reloadable
26
29
  attr_reader :product_id
30
+ attr_reader :purchase
27
31
  attr_reader :subscriptions
28
32
  attr_reader :token
29
33
  attr_reader :unique_number_identifier
@@ -75,11 +79,11 @@ module Braintree
75
79
 
76
80
  def self._attributes # :nodoc:
77
81
  [
78
- :bin, :card_type, :cardholder_name, :commercial,
79
- :container_id, :country_of_issuance, :created_at, :customer_id,
82
+ :bin, :business, :card_type, :cardholder_name, :commercial,
83
+ :consumer, :container_id, :corporate, :country_of_issuance, :created_at, :customer_id,
80
84
  :customer_location, :debit, :durbin_regulated, :expiration_month,
81
85
  :expiration_year, :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid,
82
- :prepaid_reloadable, :product_id, :token, :updated_at
86
+ :prepaid_reloadable, :product_id, :purchase, :token, :updated_at
83
87
  ]
84
88
  end
85
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
@@ -26,6 +29,7 @@ module Braintree
26
29
  attr_reader :prepaid
27
30
  attr_reader :prepaid_reloadable
28
31
  attr_reader :product_id
32
+ attr_reader :purchase
29
33
  attr_reader :token
30
34
  attr_reader :unique_number_identifier
31
35
  attr_reader :updated_at
@@ -74,11 +78,11 @@ module Braintree
74
78
 
75
79
  def self._attributes # :nodoc:
76
80
  [
77
- :bin, :card_type, :cardholder_name, :commercial, :container_id, :country_of_issuance,
78
- :created_at, :cryptogram, :customer_id, :customer_location, :debit, :durbin_regulated,
79
- :ecommerce_indicator, :expiration_month, :expiration_year, :healthcare, :image_url,
80
- :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable, :product_id, :token,
81
- :updated_at
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
82
86
  ]
83
87
  end
84
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,
@@ -205,11 +206,13 @@ module Braintree
205
206
  when :create
206
207
  options << :fail_on_duplicate_payment_method
207
208
  options << :fail_on_duplicate_payment_method_for_customer
209
+ options << :accountInformationInquiry
208
210
  signature << :customer_id
209
211
  signature << :paypal_refresh_token
210
212
  when :update
211
213
  options << :fail_on_duplicate_payment_method
212
214
  options << :fail_on_duplicate_payment_method_for_customer
215
+ options << :accountInformationInquiry
213
216
  billing_address_params << {:options => [:update_existing]}
214
217
  else
215
218
  raise ArgumentError
@@ -4,8 +4,12 @@ module Braintree
4
4
  module CardTypeIndicators
5
5
  Prepaid = "4111111111111210"
6
6
  PrepaidReloadable = "4229989900000002"
7
+ Business = "4229989800000003"
7
8
  Commercial = "4111111111131010"
9
+ Consumer = "4229989700000004"
10
+ Corporate = "4229989100000000"
8
11
  Payroll = "4111111114101010"
12
+ Purchase = "4229989500000006"
9
13
  Healthcare = "4111111510101010"
10
14
  DurbinRegulated = "4111161010101010"
11
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
@@ -23,6 +26,7 @@ module Braintree
23
26
  attr_reader :prepaid
24
27
  attr_reader :prepaid_reloadable
25
28
  attr_reader :product_id
29
+ attr_reader :purchase
26
30
  attr_reader :source_card_last4
27
31
  attr_reader :source_description
28
32
  attr_reader :token
@@ -5,9 +5,12 @@ module Braintree
5
5
 
6
6
  attr_reader :account_type
7
7
  attr_reader :bin
8
+ attr_reader :business
8
9
  attr_reader :card_type
9
10
  attr_reader :cardholder_name
10
11
  attr_reader :commercial
12
+ attr_reader :consumer
13
+ attr_reader :corporate
11
14
  attr_reader :country_of_issuance
12
15
  attr_reader :customer_location
13
16
  attr_reader :debit
@@ -22,6 +25,7 @@ module Braintree
22
25
  attr_reader :prepaid
23
26
  attr_reader :prepaid_reloadable
24
27
  attr_reader :product_id
28
+ attr_reader :purchase
25
29
  attr_reader :token
26
30
  attr_reader :unique_number_identifier
27
31
 
@@ -36,9 +40,12 @@ module Braintree
36
40
  def inspect
37
41
  attr_order = [
38
42
  :bin,
43
+ :business,
39
44
  :card_type,
40
45
  :cardholder_name,
41
46
  :commercial,
47
+ :consumer,
48
+ :corporate,
42
49
  :country_of_issuance,
43
50
  :customer_location,
44
51
  :debit,
@@ -52,6 +59,7 @@ module Braintree
52
59
  :prepaid,
53
60
  :prepaid_reloadable,
54
61
  :product_id,
62
+ :purchase,
55
63
  :token,
56
64
  :unique_number_identifier,
57
65
  ]
@@ -4,8 +4,11 @@ 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 :commercial
10
+ attr_reader :consumer
11
+ attr_reader :corporate
9
12
  attr_reader :country_of_issuance
10
13
  attr_reader :debit
11
14
  attr_reader :durbin_regulated
@@ -21,6 +24,7 @@ module Braintree
21
24
  attr_reader :prepaid
22
25
  attr_reader :prepaid_reloadable
23
26
  attr_reader :product_id
27
+ attr_reader :purchase
24
28
  attr_reader :source_card_last_4
25
29
  attr_reader :source_card_type
26
30
  attr_reader :source_description
@@ -4,10 +4,13 @@ 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
10
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_location
@@ -24,6 +27,7 @@ module Braintree
24
27
  attr_reader :prepaid
25
28
  attr_reader :prepaid_reloadable
26
29
  attr_reader :product_id
30
+ attr_reader :purchase
27
31
  attr_reader :token
28
32
  attr_reader :unique_number_identifier
29
33
  attr_reader :updated_at
@@ -38,9 +42,11 @@ module Braintree
38
42
 
39
43
  def inspect
40
44
  attr_order = [
41
- :bin, :card_type, :cardholder_name, :commercial, :container_id, :country_of_issuance,
42
- :customer_location, :debit, :durbin_regulated, :expiration_date, :healthcare, :image_url,
43
- :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable, :product_id, :token]
45
+ :bin, :business, :card_type, :cardholder_name, :commercial, :consumer, :container_id,
46
+ :corporate, :country_of_issuance, :customer_location, :debit, :durbin_regulated,
47
+ :expiration_date, :healthcare, :image_url, :issuing_bank, :last_4, :payroll,
48
+ :prepaid, :prepaid_reloadable, :product_id, :purchase, :token
49
+ ]
44
50
  formatted_attrs = attr_order.map do |attr|
45
51
  "#{attr}: #{send(attr).inspect}"
46
52
  end
@@ -4,10 +4,13 @@ module Braintree
4
4
  include BaseModule
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
@@ -26,6 +29,7 @@ module Braintree
26
29
  attr_reader :prepaid
27
30
  attr_reader :prepaid_reloadable
28
31
  attr_reader :product_id
32
+ attr_reader :purchase
29
33
  attr_reader :token
30
34
  attr_reader :unique_number_identifier
31
35
  attr_reader :updated_at
@@ -40,10 +44,12 @@ module Braintree
40
44
 
41
45
  def inspect
42
46
  attr_order = [
43
- :bin, :card_type, :cardholder_name, :commercial, :container_id, :country_of_issuance,
44
- :cryptogram, :customer_location, :debit, :durbin_regulated, :ecommerce_indicator,
45
- :expiration_date, :healthcare, :image_url, :is_network_tokenized, :issuing_bank, :last_4,
46
- :payroll, :prepaid, :prepaid_reloadable, :product_id, :token]
47
+ :bin, :business, :card_type, :cardholder_name, :commercial, :consumer, :container_id,
48
+ :corporate, :country_of_issuance, :cryptogram, :customer_location, :debit,
49
+ :durbin_regulated, :ecommerce_indicator, :expiration_date, :healthcare, :image_url,
50
+ :is_network_tokenized, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
51
+ :product_id, :purchase, :token
52
+ ]
47
53
  formatted_attrs = attr_order.map do |attr|
48
54
  "#{attr}: #{send(attr).inspect}"
49
55
  end
@@ -4,10 +4,13 @@ module Braintree
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :bin
7
+ attr_reader :business
7
8
  attr_reader :call_id
8
9
  attr_reader :card_type
9
10
  attr_reader :cardholder_name
10
11
  attr_reader :commercial
12
+ attr_reader :consumer
13
+ attr_reader :corporate
11
14
  attr_reader :country_of_issuance
12
15
  attr_reader :customer_location
13
16
  attr_reader :debit
@@ -22,6 +25,7 @@ module Braintree
22
25
  attr_reader :prepaid
23
26
  attr_reader :prepaid_reloadable
24
27
  attr_reader :product_id
28
+ attr_reader :purchase
25
29
  attr_reader :token
26
30
 
27
31
  def initialize(attributes)
@@ -34,9 +38,10 @@ module Braintree
34
38
 
35
39
  def inspect
36
40
  attr_order = [
37
- :bin, :call_id, :card_type, :cardholder_name, :commercial, :country_of_issuance, :customer_location,
38
- :debit, :durbin_regulated, :expiration_date, :healthcare, :image_url, :issuing_bank, :last_4, :payroll,
39
- :prepaid, :prepaid_reloadable, :product_id, :token]
41
+ :bin, :business, :call_id, :card_type, :cardholder_name, :commercial, :consumer, :corporate,
42
+ :country_of_issuance, :customer_location, :debit, :durbin_regulated, :expiration_date,
43
+ :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
44
+ :product_id, :purchase, :token]
40
45
  formatted_attrs = attr_order.map do |attr|
41
46
  "#{attr}: #{send(attr).inspect}"
42
47
  end
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 27
4
+ Minor = 28
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -5,10 +5,13 @@ module Braintree
5
5
 
6
6
  attr_reader :billing_address
7
7
  attr_reader :bin
8
+ attr_reader :business
8
9
  attr_reader :call_id
9
10
  attr_reader :card_type
10
11
  attr_reader :cardholder_name
11
12
  attr_reader :commercial
13
+ attr_reader :consumer
14
+ attr_reader :corporate
12
15
  attr_reader :country_of_issuance
13
16
  attr_reader :created_at
14
17
  attr_reader :customer_id
@@ -25,6 +28,7 @@ module Braintree
25
28
  attr_reader :prepaid
26
29
  attr_reader :prepaid_reloadable
27
30
  attr_reader :product_id
31
+ attr_reader :purchase
28
32
  attr_reader :subscriptions
29
33
  attr_reader :token
30
34
  attr_reader :unique_number_identifier
@@ -76,10 +80,11 @@ module Braintree
76
80
 
77
81
  def self._attributes
78
82
  [
79
- :bin, :billing_address, :card_type, :cardholder_name, :commercial, :container_id, :country_of_issuance,
80
- :created_at, :customer_id, :customer_location, :debit, :durbin_regulated, :expiration_month,
81
- :expiration_year, :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid,
82
- :prepaid_reloadable, :product_id, :token, :updated_at
83
+ :bin, :billing_address, :business, :card_type, :cardholder_name, :commercial,
84
+ :consumer, :container_id, :corporate, :country_of_issuance, :created_at, :customer_id,
85
+ :customer_location, :debit, :durbin_regulated, :expiration_month, :expiration_year,
86
+ :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
87
+ :product_id, :purchase, :token, :updated_at
83
88
  ]
84
89
  end
85
90
 
data/lib/braintree.rb CHANGED
@@ -83,8 +83,12 @@ require "braintree/graphql/inputs/customer_recommendations_input"
83
83
  require "braintree/graphql/inputs/customer_session_input"
84
84
  require "braintree/graphql/inputs/phone_input"
85
85
  require "braintree/graphql/inputs/update_customer_session_input"
86
+ require "braintree/graphql/inputs/paypal_purchase_unit_input"
87
+ require "braintree/graphql/inputs/paypal_payee_input"
88
+ require "braintree/graphql/inputs/monetary_amount_input"
86
89
  require "braintree/graphql/types/customer_recommendations_payload"
87
90
  require "braintree/graphql/types/payment_options"
91
+ require "braintree/graphql/types/payment_recommendations"
88
92
  require "braintree/graphql/unions/customer_recommendations"
89
93
  require "braintree/graphql_client"
90
94
  require "braintree/google_pay_card"
@@ -461,6 +461,54 @@ describe Braintree::CreditCard do
461
461
  expect(credit_card.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
462
462
  end
463
463
 
464
+ it "sets the business field if the card is business" do
465
+ customer = Braintree::Customer.create!
466
+ result = Braintree::CreditCard.create(
467
+ :customer_id => customer.id,
468
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
469
+ :expiration_date => "05/2014",
470
+ :options => {:verify_card => true},
471
+ )
472
+ credit_card = result.credit_card
473
+ expect(credit_card.business).to eq(Braintree::CreditCard::Business::Yes)
474
+ end
475
+
476
+ it "sets the consumer field if the card is consumer" do
477
+ customer = Braintree::Customer.create!
478
+ result = Braintree::CreditCard.create(
479
+ :customer_id => customer.id,
480
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
481
+ :expiration_date => "05/2014",
482
+ :options => {:verify_card => true},
483
+ )
484
+ credit_card = result.credit_card
485
+ expect(credit_card.consumer).to eq(Braintree::CreditCard::Consumer::Yes)
486
+ end
487
+
488
+ it "sets the corporate field if the card is corporate" do
489
+ customer = Braintree::Customer.create!
490
+ result = Braintree::CreditCard.create(
491
+ :customer_id => customer.id,
492
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
493
+ :expiration_date => "05/2014",
494
+ :options => {:verify_card => true},
495
+ )
496
+ credit_card = result.credit_card
497
+ expect(credit_card.corporate).to eq(Braintree::CreditCard::Corporate::Yes)
498
+ end
499
+
500
+ it "sets the purchase field if the card is purchase" do
501
+ customer = Braintree::Customer.create!
502
+ result = Braintree::CreditCard.create(
503
+ :customer_id => customer.id,
504
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
505
+ :expiration_date => "05/2014",
506
+ :options => {:verify_card => true},
507
+ )
508
+ credit_card = result.credit_card
509
+ expect(credit_card.purchase).to eq(Braintree::CreditCard::Purchase::Yes)
510
+ end
511
+
464
512
  it "sets the healthcare field if the card is healthcare" do
465
513
  customer = Braintree::Customer.create!
466
514
  result = Braintree::CreditCard.create(
@@ -1450,4 +1498,57 @@ describe Braintree::CreditCard do
1450
1498
  expect(credit_card_vaulted.is_network_tokenized?).to eq(false)
1451
1499
  end
1452
1500
  end
1501
+
1502
+ describe "account information inquiry" do
1503
+ it "includes ani response when account information inquiry is sent in options" do
1504
+ customer = Braintree::Customer.create!
1505
+ result = Braintree::CreditCard.create(
1506
+ :cardholder_name => "John Doe",
1507
+ :customer_id => customer.id,
1508
+ :cvv => "123",
1509
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1510
+ :expiration_date => "05/2027",
1511
+ :billing_address => {
1512
+ :first_name => "John",
1513
+ :last_name => "Doe",
1514
+ },
1515
+ :options => {
1516
+ :account_information_inquiry => "send_data",
1517
+ :verify_card => true,
1518
+ },
1519
+ )
1520
+
1521
+ expect(result).to be_success
1522
+ verification = result.credit_card.verification
1523
+ expect(verification.ani_first_name_response_code).not_to be_nil
1524
+ expect(verification.ani_last_name_response_code).not_to be_nil
1525
+ end
1526
+
1527
+ it "includes ani response after updating the options with account information inquiry" do
1528
+ customer = Braintree::Customer.create!
1529
+ credit_card = Braintree::CreditCard.create!(
1530
+ :cardholder_name => "Original Holder",
1531
+ :customer_id => customer.id,
1532
+ :cvv => "123",
1533
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1534
+ :expiration_date => "05/2027",
1535
+ )
1536
+ updated_result = Braintree::CreditCard.update(credit_card.token,
1537
+ :options => {
1538
+ :verify_card => true,
1539
+ :account_information_inquiry => "send_data",
1540
+ },
1541
+ )
1542
+
1543
+ expect(updated_result).to be_success
1544
+ verification = updated_result.credit_card.verification
1545
+ expect(verification.ani_first_name_response_code).not_to be_nil
1546
+ expect(verification.ani_last_name_response_code).not_to be_nil
1547
+ end
1548
+ end
1453
1549
  end
1550
+
1551
+
1552
+
1553
+
1554
+