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
data/lib/braintree.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'base64'
1
+ require "base64"
2
2
  require "bigdecimal"
3
3
  require "cgi"
4
4
  require "date"
@@ -31,8 +31,6 @@ require "braintree/address"
31
31
  require "braintree/address/country_names"
32
32
  require "braintree/address_gateway"
33
33
  require "braintree/advanced_search"
34
- require "braintree/android_pay_card"
35
- require "braintree/amex_express_checkout_card"
36
34
  require "braintree/apple_pay"
37
35
  require "braintree/apple_pay_card"
38
36
  require "braintree/apple_pay_gateway"
@@ -41,7 +39,6 @@ require "braintree/authorization_adjustment"
41
39
  require "braintree/bin_data"
42
40
  require "braintree/client_token"
43
41
  require "braintree/client_token_gateway"
44
- require "braintree/coinbase_account"
45
42
  require "braintree/configuration"
46
43
  require "braintree/connected_merchant_status_transitioned"
47
44
  require "braintree/connected_merchant_paypal_status_changed"
@@ -62,20 +59,29 @@ require "braintree/discount_gateway"
62
59
  require "braintree/dispute"
63
60
  require "braintree/dispute_gateway"
64
61
  require "braintree/dispute/evidence"
65
- require "braintree/dispute/history_event"
62
+ require "braintree/dispute/paypal_message"
63
+ require "braintree/dispute/status_history"
66
64
  require "braintree/dispute/transaction"
67
65
  require "braintree/dispute/transaction_details"
68
66
  require "braintree/document_upload"
69
67
  require "braintree/document_upload_gateway"
68
+ require "braintree/enriched_customer_data"
70
69
  require "braintree/error_codes"
71
70
  require "braintree/error_result"
72
71
  require "braintree/errors"
72
+ require "braintree/exchange_rate"
73
+ require "braintree/exchange_rate_quote"
74
+ require "braintree/exchange_rate_quote_gateway"
75
+ require "braintree/exchange_rate_quote_input"
76
+ require "braintree/exchange_rate_quote_response"
77
+ require "braintree/exchange_rate_quote_request"
73
78
  require "braintree/gateway"
74
79
  require "braintree/graphql_client"
75
- require "braintree/ideal_payment"
76
- require "braintree/ideal_payment_gateway"
77
- require "braintree/transaction/ideal_payment_details"
80
+ require "braintree/google_pay_card"
78
81
  require "braintree/local_payment_completed"
82
+ require "braintree/local_payment_reversed"
83
+ require "braintree/local_payment_expired"
84
+ require "braintree/local_payment_funded"
79
85
  require "braintree/transaction/local_payment_details"
80
86
  require "braintree/merchant"
81
87
  require "braintree/merchant_gateway"
@@ -89,8 +95,11 @@ require "braintree/oauth_gateway"
89
95
  require "braintree/oauth_credentials"
90
96
  require "braintree/payment_instrument_type"
91
97
  require "braintree/payment_method"
98
+ require "braintree/payment_method_customer_data_updated_metadata"
92
99
  require "braintree/payment_method_gateway"
93
100
  require "braintree/payment_method_nonce"
101
+ require "braintree/payment_method_nonce_details"
102
+ require "braintree/payment_method_nonce_details_payer_info"
94
103
  require "braintree/payment_method_nonce_gateway"
95
104
  require "braintree/payment_method_parser"
96
105
  require "braintree/paypal_account"
@@ -99,6 +108,7 @@ require "braintree/plan"
99
108
  require "braintree/plan_gateway"
100
109
  require "braintree/processor_response_types"
101
110
  require "braintree/risk_data"
111
+ require "braintree/risk_data/liability_shift"
102
112
  require "braintree/facilitated_details"
103
113
  require "braintree/facilitator_details"
104
114
  require "braintree/three_d_secure_info"
@@ -108,8 +118,6 @@ require "braintree/resource_collection"
108
118
  require "braintree/revoked_payment_method_metadata"
109
119
  require "braintree/paginated_collection"
110
120
  require "braintree/paginated_result"
111
- require "braintree/europe_bank_account"
112
- require "braintree/europe_bank_account_gateway"
113
121
  require "braintree/us_bank_account"
114
122
  require "braintree/us_bank_account_verification"
115
123
  require "braintree/us_bank_account_verification_gateway"
@@ -129,39 +137,36 @@ require "braintree/test/venmo_sdk"
129
137
  require "braintree/test/nonce"
130
138
  require "braintree/test/transaction_amounts"
131
139
  require "braintree/testing_gateway"
132
- require "braintree/transaction"
133
- require "braintree/transaction_line_item"
134
140
  require "braintree/test_transaction"
141
+ require "braintree/transaction"
135
142
  require "braintree/transaction/address_details"
136
143
  require "braintree/transaction/apple_pay_details"
137
- require "braintree/transaction/android_pay_details"
138
- require "braintree/transaction/amex_express_checkout_details"
139
- require "braintree/transaction/coinbase_details"
140
144
  require "braintree/transaction/credit_card_details"
141
145
  require "braintree/transaction/customer_details"
142
146
  require "braintree/transaction/disbursement_details"
147
+ require "braintree/transaction/google_pay_details"
148
+ require "braintree/transaction/installment"
149
+ require "braintree/transaction/installment/adjustment"
143
150
  require "braintree/transaction/paypal_details"
144
151
  require "braintree/transaction/paypal_here_details"
152
+ require "braintree/transaction/samsung_pay_card_details"
153
+ require "braintree/transaction/status_details"
145
154
  require "braintree/transaction/subscription_details"
155
+ require "braintree/transaction/venmo_account_details"
156
+ require "braintree/transaction/visa_checkout_card_details"
146
157
  require "braintree/transaction_gateway"
158
+ require "braintree/transaction_line_item"
147
159
  require "braintree/transaction_line_item_gateway"
148
160
  require "braintree/transaction_search"
149
- require "braintree/transaction/status_details"
150
- require "braintree/transaction/venmo_account_details"
151
- require "braintree/transaction/visa_checkout_card_details"
152
- require "braintree/transaction/masterpass_card_details"
153
- require "braintree/transaction/samsung_pay_card_details"
154
161
  require "braintree/unknown_payment_method"
155
162
  require "braintree/disbursement"
156
163
  require "braintree/dispute_search"
157
- require "braintree/transparent_redirect"
158
- require "braintree/transparent_redirect_gateway"
159
164
  require "braintree/validation_error"
160
165
  require "braintree/validation_error_collection"
161
166
  require "braintree/venmo_account"
167
+ require "braintree/venmo_profile_data"
162
168
  require "braintree/version"
163
169
  require "braintree/visa_checkout_card"
164
- require "braintree/masterpass_card"
165
170
  require "braintree/samsung_pay_card"
166
171
  require "braintree/webhook_notification"
167
172
  require "braintree/webhook_notification_gateway"
@@ -35,7 +35,7 @@ describe Braintree::AddOn do
35
35
  gateway = Braintree::Gateway.new(
36
36
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
37
37
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
38
- :logger => Logger.new("/dev/null")
38
+ :logger => Logger.new("/dev/null"),
39
39
  )
40
40
 
41
41
  expect do
@@ -14,8 +14,9 @@ describe Braintree::Address do
14
14
  :extended_address => "Suite 200",
15
15
  :locality => "Chicago",
16
16
  :region => "Illinois",
17
+ :phone_number => "5551231234",
17
18
  :postal_code => "60622",
18
- :country_name => "United States of America"
19
+ :country_name => "United States of America",
19
20
  )
20
21
  result.success?.should == true
21
22
  result.address.customer_id.should == customer.id
@@ -26,6 +27,7 @@ describe Braintree::Address do
26
27
  result.address.extended_address.should == "Suite 200"
27
28
  result.address.locality.should == "Chicago"
28
29
  result.address.region.should == "Illinois"
30
+ result.address.phone_number.should == "5551231234"
29
31
  result.address.postal_code.should == "60622"
30
32
  result.address.country_name.should == "United States of America"
31
33
  result.address.country_code_alpha2.should == "US"
@@ -39,7 +41,7 @@ describe Braintree::Address do
39
41
  :customer_id => customer.id,
40
42
  :country_code_alpha2 => "AS",
41
43
  :country_code_alpha3 => "ASM",
42
- :country_code_numeric => "16"
44
+ :country_code_numeric => "16",
43
45
  )
44
46
  result.success?.should == true
45
47
  result.address.country_name.should == "American Samoa"
@@ -52,7 +54,7 @@ describe Braintree::Address do
52
54
  customer = Braintree::Customer.create!
53
55
  result = Braintree::Address.create(
54
56
  :customer_id => customer.id,
55
- :country_name => "Åland"
57
+ :country_name => "Åland",
56
58
  )
57
59
  result.success?.should == true
58
60
  result.address.country_name.should == "Åland"
@@ -63,47 +65,47 @@ describe Braintree::Address do
63
65
  result = Braintree::Address.create(
64
66
  :customer_id => customer.id,
65
67
  :country_code_alpha2 => "AS",
66
- :country_code_alpha3 => "USA"
68
+ :country_code_alpha3 => "USA",
67
69
  )
68
70
  result.success?.should == false
69
- result.errors.for(:address).on(:base).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
71
+ result.errors.for(:address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
70
72
  end
71
73
 
72
74
  it "returns an error response given an invalid country_code_alpha2" do
73
75
  customer = Braintree::Customer.create!
74
76
  result = Braintree::Address.create(
75
77
  :customer_id => customer.id,
76
- :country_code_alpha2 => "zz"
78
+ :country_code_alpha2 => "zz",
77
79
  )
78
80
  result.success?.should == false
79
- result.errors.for(:address).on(:country_code_alpha2).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
81
+ result.errors.for(:address).on(:country_code_alpha2).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
80
82
  end
81
83
 
82
84
  it "returns an error response given an invalid country_code_alpha3" do
83
85
  customer = Braintree::Customer.create!
84
86
  result = Braintree::Address.create(
85
87
  :customer_id => customer.id,
86
- :country_code_alpha3 => "zzz"
88
+ :country_code_alpha3 => "zzz",
87
89
  )
88
90
  result.success?.should == false
89
- result.errors.for(:address).on(:country_code_alpha3).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
91
+ result.errors.for(:address).on(:country_code_alpha3).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
90
92
  end
91
93
 
92
94
  it "returns an error response given an invalid country_code_numeric" do
93
95
  customer = Braintree::Customer.create!
94
96
  result = Braintree::Address.create(
95
97
  :customer_id => customer.id,
96
- :country_code_numeric => "zz"
98
+ :country_code_numeric => "zz",
97
99
  )
98
100
  result.success?.should == false
99
- result.errors.for(:address).on(:country_code_numeric).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
101
+ result.errors.for(:address).on(:country_code_numeric).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
100
102
  end
101
103
 
102
104
  it "returns an error response if invalid" do
103
105
  customer = Braintree::Customer.create!(:last_name => "Wilson")
104
106
  result = Braintree::Address.create(
105
107
  :customer_id => customer.id,
106
- :country_name => "United States of Invalid"
108
+ :country_name => "United States of Invalid",
107
109
  )
108
110
  result.success?.should == false
109
111
  result.errors.for(:address).on(:country_name)[0].message.should == "Country name is not an accepted country."
@@ -131,14 +133,16 @@ describe Braintree::Address do
131
133
  :extended_address => "Suite 201",
132
134
  :locality => "Bartlett",
133
135
  :region => "IL",
136
+ :phone_number => "5551231234",
134
137
  :postal_code => "60623",
135
- :country_name => "United States of America"
138
+ :country_name => "United States of America",
136
139
  )
137
140
  address.customer_id.should == customer.id
138
141
  address.street_address.should == "1812 E Main St"
139
142
  address.extended_address.should == "Suite 201"
140
143
  address.locality.should == "Bartlett"
141
144
  address.region.should == "IL"
145
+ address.phone_number.should == "5551231234"
142
146
  address.postal_code.should == "60623"
143
147
  address.country_name.should == "United States of America"
144
148
  end
@@ -148,7 +152,7 @@ describe Braintree::Address do
148
152
  expect do
149
153
  Braintree::Address.create!(
150
154
  :customer_id => customer.id,
151
- :country_name => "United States of Invalid"
155
+ :country_name => "United States of Invalid",
152
156
  )
153
157
  end.to raise_error(Braintree::ValidationsFailed)
154
158
  end
@@ -226,7 +230,7 @@ describe Braintree::Address do
226
230
  :locality => "Old Chicago",
227
231
  :region => "IL",
228
232
  :postal_code => "60620",
229
- :country_name => "United States of America"
233
+ :country_name => "United States of America",
230
234
  )
231
235
  result = Braintree::Address.update(
232
236
  customer.id,
@@ -236,7 +240,7 @@ describe Braintree::Address do
236
240
  :locality => "Chicago",
237
241
  :region => "Illinois",
238
242
  :postal_code => "60621",
239
- :country_name => "United States of America"
243
+ :country_name => "United States of America",
240
244
  )
241
245
  result.success?.should == true
242
246
  result.address.street_address.should == "123 E New St"
@@ -254,12 +258,12 @@ describe Braintree::Address do
254
258
  customer = Braintree::Customer.create!(:last_name => "Miller")
255
259
  address = Braintree::Address.create!(
256
260
  :customer_id => customer.id,
257
- :country_name => "Angola"
261
+ :country_name => "Angola",
258
262
  )
259
263
  result = Braintree::Address.update(
260
264
  customer.id,
261
265
  address.id,
262
- :country_name => "Azerbaijan"
266
+ :country_name => "Azerbaijan",
263
267
  )
264
268
 
265
269
  result.success?.should == true
@@ -273,13 +277,13 @@ describe Braintree::Address do
273
277
  customer = Braintree::Customer.create!(:last_name => "Miller")
274
278
  address = Braintree::Address.create!(
275
279
  :customer_id => customer.id,
276
- :country_name => "United States of America"
280
+ :country_name => "United States of America",
277
281
  )
278
282
  result = Braintree::Address.update(
279
283
  customer.id,
280
284
  address.id,
281
285
  :street_address => "123 E New St",
282
- :country_name => "United States of Invalid"
286
+ :country_name => "United States of Invalid",
283
287
  )
284
288
  result.success?.should == false
285
289
  result.errors.for(:address).on(:country_name)[0].message.should == "Country name is not an accepted country."
@@ -304,7 +308,7 @@ describe Braintree::Address do
304
308
  :locality => "Old Chicago",
305
309
  :region => "IL",
306
310
  :postal_code => "60620",
307
- :country_name => "United States of America"
311
+ :country_name => "United States of America",
308
312
  )
309
313
  updated_address = Braintree::Address.update!(
310
314
  customer.id,
@@ -314,7 +318,7 @@ describe Braintree::Address do
314
318
  :locality => "Chicago",
315
319
  :region => "Illinois",
316
320
  :postal_code => "60621",
317
- :country_name => "United States of America"
321
+ :country_name => "United States of America",
318
322
  )
319
323
  updated_address.should == address
320
324
  updated_address.street_address.should == "123 E New St"
@@ -329,14 +333,14 @@ describe Braintree::Address do
329
333
  customer = Braintree::Customer.create!(:last_name => "Miller")
330
334
  address = Braintree::Address.create!(
331
335
  :customer_id => customer.id,
332
- :country_name => "United States of America"
336
+ :country_name => "United States of America",
333
337
  )
334
338
  expect do
335
339
  Braintree::Address.update!(
336
340
  customer.id,
337
341
  address.id,
338
342
  :street_address => "123 E New St",
339
- :country_name => "United States of Invalid"
343
+ :country_name => "United States of Invalid",
340
344
  )
341
345
  end.to raise_error(Braintree::ValidationsFailed)
342
346
  end
@@ -347,98 +351,11 @@ describe Braintree::Address do
347
351
  it "deletes the address" do
348
352
  customer = Braintree::Customer.create!(:last_name => "Wilson")
349
353
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
350
- address.delete.success?.should == true
354
+ result = Braintree::Address.delete(customer.id, address.id)
355
+ result.success?.should == true
351
356
  expect do
352
357
  Braintree::Address.find(customer.id, address.id)
353
358
  end.to raise_error(Braintree::NotFoundError)
354
359
  end
355
360
  end
356
-
357
- describe "update" do
358
- it "returns a success response and updates the address if valid" do
359
- customer = Braintree::Customer.create!(:last_name => "Miller")
360
- address = Braintree::Address.create!(
361
- :customer_id => customer.id,
362
- :street_address => "1812 E Old St",
363
- :extended_address => "Suite Old 201",
364
- :locality => "Old Chicago",
365
- :region => "IL",
366
- :postal_code => "60620",
367
- :country_name => "United States of America"
368
- )
369
- result = address.update(
370
- :street_address => "123 E New St",
371
- :extended_address => "New Suite 3",
372
- :locality => "Chicago",
373
- :region => "Illinois",
374
- :postal_code => "60621",
375
- :country_name => "United States of America"
376
- )
377
- result.success?.should == true
378
- result.address.should == address
379
- address.street_address.should == "123 E New St"
380
- address.extended_address.should == "New Suite 3"
381
- address.locality.should == "Chicago"
382
- address.region.should == "Illinois"
383
- address.postal_code.should == "60621"
384
- address.country_name.should == "United States of America"
385
- end
386
-
387
- it "returns an error response if invalid" do
388
- customer = Braintree::Customer.create!(:last_name => "Miller")
389
- address = Braintree::Address.create!(
390
- :customer_id => customer.id,
391
- :country_name => "United States of America"
392
- )
393
- result = address.update(
394
- :street_address => "123 E New St",
395
- :country_name => "United States of Invalid"
396
- )
397
- result.success?.should == false
398
- result.errors.for(:address).on(:country_name)[0].message.should == "Country name is not an accepted country."
399
- end
400
- end
401
-
402
- describe "update!" do
403
- it "returns true and updates the address if valid" do
404
- customer = Braintree::Customer.create!(:last_name => "Miller")
405
- address = Braintree::Address.create!(
406
- :customer_id => customer.id,
407
- :street_address => "1812 E Old St",
408
- :extended_address => "Suite Old 201",
409
- :locality => "Old Chicago",
410
- :region => "IL",
411
- :postal_code => "60620",
412
- :country_name => "United States of America"
413
- )
414
- address.update!(
415
- :street_address => "123 E New St",
416
- :extended_address => "New Suite 3",
417
- :locality => "Chicago",
418
- :region => "Illinois",
419
- :postal_code => "60621",
420
- :country_name => "United States of America"
421
- ).should == address
422
- address.street_address.should == "123 E New St"
423
- address.extended_address.should == "New Suite 3"
424
- address.locality.should == "Chicago"
425
- address.region.should == "Illinois"
426
- address.postal_code.should == "60621"
427
- address.country_name.should == "United States of America"
428
- end
429
-
430
- it "raises a ValidationsFailed invalid" do
431
- customer = Braintree::Customer.create!(:last_name => "Miller")
432
- address = Braintree::Address.create!(
433
- :customer_id => customer.id,
434
- :country_name => "United States of America"
435
- )
436
- expect do
437
- address.update!(
438
- :street_address => "123 E New St",
439
- :country_name => "United States of Invalid"
440
- )
441
- end.to raise_error(Braintree::ValidationsFailed)
442
- end
443
- end
444
361
  end