braintree 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +1 -1
  3. data/lib/braintree.rb +2 -1
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +1 -1
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +1 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/client_token.rb +1 -1
  11. data/lib/braintree/configuration.rb +11 -11
  12. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  13. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  14. data/lib/braintree/credit_card.rb +2 -2
  15. data/lib/braintree/credit_card_gateway.rb +3 -3
  16. data/lib/braintree/credit_card_verification.rb +5 -5
  17. data/lib/braintree/credit_card_verification_search.rb +1 -1
  18. data/lib/braintree/customer.rb +2 -2
  19. data/lib/braintree/customer_search.rb +1 -1
  20. data/lib/braintree/disbursement.rb +1 -1
  21. data/lib/braintree/dispute.rb +1 -1
  22. data/lib/braintree/dispute_gateway.rb +2 -2
  23. data/lib/braintree/dispute_search.rb +2 -2
  24. data/lib/braintree/document_upload.rb +1 -1
  25. data/lib/braintree/error_codes.rb +7 -0
  26. data/lib/braintree/google_pay_card.rb +1 -1
  27. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  28. data/lib/braintree/graphql_client.rb +7 -7
  29. data/lib/braintree/http.rb +3 -3
  30. data/lib/braintree/local_payment_completed.rb +1 -1
  31. data/lib/braintree/local_payment_reversed.rb +19 -0
  32. data/lib/braintree/merchant.rb +1 -1
  33. data/lib/braintree/merchant_account.rb +1 -1
  34. data/lib/braintree/merchant_account_gateway.rb +1 -1
  35. data/lib/braintree/merchant_gateway.rb +1 -1
  36. data/lib/braintree/modification.rb +1 -1
  37. data/lib/braintree/oauth_credentials.rb +1 -1
  38. data/lib/braintree/oauth_gateway.rb +5 -5
  39. data/lib/braintree/payment_instrument_type.rb +10 -10
  40. data/lib/braintree/payment_method_gateway.rb +3 -3
  41. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  42. data/lib/braintree/plan.rb +1 -1
  43. data/lib/braintree/processor_response_types.rb +3 -3
  44. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  45. data/lib/braintree/samsung_pay_card.rb +1 -1
  46. data/lib/braintree/settlement_batch_summary.rb +2 -2
  47. data/lib/braintree/subscription.rb +6 -6
  48. data/lib/braintree/transaction.rb +32 -24
  49. data/lib/braintree/transaction_gateway.rb +23 -4
  50. data/lib/braintree/transaction_line_item.rb +1 -1
  51. data/lib/braintree/transaction_search.rb +3 -1
  52. data/lib/braintree/unknown_payment_method.rb +1 -1
  53. data/lib/braintree/us_bank_account.rb +3 -3
  54. data/lib/braintree/us_bank_account_verification.rb +1 -1
  55. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  56. data/lib/braintree/util.rb +4 -4
  57. data/lib/braintree/venmo_account.rb +1 -1
  58. data/lib/braintree/version.rb +1 -1
  59. data/lib/braintree/visa_checkout_card.rb +2 -2
  60. data/lib/braintree/webhook_notification.rb +28 -19
  61. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  62. data/lib/braintree/webhook_testing_gateway.rb +10 -0
  63. data/lib/braintree/xml/generator.rb +5 -4
  64. data/lib/braintree/xml/libxml.rb +1 -1
  65. data/lib/braintree/xml/parser.rb +10 -10
  66. data/spec/integration/braintree/add_on_spec.rb +1 -1
  67. data/spec/integration/braintree/address_spec.rb +24 -24
  68. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  69. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  70. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  71. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  72. data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
  73. data/spec/integration/braintree/credit_card_spec.rb +119 -119
  74. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  75. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  76. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  77. data/spec/integration/braintree/customer_spec.rb +165 -165
  78. data/spec/integration/braintree/dispute_search_spec.rb +3 -3
  79. data/spec/integration/braintree/dispute_spec.rb +6 -6
  80. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  81. data/spec/integration/braintree/http_spec.rb +2 -2
  82. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  83. data/spec/integration/braintree/merchant_spec.rb +12 -12
  84. data/spec/integration/braintree/oauth_spec.rb +11 -11
  85. data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
  86. data/spec/integration/braintree/payment_method_spec.rb +165 -165
  87. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
  88. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  89. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  90. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  91. data/spec/integration/braintree/subscription_spec.rb +133 -133
  92. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  93. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  94. data/spec/integration/braintree/transaction_search_spec.rb +93 -67
  95. data/spec/integration/braintree/transaction_spec.rb +498 -344
  96. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
  97. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  98. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  99. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  100. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  101. data/spec/integration/spec_helper.rb +2 -2
  102. data/spec/oauth_test_helper.rb +1 -1
  103. data/spec/script/httpsd.rb +6 -6
  104. data/spec/spec_helper.rb +4 -3
  105. data/spec/unit/braintree/address_spec.rb +1 -1
  106. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  107. data/spec/unit/braintree/client_token_spec.rb +2 -2
  108. data/spec/unit/braintree/configuration_spec.rb +42 -42
  109. data/spec/unit/braintree/credit_card_spec.rb +7 -7
  110. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  111. data/spec/unit/braintree/credit_card_verification_spec.rb +2 -2
  112. data/spec/unit/braintree/customer_spec.rb +3 -3
  113. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  114. data/spec/unit/braintree/dispute_spec.rb +8 -8
  115. data/spec/unit/braintree/error_result_spec.rb +5 -5
  116. data/spec/unit/braintree/errors_spec.rb +8 -8
  117. data/spec/unit/braintree/http_spec.rb +5 -5
  118. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  119. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  120. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  121. data/spec/unit/braintree/resource_collection_spec.rb +9 -9
  122. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  123. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  124. data/spec/unit/braintree/three_d_secure_info_spec.rb +1 -1
  125. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  126. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  127. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  128. data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
  129. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  130. data/spec/unit/braintree/transaction_spec.rb +25 -17
  131. data/spec/unit/braintree/util_spec.rb +18 -18
  132. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  133. data/spec/unit/braintree/webhook_notification_spec.rb +72 -56
  134. data/spec/unit/braintree/xml_spec.rb +31 -31
  135. metadata +3 -3
  136. data/lib/braintree/settlement_batch.rb +0 -0
@@ -108,7 +108,7 @@ describe Braintree::CreditCardVerification, "search" do
108
108
  search.id.is verification.id
109
109
  search.created_at.between(
110
110
  created_at - 60,
111
- created_at + 60
111
+ created_at + 60,
112
112
  )
113
113
  end
114
114
 
@@ -135,7 +135,7 @@ describe Braintree::CreditCardVerification, "search" do
135
135
  search.id.is verification.id
136
136
  search.created_at.between(
137
137
  created_at - 300,
138
- created_at - 100
138
+ created_at - 100,
139
139
  )
140
140
  end
141
141
 
@@ -242,7 +242,7 @@ describe Braintree::CreditCardVerification, "search" do
242
242
  :cardholder_name => cardholder_name,
243
243
  :expiration_date => "05/2012",
244
244
  :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
245
- :cvv => '200',
245
+ :cvv => "200",
246
246
  :options => {
247
247
  :verify_card => true
248
248
  }
@@ -36,7 +36,7 @@ describe Braintree::Transaction, "search" do
36
36
  :postal_code => "60622",
37
37
  :country_name => "United States of America"
38
38
  }
39
- }
39
+ },
40
40
  )
41
41
 
42
42
  customer = Braintree::Customer.find(customer.id)
@@ -96,7 +96,7 @@ describe Braintree::Transaction, "search" do
96
96
  :credit_card => {
97
97
  :number => Braintree::Test::CreditCardNumbers::Maestro,
98
98
  :expiration_date => "05/2012"
99
- }
99
+ },
100
100
  ).customer
101
101
 
102
102
  joe = Braintree::Customer.create(
@@ -104,7 +104,7 @@ describe Braintree::Transaction, "search" do
104
104
  :credit_card => {
105
105
  :number => Braintree::Test::CreditCardNumbers::Maestro,
106
106
  :expiration_date => "05/2012"
107
- }
107
+ },
108
108
  ).customer
109
109
 
110
110
  collection = Braintree::Customer.search do |search|
@@ -118,7 +118,7 @@ describe Braintree::Transaction, "search" do
118
118
  it "can search by created_at" do
119
119
  company = "Company #{rand(1_000_000)}"
120
120
  customer = Braintree::Customer.create!(
121
- :company => company
121
+ :company => company,
122
122
  )
123
123
 
124
124
  created_at = customer.created_at
@@ -128,7 +128,7 @@ describe Braintree::Transaction, "search" do
128
128
  search.company.is company
129
129
  search.created_at.between(
130
130
  created_at - 60,
131
- created_at + 60
131
+ created_at + 60,
132
132
  )
133
133
  end
134
134
 
@@ -155,7 +155,7 @@ describe Braintree::Transaction, "search" do
155
155
  search.company.is customer.company
156
156
  search.created_at.between(
157
157
  created_at - 300,
158
- created_at - 100
158
+ created_at - 100,
159
159
  )
160
160
  end
161
161
 
@@ -175,13 +175,13 @@ describe Braintree::Transaction, "search" do
175
175
  paypal_token = rand(36**3).to_s(36)
176
176
  nonce = nonce_for_paypal_account(
177
177
  :consent_code => "PAYPAL_CONSENT_CODE",
178
- :token => paypal_token
178
+ :token => paypal_token,
179
179
  )
180
180
 
181
181
  customer_id = "UNIQUE_CUSTOMER_ID_" + rand(36**3).to_s(36)
182
182
  customer = Braintree::Customer.create!(
183
183
  :payment_method_nonce => nonce,
184
- :id => customer_id
184
+ :id => customer_id,
185
185
  )
186
186
 
187
187
  collection = Braintree::Customer.search do |search|
@@ -8,7 +8,7 @@ describe Braintree::Customer do
8
8
  customers = Braintree::Customer.all
9
9
  customers.maximum_size.should > 100
10
10
 
11
- customer_ids = customers.map {|c| c.id }.uniq.compact
11
+ customer_ids = customers.map { |c| c.id }.uniq.compact
12
12
  customer_ids.size.should == customers.maximum_size
13
13
  end
14
14
  end
@@ -17,7 +17,7 @@ describe Braintree::Customer do
17
17
  it "deletes the customer with the given id" do
18
18
  create_result = Braintree::Customer.create(
19
19
  :first_name => "Joe",
20
- :last_name => "Cool"
20
+ :last_name => "Cool",
21
21
  )
22
22
  create_result.success?.should == true
23
23
  customer = create_result.customer
@@ -39,7 +39,7 @@ describe Braintree::Customer do
39
39
  :email => "bill@microsoft.com",
40
40
  :phone => "312.555.1234",
41
41
  :fax => "614.555.5678",
42
- :website => "www.microsoft.com"
42
+ :website => "www.microsoft.com",
43
43
  )
44
44
  result.success?.should == true
45
45
  result.customer.id.should =~ /^\d{6,}$/
@@ -58,7 +58,7 @@ describe Braintree::Customer do
58
58
  oauth_gateway = Braintree::Gateway.new(
59
59
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
60
60
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
61
- :logger => Logger.new("/dev/null")
61
+ :logger => Logger.new("/dev/null"),
62
62
  )
63
63
  access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
64
64
  :merchant_public_id => "integration_merchant_id",
@@ -67,7 +67,7 @@ describe Braintree::Customer do
67
67
 
68
68
  gateway = Braintree::Gateway.new(
69
69
  :access_token => access_token,
70
- :logger => Logger.new("/dev/null")
70
+ :logger => Logger.new("/dev/null"),
71
71
  )
72
72
 
73
73
  result = gateway.customer.create(
@@ -77,7 +77,7 @@ describe Braintree::Customer do
77
77
  :email => "joe@example.com",
78
78
  :phone => "312.555.1234",
79
79
  :fax => "614.555.5678",
80
- :website => "www.example.com"
80
+ :website => "www.example.com",
81
81
  )
82
82
  result.success?.should == true
83
83
  result.customer.id.should =~ /^\d{6,}$/
@@ -92,7 +92,7 @@ describe Braintree::Customer do
92
92
  :expiration_date => "05/2010",
93
93
  :cvv => "100",
94
94
  :device_data => "device_data",
95
- }
95
+ },
96
96
  )
97
97
 
98
98
  result.should be_success
@@ -108,7 +108,7 @@ describe Braintree::Customer do
108
108
  :risk_data => {
109
109
  :customer_browser => "IE5",
110
110
  :customer_ip => "192.168.0.1"
111
- }
111
+ },
112
112
  )
113
113
 
114
114
  result.should be_success
@@ -134,21 +134,21 @@ describe Braintree::Customer do
134
134
  found_customer.last_name.should == last_name
135
135
  else
136
136
  result.customer.first_name.should == "José"
137
- result.customer.first_name.bytes.map {|b| b.to_s(8)}.should == ["112", "157", "163", "303", "251"]
137
+ result.customer.first_name.bytes.map { |b| b.to_s(8) }.should == ["112", "157", "163", "303", "251"]
138
138
  result.customer.last_name.should == "Muñoz"
139
- result.customer.last_name.bytes.map {|b| b.to_s(8)}.should == ["115", "165", "303", "261", "157", "172"]
139
+ result.customer.last_name.bytes.map { |b| b.to_s(8) }.should == ["115", "165", "303", "261", "157", "172"]
140
140
 
141
141
  found_customer = Braintree::Customer.find(result.customer.id)
142
142
  found_customer.first_name.should == "José"
143
- found_customer.first_name.bytes.map {|b| b.to_s(8)}.should == ["112", "157", "163", "303", "251"]
143
+ found_customer.first_name.bytes.map { |b| b.to_s(8) }.should == ["112", "157", "163", "303", "251"]
144
144
  found_customer.last_name.should == "Muñoz"
145
- found_customer.last_name.bytes.map {|b| b.to_s(8)}.should == ["115", "165", "303", "261", "157", "172"]
145
+ found_customer.last_name.bytes.map { |b| b.to_s(8) }.should == ["115", "165", "303", "261", "157", "172"]
146
146
  end
147
147
  end
148
148
 
149
149
  it "returns an error response if invalid" do
150
150
  result = Braintree::Customer.create(
151
- :email => "@invalid.com"
151
+ :email => "@invalid.com",
152
152
  )
153
153
  result.success?.should == false
154
154
  result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
@@ -162,7 +162,7 @@ describe Braintree::Customer do
162
162
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
163
163
  :expiration_date => "05/2010",
164
164
  :cvv => "100"
165
- }
165
+ },
166
166
  )
167
167
 
168
168
  result.success?.should == true
@@ -182,7 +182,7 @@ describe Braintree::Customer do
182
182
  :email => "other@example.com",
183
183
  :billing_agreement_id => "B-123456",
184
184
  :options => {:make_default => true}
185
- }
185
+ },
186
186
  )
187
187
 
188
188
  result.success?.should == true
@@ -200,7 +200,7 @@ describe Braintree::Customer do
200
200
  :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
201
201
  :expiration_date => "05/2010",
202
202
  :options => {:verify_card => true}
203
- }
203
+ },
204
204
  )
205
205
  result.success?.should == false
206
206
  result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
@@ -214,7 +214,7 @@ describe Braintree::Customer do
214
214
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
215
215
  :expiration_date => "05/2019",
216
216
  :options => {:verify_card => true, :verification_amount => "2.00"}
217
- }
217
+ },
218
218
  )
219
219
  result.success?.should == true
220
220
  end
@@ -224,7 +224,7 @@ describe Braintree::Customer do
224
224
  Braintree::CreditCard.create(
225
225
  :customer_id => customer.id,
226
226
  :number => Braintree::Test::CreditCardNumbers::Visa,
227
- :expiration_date => "05/2015"
227
+ :expiration_date => "05/2015",
228
228
  )
229
229
 
230
230
  result = Braintree::Customer.create(
@@ -234,7 +234,7 @@ describe Braintree::Customer do
234
234
  :number => Braintree::Test::CreditCardNumbers::Visa,
235
235
  :expiration_date => "05/2015",
236
236
  :options => {:fail_on_duplicate_payment_method => true}
237
- }
237
+ },
238
238
  )
239
239
  result.success?.should == false
240
240
  result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
@@ -251,7 +251,7 @@ describe Braintree::Customer do
251
251
  :verify_card => true,
252
252
  :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
253
253
  }
254
- }
254
+ },
255
255
  )
256
256
  result.success?.should == false
257
257
  result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
@@ -269,7 +269,7 @@ describe Braintree::Customer do
269
269
  :verify_card => true,
270
270
  :verification_currency_iso_code => "USD"
271
271
  }
272
- }
272
+ },
273
273
  )
274
274
 
275
275
  result.success?.should == true
@@ -294,7 +294,7 @@ describe Braintree::Customer do
294
294
  :verify_card => true,
295
295
  :verification_currency_iso_code => "GBP"
296
296
  }
297
- }
297
+ },
298
298
  )
299
299
  expect(result).to_not be_success
300
300
  expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
@@ -312,7 +312,7 @@ describe Braintree::Customer do
312
312
  :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
313
313
  :verification_currency_iso_code => "USD"
314
314
  }
315
- }
315
+ },
316
316
  )
317
317
  result.success?.should == true
318
318
  result.customer.credit_cards[0].verification.currency_iso_code == "USD"
@@ -336,7 +336,7 @@ describe Braintree::Customer do
336
336
  :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
337
337
  :verification_currency_iso_code => "GBP"
338
338
  }
339
- }
339
+ },
340
340
  )
341
341
  expect(result).to_not be_success
342
342
  expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
@@ -358,7 +358,7 @@ describe Braintree::Customer do
358
358
  :postal_code => "60622",
359
359
  :country_name => "United States of America"
360
360
  }
361
- }
361
+ },
362
362
  )
363
363
  result.success?.should == true
364
364
  result.customer.first_name.should == "Mike"
@@ -389,7 +389,7 @@ describe Braintree::Customer do
389
389
  :country_code_alpha3 => "COM",
390
390
  :country_code_numeric => "174"
391
391
  }
392
- }
392
+ },
393
393
  )
394
394
  result.success?.should == true
395
395
  result.customer.addresses[0].country_name.should == "Comoros"
@@ -404,7 +404,7 @@ describe Braintree::Customer do
404
404
  :last_name => "Gates",
405
405
  :custom_fields => {
406
406
  :store_me => "custom value"
407
- }
407
+ },
408
408
  )
409
409
  result.success?.should == true
410
410
  result.customer.custom_fields[:store_me].should == "custom value"
@@ -414,7 +414,7 @@ describe Braintree::Customer do
414
414
  result = Braintree::Customer.create(
415
415
  :first_name => "Bill",
416
416
  :last_name => "Gates",
417
- :custom_fields => { :store_me => "" }
417
+ :custom_fields => {:store_me => ""},
418
418
  )
419
419
  result.success?.should == true
420
420
  result.customer.custom_fields.should == {}
@@ -428,7 +428,7 @@ describe Braintree::Customer do
428
428
  :billing_address => {
429
429
  :country_name => "invalid"
430
430
  }
431
- }
431
+ },
432
432
  )
433
433
  result.success?.should == false
434
434
  result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
@@ -448,10 +448,10 @@ describe Braintree::Customer do
448
448
  :country_code_alpha2 => "US",
449
449
  :country_code_alpha3 => "COM",
450
450
  }
451
- }
451
+ },
452
452
  )
453
453
  result.success?.should == false
454
- result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
454
+ result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
455
455
  end
456
456
 
457
457
  it "returns an error if country code alpha2 is invalid" do
@@ -464,10 +464,10 @@ describe Braintree::Customer do
464
464
  :billing_address => {
465
465
  :country_code_alpha2 => "zz",
466
466
  }
467
- }
467
+ },
468
468
  )
469
469
  result.success?.should == false
470
- result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha2).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
470
+ result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha2).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
471
471
  end
472
472
 
473
473
  it "returns an error if country code alpha3 is invalid" do
@@ -480,10 +480,10 @@ describe Braintree::Customer do
480
480
  :billing_address => {
481
481
  :country_code_alpha3 => "zzz",
482
482
  }
483
- }
483
+ },
484
484
  )
485
485
  result.success?.should == false
486
- result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha3).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
486
+ result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha3).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
487
487
  end
488
488
 
489
489
  it "returns an error if country code numeric is invalid" do
@@ -496,10 +496,10 @@ describe Braintree::Customer do
496
496
  :billing_address => {
497
497
  :country_code_numeric => "zzz",
498
498
  }
499
- }
499
+ },
500
500
  )
501
501
  result.success?.should == false
502
- result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_numeric).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
502
+ result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_numeric).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
503
503
  end
504
504
 
505
505
  it "returns errors if custom_fields are not registered" do
@@ -508,7 +508,7 @@ describe Braintree::Customer do
508
508
  :last_name => "Kennedy",
509
509
  :custom_fields => {
510
510
  :spouse_name => "Jacqueline"
511
- }
511
+ },
512
512
  )
513
513
  result.success?.should == false
514
514
  result.errors.for(:customer).on(:custom_fields)[0].message.should == "Custom field is invalid: spouse_name."
@@ -521,7 +521,7 @@ describe Braintree::Customer do
521
521
  :last_name => "Hamlin",
522
522
  :credit_card => {
523
523
  :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
524
- }
524
+ },
525
525
  )
526
526
  result.success?.should == true
527
527
  result.customer.credit_cards.first.bin.should == "400934"
@@ -538,7 +538,7 @@ describe Braintree::Customer do
538
538
  :options => {
539
539
  :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
540
540
  }
541
- }
541
+ },
542
542
  )
543
543
  result.success?.should == true
544
544
  result.customer.credit_cards.first.venmo_sdk?.should == false
@@ -553,13 +553,13 @@ describe Braintree::Customer do
553
553
  :expiration_month => "11",
554
554
  :expiration_year => "2099",
555
555
  },
556
- :share => true
556
+ :share => true,
557
557
  )
558
558
 
559
559
  result = Braintree::Customer.create(
560
560
  :credit_card => {
561
561
  :payment_method_nonce => nonce
562
- }
562
+ },
563
563
  )
564
564
 
565
565
  result.success?.should == true
@@ -589,7 +589,7 @@ describe Braintree::Customer do
589
589
  :number => Braintree::Test::CreditCardNumbers::Hiper,
590
590
  :expiration_month => "11",
591
591
  :expiration_year => "2099",
592
- }
592
+ },
593
593
  )
594
594
  result = Braintree::Customer.create(
595
595
  :payment_method_nonce => nonce,
@@ -599,7 +599,7 @@ describe Braintree::Customer do
599
599
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
600
600
  :verification_account_type => "debit",
601
601
  }
602
- }
602
+ },
603
603
  )
604
604
 
605
605
  expect(result).to be_success
@@ -611,7 +611,7 @@ describe Braintree::Customer do
611
611
  :number => Braintree::Test::CreditCardNumbers::Hiper,
612
612
  :expiration_month => "11",
613
613
  :expiration_year => "2099",
614
- }
614
+ },
615
615
  )
616
616
  result = Braintree::Customer.create(
617
617
  :payment_method_nonce => nonce,
@@ -621,7 +621,7 @@ describe Braintree::Customer do
621
621
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
622
622
  :verification_account_type => "credit",
623
623
  }
624
- }
624
+ },
625
625
  )
626
626
 
627
627
  expect(result).to be_success
@@ -633,7 +633,7 @@ describe Braintree::Customer do
633
633
  :number => Braintree::Test::CreditCardNumbers::Hiper,
634
634
  :expiration_month => "11",
635
635
  :expiration_year => "2099",
636
- }
636
+ },
637
637
  )
638
638
  result = Braintree::Customer.create(
639
639
  :payment_method_nonce => nonce,
@@ -643,7 +643,7 @@ describe Braintree::Customer do
643
643
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
644
644
  :verification_account_type => "ach",
645
645
  }
646
- }
646
+ },
647
647
  )
648
648
 
649
649
  expect(result).to_not be_success
@@ -656,7 +656,7 @@ describe Braintree::Customer do
656
656
  :number => Braintree::Test::CreditCardNumbers::Visa,
657
657
  :expiration_month => "11",
658
658
  :expiration_year => "2099",
659
- }
659
+ },
660
660
  )
661
661
  result = Braintree::Customer.create(
662
662
  :payment_method_nonce => nonce,
@@ -665,7 +665,7 @@ describe Braintree::Customer do
665
665
  :verify_card => true,
666
666
  :verification_account_type => "credit",
667
667
  }
668
- }
668
+ },
669
669
  )
670
670
 
671
671
  expect(result).to_not be_success
@@ -678,7 +678,7 @@ describe Braintree::Customer do
678
678
  it "returns the customer if successful" do
679
679
  customer = Braintree::Customer.create!(
680
680
  :first_name => "Jim",
681
- :last_name => "Smith"
681
+ :last_name => "Smith",
682
682
  )
683
683
  customer.id.should =~ /\d+/
684
684
  customer.first_name.should == "Jim"
@@ -703,7 +703,7 @@ describe Braintree::Customer do
703
703
  :credit_card => {
704
704
  :number => Braintree::Test::CreditCardNumbers::Visa,
705
705
  :expiration_date => "05/2010"
706
- }
706
+ },
707
707
  )
708
708
  result = Braintree::Customer.credit(customer.id, :amount => "100.00")
709
709
  result.success?.should == true
@@ -723,7 +723,7 @@ describe Braintree::Customer do
723
723
  :credit_card => {
724
724
  :number => Braintree::Test::CreditCardNumbers::Visa,
725
725
  :expiration_date => "05/2010"
726
- }
726
+ },
727
727
  )
728
728
  transaction = Braintree::Customer.credit!(customer.id, :amount => "100.00")
729
729
  transaction.amount.should == BigDecimal("100.00")
@@ -742,7 +742,7 @@ describe Braintree::Customer do
742
742
  :credit_card => {
743
743
  :number => Braintree::Test::CreditCardNumbers::Visa,
744
744
  :expiration_date => "05/2010"
745
- }
745
+ },
746
746
  )
747
747
  result = Braintree::Customer.sale(customer.id, :amount => "100.00")
748
748
  result.success?.should == true
@@ -762,7 +762,7 @@ describe Braintree::Customer do
762
762
  :credit_card => {
763
763
  :number => Braintree::Test::CreditCardNumbers::Visa,
764
764
  :expiration_date => "05/2010"
765
- }
765
+ },
766
766
  )
767
767
  transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
768
768
  transaction.amount.should == BigDecimal("100.00")
@@ -781,7 +781,7 @@ describe Braintree::Customer do
781
781
  :credit_card => {
782
782
  :number => Braintree::Test::CreditCardNumbers::Visa,
783
783
  :expiration_date => "05/2010"
784
- }
784
+ },
785
785
  )
786
786
  transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
787
787
  collection = Braintree::Customer.transactions(customer.id)
@@ -795,10 +795,10 @@ describe Braintree::Customer do
795
795
  :credit_card => {
796
796
  :number => Braintree::Test::CreditCardNumbers::Visa,
797
797
  :expiration_date => "05/2010"
798
- }
798
+ },
799
799
  )
800
800
  result = customer.credit(
801
- :amount => "100.00"
801
+ :amount => "100.00",
802
802
  )
803
803
  result.success?.should == true
804
804
  result.transaction.amount.should == BigDecimal("100.00")
@@ -817,7 +817,7 @@ describe Braintree::Customer do
817
817
  :credit_card => {
818
818
  :number => Braintree::Test::CreditCardNumbers::Visa,
819
819
  :expiration_date => "05/2010"
820
- }
820
+ },
821
821
  )
822
822
  transaction = customer.credit!(:amount => "100.00")
823
823
  transaction.amount.should == BigDecimal("100.00")
@@ -834,7 +834,7 @@ describe Braintree::Customer do
834
834
  it "deletes the customer" do
835
835
  result = Braintree::Customer.create(
836
836
  :first_name => "Joe",
837
- :last_name => "Cool"
837
+ :last_name => "Cool",
838
838
  )
839
839
  result.success?.should == true
840
840
 
@@ -851,7 +851,7 @@ describe Braintree::Customer do
851
851
  it "finds the customer with the given id" do
852
852
  result = Braintree::Customer.create(
853
853
  :first_name => "Joe",
854
- :last_name => "Cool"
854
+ :last_name => "Cool",
855
855
  )
856
856
  result.success?.should == true
857
857
 
@@ -867,13 +867,13 @@ describe Braintree::Customer do
867
867
  credit_card = Braintree::CreditCard.create(
868
868
  :customer_id => customer.id,
869
869
  :number => Braintree::Test::CreditCardNumbers::Visa,
870
- :expiration_date => "05/2012"
870
+ :expiration_date => "05/2012",
871
871
  ).credit_card
872
872
 
873
873
  subscription = Braintree::Subscription.create(
874
874
  :payment_method_token => credit_card.token,
875
875
  :plan_id => "integration_trialless_plan",
876
- :price => "1.00"
876
+ :price => "1.00",
877
877
  ).subscription
878
878
 
879
879
  found_customer = Braintree::Customer.find(customer.id)
@@ -888,7 +888,7 @@ describe Braintree::Customer do
888
888
  customer = Braintree::Customer.create(
889
889
  :custom_fields => {
890
890
  :store_me => "custom value"
891
- }
891
+ },
892
892
  ).customer
893
893
  credit_card = Braintree::CreditCard.create(
894
894
  :customer_id => customer.id,
@@ -900,13 +900,13 @@ describe Braintree::Customer do
900
900
  :region => "Illinois",
901
901
  :postal_code => "60622",
902
902
  :country_name => "United States of America"
903
- }
903
+ },
904
904
  ).credit_card
905
905
 
906
906
  subscription = Braintree::Subscription.create(
907
907
  :payment_method_token => credit_card.token,
908
908
  :plan_id => "integration_trialless_plan",
909
- :price => "1.00"
909
+ :price => "1.00",
910
910
  ).subscription
911
911
 
912
912
  found_customer = Braintree::Customer.find(customer.id, {
@@ -922,7 +922,7 @@ describe Braintree::Customer do
922
922
  customer = Braintree::Customer.create(
923
923
  :custom_fields => {
924
924
  :store_me => "custom value"
925
- }
925
+ },
926
926
  ).customer
927
927
  credit_card = Braintree::CreditCard.create(
928
928
  :customer_id => customer.id,
@@ -934,13 +934,13 @@ describe Braintree::Customer do
934
934
  :region => "Illinois",
935
935
  :postal_code => "60622",
936
936
  :country_name => "United States of America"
937
- }
937
+ },
938
938
  ).credit_card
939
939
 
940
940
  subscription = Braintree::Subscription.create(
941
941
  :payment_method_token => credit_card.token,
942
942
  :plan_id => "integration_trialless_plan",
943
- :price => "1.00"
943
+ :price => "1.00",
944
944
  ).subscription
945
945
 
946
946
  found_customer = Braintree::Customer.find(customer.id, {
@@ -958,7 +958,7 @@ describe Braintree::Customer do
958
958
 
959
959
  it "returns associated ApplePayCards" do
960
960
  result = Braintree::Customer.create(
961
- :payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx
961
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
962
962
  )
963
963
  result.success?.should == true
964
964
 
@@ -973,7 +973,7 @@ describe Braintree::Customer do
973
973
 
974
974
  it "returns associated google pay proxy cards" do
975
975
  result = Braintree::Customer.create(
976
- :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
976
+ :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
977
977
  )
978
978
  result.success?.should == true
979
979
 
@@ -989,7 +989,7 @@ describe Braintree::Customer do
989
989
 
990
990
  it "returns associated google pay network tokens" do
991
991
  result = Braintree::Customer.create(
992
- :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
992
+ :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
993
993
  )
994
994
  result.success?.should == true
995
995
 
@@ -1005,7 +1005,7 @@ describe Braintree::Customer do
1005
1005
 
1006
1006
  it "returns associated venmo accounts" do
1007
1007
  result = Braintree::Customer.create(
1008
- :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
1008
+ :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
1009
1009
  )
1010
1010
  result.success?.should == true
1011
1011
 
@@ -1025,7 +1025,7 @@ describe Braintree::Customer do
1025
1025
  :options => {
1026
1026
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
1027
1027
  }
1028
- }
1028
+ },
1029
1029
  )
1030
1030
  result.should be_success
1031
1031
 
@@ -1071,7 +1071,7 @@ describe Braintree::Customer do
1071
1071
  it "updates the credit card with three_d_secure pass thru params" do
1072
1072
  customer = Braintree::Customer.create!(
1073
1073
  :first_name => "Joe",
1074
- :last_name => "Cool"
1074
+ :last_name => "Cool",
1075
1075
  )
1076
1076
  result = Braintree::Customer.update(
1077
1077
  customer.id,
@@ -1084,17 +1084,17 @@ describe Braintree::Customer do
1084
1084
  :number => 4111111111111111,
1085
1085
  :expiration_date => "05/2060",
1086
1086
  :three_d_secure_pass_thru => {
1087
- :eci_flag => '02',
1088
- :cavv => 'some_cavv',
1089
- :xid => 'some_xid',
1090
- :three_d_secure_version => '1.0.2',
1091
- :authentication_response => 'Y',
1092
- :directory_response => 'Y',
1093
- :cavv_algorithm => '2',
1094
- :ds_transaction_id => 'some_ds_transaction_id',
1087
+ :eci_flag => "02",
1088
+ :cavv => "some_cavv",
1089
+ :xid => "some_xid",
1090
+ :three_d_secure_version => "1.0.2",
1091
+ :authentication_response => "Y",
1092
+ :directory_response => "Y",
1093
+ :cavv_algorithm => "2",
1094
+ :ds_transaction_id => "some_ds_transaction_id",
1095
1095
  },
1096
1096
  :options => {:verify_card => true},
1097
- }
1097
+ },
1098
1098
  )
1099
1099
  result.success?.should == true
1100
1100
  result.customer.id.should == customer.id
@@ -1106,7 +1106,7 @@ describe Braintree::Customer do
1106
1106
  it "validates the presence of three_d_secure_version while passing three_d_secure_pass_thru in update" do
1107
1107
  customer = Braintree::Customer.create!(
1108
1108
  :first_name => "Joe",
1109
- :last_name => "Cool"
1109
+ :last_name => "Cool",
1110
1110
  )
1111
1111
  result = Braintree::Customer.update(
1112
1112
  customer.id,
@@ -1119,16 +1119,16 @@ describe Braintree::Customer do
1119
1119
  :number => 4111111111111111,
1120
1120
  :expiration_date => "05/2060",
1121
1121
  :three_d_secure_pass_thru => {
1122
- :eci_flag => '02',
1123
- :cavv => 'some_cavv',
1124
- :xid => 'some_xid',
1125
- :authentication_response => 'Y',
1126
- :directory_response => 'Y',
1127
- :cavv_algorithm => '2',
1128
- :ds_transaction_id => 'some_ds_transaction_id',
1122
+ :eci_flag => "02",
1123
+ :cavv => "some_cavv",
1124
+ :xid => "some_xid",
1125
+ :authentication_response => "Y",
1126
+ :directory_response => "Y",
1127
+ :cavv_algorithm => "2",
1128
+ :ds_transaction_id => "some_ds_transaction_id",
1129
1129
  },
1130
1130
  options: {:verify_card => true}
1131
- }
1131
+ },
1132
1132
  )
1133
1133
  expect(result).to_not be_success
1134
1134
  error = result.errors.for(:verification).first
@@ -1139,7 +1139,7 @@ describe Braintree::Customer do
1139
1139
  it "updates the customer with the given id if successful" do
1140
1140
  customer = Braintree::Customer.create!(
1141
1141
  :first_name => "Joe",
1142
- :last_name => "Cool"
1142
+ :last_name => "Cool",
1143
1143
  )
1144
1144
  result = Braintree::Customer.update(
1145
1145
  customer.id,
@@ -1147,7 +1147,7 @@ describe Braintree::Customer do
1147
1147
  :last_name => "Super Cool",
1148
1148
  :custom_fields => {
1149
1149
  :store_me => "a value"
1150
- }
1150
+ },
1151
1151
  )
1152
1152
  result.success?.should == true
1153
1153
  result.customer.id.should == customer.id
@@ -1161,7 +1161,7 @@ describe Braintree::Customer do
1161
1161
  :credit_card => {
1162
1162
  :number => 4111111111111111,
1163
1163
  :expiration_date => "05/2010",
1164
- }
1164
+ },
1165
1165
  )
1166
1166
  result = Braintree::Customer.update(
1167
1167
  customer.id,
@@ -1171,7 +1171,7 @@ describe Braintree::Customer do
1171
1171
  :options=> {
1172
1172
  :fail_on_duplicate_payment_method => true
1173
1173
  }
1174
- }
1174
+ },
1175
1175
  )
1176
1176
  result.success?.should == false
1177
1177
  result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
@@ -1180,7 +1180,7 @@ describe Braintree::Customer do
1180
1180
  it "updates the default payment method" do
1181
1181
  customer = Braintree::Customer.create!(
1182
1182
  :first_name => "Joe",
1183
- :last_name => "Brown"
1183
+ :last_name => "Brown",
1184
1184
  )
1185
1185
 
1186
1186
  token1 = random_payment_method_token
@@ -1188,7 +1188,7 @@ describe Braintree::Customer do
1188
1188
  payment_method1 = Braintree::PaymentMethod.create(
1189
1189
  :customer_id => customer.id,
1190
1190
  :payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
1191
- :token => token1
1191
+ :token => token1,
1192
1192
  )
1193
1193
 
1194
1194
  payment_method1 = Braintree::PaymentMethod.find(token1)
@@ -1199,11 +1199,11 @@ describe Braintree::Customer do
1199
1199
  payment_method2 = Braintree::PaymentMethod.create(
1200
1200
  :customer_id => customer.id,
1201
1201
  :payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
1202
- :token => token2
1202
+ :token => token2,
1203
1203
  )
1204
1204
 
1205
1205
  Braintree::Customer.update(customer.id,
1206
- :default_payment_method_token => token2
1206
+ :default_payment_method_token => token2,
1207
1207
  )
1208
1208
 
1209
1209
  payment_method2 = Braintree::PaymentMethod.find(token2)
@@ -1213,7 +1213,7 @@ describe Braintree::Customer do
1213
1213
  it "updates the default payment method in the options" do
1214
1214
  customer = Braintree::Customer.create!(
1215
1215
  :first_name => "Joe",
1216
- :last_name => "Brown"
1216
+ :last_name => "Brown",
1217
1217
  )
1218
1218
 
1219
1219
  token1 = random_payment_method_token
@@ -1221,7 +1221,7 @@ describe Braintree::Customer do
1221
1221
  payment_method1 = Braintree::PaymentMethod.create(
1222
1222
  :customer_id => customer.id,
1223
1223
  :payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
1224
- :token => token1
1224
+ :token => token1,
1225
1225
  )
1226
1226
 
1227
1227
  payment_method1 = Braintree::PaymentMethod.find(token1)
@@ -1232,7 +1232,7 @@ describe Braintree::Customer do
1232
1232
  payment_method2 = Braintree::PaymentMethod.create(
1233
1233
  :customer_id => customer.id,
1234
1234
  :payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
1235
- :token => token2
1235
+ :token => token2,
1236
1236
  )
1237
1237
 
1238
1238
  Braintree::Customer.update(customer.id,
@@ -1241,7 +1241,7 @@ describe Braintree::Customer do
1241
1241
  :update_existing_token => token2,
1242
1242
  :make_default => true
1243
1243
  }
1244
- }
1244
+ },
1245
1245
  )
1246
1246
 
1247
1247
  payment_method2 = Braintree::PaymentMethod.find(token2)
@@ -1251,7 +1251,7 @@ describe Braintree::Customer do
1251
1251
  it "can use any country code" do
1252
1252
  customer = Braintree::Customer.create!(
1253
1253
  :first_name => "Alex",
1254
- :last_name => "Matterson"
1254
+ :last_name => "Matterson",
1255
1255
  )
1256
1256
  result = Braintree::Customer.update(
1257
1257
  customer.id,
@@ -1266,7 +1266,7 @@ describe Braintree::Customer do
1266
1266
  :country_code_alpha3 => "FJI",
1267
1267
  :country_code_numeric => "242"
1268
1268
  }
1269
- }
1269
+ },
1270
1270
  )
1271
1271
  result.success?.should == true
1272
1272
  result.customer.addresses[0].country_name.should == "Fiji"
@@ -1285,7 +1285,7 @@ describe Braintree::Customer do
1285
1285
  :first_name => "Joe",
1286
1286
  :postal_code => "60622"
1287
1287
  }
1288
- }
1288
+ },
1289
1289
  )
1290
1290
 
1291
1291
  result = Braintree::Customer.update(
@@ -1293,13 +1293,13 @@ describe Braintree::Customer do
1293
1293
  :first_name => "New Joe",
1294
1294
  :credit_card => {
1295
1295
  :cardholder_name => "New Joe Cardholder",
1296
- :options => { :update_existing_token => customer.credit_cards.first.token },
1296
+ :options => {:update_existing_token => customer.credit_cards.first.token},
1297
1297
  :billing_address => {
1298
1298
  :last_name => "Cool",
1299
1299
  :postal_code => "60666",
1300
- :options => { :update_existing => true }
1300
+ :options => {:update_existing => true}
1301
1301
  }
1302
- }
1302
+ },
1303
1303
  )
1304
1304
  result.success?.should == true
1305
1305
  result.customer.id.should == customer.id
@@ -1317,7 +1317,7 @@ describe Braintree::Customer do
1317
1317
 
1318
1318
  it "can update the customer and verify_card with a specific verification_amount" do
1319
1319
  customer = Braintree::Customer.create!(
1320
- :first_name => "Joe"
1320
+ :first_name => "Joe",
1321
1321
  )
1322
1322
 
1323
1323
  result = Braintree::Customer.update(
@@ -1327,8 +1327,8 @@ describe Braintree::Customer do
1327
1327
  :cardholder_name => "New Joe Cardholder",
1328
1328
  :number => Braintree::Test::CreditCardNumbers::Visa,
1329
1329
  :expiration_date => "12/2009",
1330
- :options => { :verify_card => true, :verification_amount => "2.00" }
1331
- }
1330
+ :options => {:verify_card => true, :verification_amount => "2.00"}
1331
+ },
1332
1332
  )
1333
1333
  result.success?.should == true
1334
1334
  end
@@ -1338,17 +1338,17 @@ describe Braintree::Customer do
1338
1338
  :payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
1339
1339
  :credit_card => {
1340
1340
  :three_d_secure_pass_thru => {
1341
- :eci_flag => '02',
1342
- :cavv => 'some_cavv',
1343
- :xid => 'some_xid',
1344
- :three_d_secure_version => 'xx',
1345
- :authentication_response => 'Y',
1346
- :directory_response => 'Y',
1347
- :cavv_algorithm => '2',
1348
- :ds_transaction_id => 'some_ds_transaction_id',
1341
+ :eci_flag => "02",
1342
+ :cavv => "some_cavv",
1343
+ :xid => "some_xid",
1344
+ :three_d_secure_version => "xx",
1345
+ :authentication_response => "Y",
1346
+ :directory_response => "Y",
1347
+ :cavv_algorithm => "2",
1348
+ :ds_transaction_id => "some_ds_transaction_id",
1349
1349
  },
1350
1350
  :options => {:verify_card => true}
1351
- }
1351
+ },
1352
1352
  )
1353
1353
 
1354
1354
  expect(result).not_to be_success
@@ -1362,17 +1362,17 @@ describe Braintree::Customer do
1362
1362
  :payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
1363
1363
  :credit_card => {
1364
1364
  :three_d_secure_pass_thru => {
1365
- :eci_flag => '02',
1366
- :cavv => 'some_cavv',
1367
- :xid => 'some_xid',
1368
- :three_d_secure_version => '2.2.1',
1369
- :authentication_response => 'Y',
1370
- :directory_response => 'Y',
1371
- :cavv_algorithm => '2',
1372
- :ds_transaction_id => 'some_ds_transaction_id',
1365
+ :eci_flag => "02",
1366
+ :cavv => "some_cavv",
1367
+ :xid => "some_xid",
1368
+ :three_d_secure_version => "2.2.1",
1369
+ :authentication_response => "Y",
1370
+ :directory_response => "Y",
1371
+ :cavv_algorithm => "2",
1372
+ :ds_transaction_id => "some_ds_transaction_id",
1373
1373
  },
1374
1374
  :options => {:verify_card => true}
1375
- }
1375
+ },
1376
1376
  )
1377
1377
 
1378
1378
  expect(result).to be_success
@@ -1383,7 +1383,7 @@ describe Braintree::Customer do
1383
1383
  :payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
1384
1384
  :credit_card => {
1385
1385
  :options => {:verify_card => true}
1386
- }
1386
+ },
1387
1387
  )
1388
1388
  result.success?.should == true
1389
1389
 
@@ -1405,7 +1405,7 @@ describe Braintree::Customer do
1405
1405
  address = Braintree::Address.create!(
1406
1406
  :customer_id => customer.id,
1407
1407
  :first_name => "John",
1408
- :last_name => "Doe"
1408
+ :last_name => "Doe",
1409
1409
  )
1410
1410
 
1411
1411
  customer = Braintree::Customer.update(
@@ -1414,7 +1414,7 @@ describe Braintree::Customer do
1414
1414
  :number => Braintree::Test::CreditCardNumbers::Visa,
1415
1415
  :expiration_date => "12/2009",
1416
1416
  :billing_address_id => address.id
1417
- }
1417
+ },
1418
1418
  ).customer
1419
1419
 
1420
1420
  billing_address = customer.credit_cards.first.billing_address
@@ -1427,7 +1427,7 @@ describe Braintree::Customer do
1427
1427
  customer = Braintree::Customer.create!(:email => "valid@email.com")
1428
1428
  result = Braintree::Customer.update(
1429
1429
  customer.id,
1430
- :email => "@invalid.com"
1430
+ :email => "@invalid.com",
1431
1431
  )
1432
1432
  result.success?.should == false
1433
1433
  result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
@@ -1436,7 +1436,7 @@ describe Braintree::Customer do
1436
1436
  context "verification_currency_iso_code" do
1437
1437
  it "can update the customer after validating verification_currency_iso_code" do
1438
1438
  customer = Braintree::Customer.create!(
1439
- :first_name => "Joe"
1439
+ :first_name => "Joe",
1440
1440
  )
1441
1441
 
1442
1442
  result = Braintree::Customer.update(
@@ -1446,8 +1446,8 @@ describe Braintree::Customer do
1446
1446
  :cardholder_name => "New Joe Cardholder",
1447
1447
  :number => Braintree::Test::CreditCardNumbers::Visa,
1448
1448
  :expiration_date => "12/2009",
1449
- :options => { :verify_card => true, :verification_currency_iso_code => "USD" }
1450
- }
1449
+ :options => {:verify_card => true, :verification_currency_iso_code => "USD"}
1450
+ },
1451
1451
  )
1452
1452
  result.success?.should == true
1453
1453
  result.customer.credit_cards[0].verification.currency_iso_code == "USD"
@@ -1455,7 +1455,7 @@ describe Braintree::Customer do
1455
1455
 
1456
1456
  it "can update the customer after validating verification_currency_iso_code against the given verification_merchant_account_id" do
1457
1457
  customer = Braintree::Customer.create!(
1458
- :first_name => "Joe"
1458
+ :first_name => "Joe",
1459
1459
  )
1460
1460
 
1461
1461
  result = Braintree::Customer.update(
@@ -1465,8 +1465,8 @@ describe Braintree::Customer do
1465
1465
  :cardholder_name => "New Joe Cardholder",
1466
1466
  :number => Braintree::Test::CreditCardNumbers::Visa,
1467
1467
  :expiration_date => "12/2009",
1468
- :options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD" }
1469
- }
1468
+ :options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"}
1469
+ },
1470
1470
  )
1471
1471
  result.success?.should == true
1472
1472
  result.customer.credit_cards[0].verification.currency_iso_code == "USD"
@@ -1475,7 +1475,7 @@ describe Braintree::Customer do
1475
1475
 
1476
1476
  it "throws error due to verification_currency_iso_code not matching against the currency configured in default merchant account" do
1477
1477
  customer = Braintree::Customer.create!(
1478
- :first_name => "Joe"
1478
+ :first_name => "Joe",
1479
1479
  )
1480
1480
 
1481
1481
  result = Braintree::Customer.update(
@@ -1485,8 +1485,8 @@ describe Braintree::Customer do
1485
1485
  :cardholder_name => "New Joe Cardholder",
1486
1486
  :number => Braintree::Test::CreditCardNumbers::Visa,
1487
1487
  :expiration_date => "12/2009",
1488
- :options => { :verify_card => true, :verification_currency_iso_code => "GBP" }
1489
- }
1488
+ :options => {:verify_card => true, :verification_currency_iso_code => "GBP"}
1489
+ },
1490
1490
  )
1491
1491
  result.success?.should == false
1492
1492
  expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
@@ -1495,7 +1495,7 @@ describe Braintree::Customer do
1495
1495
 
1496
1496
  it "throws error due to verification_currency_iso_code not matching against the currency configured in the given verification merchant account" do
1497
1497
  customer = Braintree::Customer.create!(
1498
- :first_name => "Joe"
1498
+ :first_name => "Joe",
1499
1499
  )
1500
1500
 
1501
1501
  result = Braintree::Customer.update(
@@ -1505,8 +1505,8 @@ describe Braintree::Customer do
1505
1505
  :cardholder_name => "New Joe Cardholder",
1506
1506
  :number => Braintree::Test::CreditCardNumbers::Visa,
1507
1507
  :expiration_date => "12/2009",
1508
- :options => { :verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP" }
1509
- }
1508
+ :options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"}
1509
+ },
1510
1510
  )
1511
1511
  result.success?.should == false
1512
1512
  expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
@@ -1529,7 +1529,7 @@ describe Braintree::Customer do
1529
1529
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
1530
1530
  :verification_account_type => "credit",
1531
1531
  },
1532
- }
1532
+ },
1533
1533
  )
1534
1534
  expect(update_result).to be_success
1535
1535
  end
@@ -1548,7 +1548,7 @@ describe Braintree::Customer do
1548
1548
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
1549
1549
  :verification_account_type => "debit",
1550
1550
  },
1551
- }
1551
+ },
1552
1552
  )
1553
1553
  expect(update_result).to be_success
1554
1554
  end
@@ -1559,12 +1559,12 @@ describe Braintree::Customer do
1559
1559
  it "returns the updated customer if successful" do
1560
1560
  customer = Braintree::Customer.create!(
1561
1561
  :first_name => "Joe",
1562
- :last_name => "Cool"
1562
+ :last_name => "Cool",
1563
1563
  )
1564
1564
  updated_customer = Braintree::Customer.update!(
1565
1565
  customer.id,
1566
1566
  :first_name => "Mr. Joe",
1567
- :last_name => "Super Cool"
1567
+ :last_name => "Super Cool",
1568
1568
  )
1569
1569
  updated_customer.first_name.should == "Mr. Joe"
1570
1570
  updated_customer.last_name.should == "Super Cool"
@@ -1588,7 +1588,7 @@ describe Braintree::Customer do
1588
1588
  :options => {
1589
1589
  :make_default => false
1590
1590
  }
1591
- }
1591
+ },
1592
1592
  )
1593
1593
 
1594
1594
  default_payment_method = Braintree::CreditCard.create!(
@@ -1597,7 +1597,7 @@ describe Braintree::Customer do
1597
1597
  :expiration_date => "11/2015",
1598
1598
  :options => {
1599
1599
  :make_default => true
1600
- }
1600
+ },
1601
1601
  )
1602
1602
 
1603
1603
  customer = Braintree::Customer.find(customer.id)
@@ -1610,7 +1610,7 @@ describe Braintree::Customer do
1610
1610
  context "future" do
1611
1611
  it "creates a customer with a future paypal account" do
1612
1612
  result = Braintree::Customer.create(
1613
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
1613
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
1614
1614
  )
1615
1615
 
1616
1616
  result.should be_success
@@ -1624,7 +1624,7 @@ describe Braintree::Customer do
1624
1624
  :options => {
1625
1625
  :make_default => true
1626
1626
  }
1627
- }
1627
+ },
1628
1628
  )
1629
1629
 
1630
1630
  paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
@@ -1633,12 +1633,12 @@ describe Braintree::Customer do
1633
1633
  :token => paypal_account_token,
1634
1634
  :options => {
1635
1635
  :make_default => true
1636
- }
1636
+ },
1637
1637
  )
1638
1638
 
1639
1639
  result = Braintree::Customer.update(
1640
1640
  customer.id,
1641
- :payment_method_nonce => nonce
1641
+ :payment_method_nonce => nonce,
1642
1642
  )
1643
1643
 
1644
1644
  result.should be_success
@@ -1654,7 +1654,7 @@ describe Braintree::Customer do
1654
1654
  :token => paypal_account_token,
1655
1655
  :options => {
1656
1656
  :make_default => true
1657
- }
1657
+ },
1658
1658
  )
1659
1659
 
1660
1660
  result = Braintree::Customer.create(
@@ -1690,7 +1690,7 @@ describe Braintree::Customer do
1690
1690
  :options => {
1691
1691
  :make_default => true
1692
1692
  }
1693
- }
1693
+ },
1694
1694
  )
1695
1695
 
1696
1696
  paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
@@ -1699,7 +1699,7 @@ describe Braintree::Customer do
1699
1699
  :token => paypal_account_token,
1700
1700
  :options => {
1701
1701
  :make_default => true
1702
- }
1702
+ },
1703
1703
  )
1704
1704
 
1705
1705
  result = Braintree::Customer.update(
@@ -1733,7 +1733,7 @@ describe Braintree::Customer do
1733
1733
  context "onetime" do
1734
1734
  it "does not create a customer with a onetime paypal account" do
1735
1735
  result = Braintree::Customer.create(
1736
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
1736
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
1737
1737
  )
1738
1738
 
1739
1739
  result.should_not be_success
@@ -1749,7 +1749,7 @@ describe Braintree::Customer do
1749
1749
  :options => {
1750
1750
  :make_default => true
1751
1751
  }
1752
- }
1752
+ },
1753
1753
  )
1754
1754
 
1755
1755
  paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
@@ -1758,12 +1758,12 @@ describe Braintree::Customer do
1758
1758
  :token => paypal_account_token,
1759
1759
  :options => {
1760
1760
  :make_default => true
1761
- }
1761
+ },
1762
1762
  )
1763
1763
 
1764
1764
  result = Braintree::Customer.update(
1765
1765
  customer.id,
1766
- :payment_method_nonce => nonce
1766
+ :payment_method_nonce => nonce,
1767
1767
  )
1768
1768
 
1769
1769
  result.should_not be_success