braintree 3.1.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +3 -3
  3. data/lib/braintree.rb +8 -1
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -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 +14 -4
  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 +6 -4
  19. data/lib/braintree/customer_gateway.rb +2 -0
  20. data/lib/braintree/customer_search.rb +1 -1
  21. data/lib/braintree/disbursement.rb +1 -1
  22. data/lib/braintree/dispute.rb +15 -1
  23. data/lib/braintree/dispute/paypal_message.rb +15 -0
  24. data/lib/braintree/dispute_gateway.rb +2 -2
  25. data/lib/braintree/dispute_search.rb +3 -2
  26. data/lib/braintree/document_upload.rb +1 -1
  27. data/lib/braintree/error_codes.rb +12 -4
  28. data/lib/braintree/google_pay_card.rb +1 -1
  29. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  30. data/lib/braintree/graphql_client.rb +7 -7
  31. data/lib/braintree/http.rb +3 -3
  32. data/lib/braintree/local_payment_completed.rb +1 -1
  33. data/lib/braintree/local_payment_reversed.rb +19 -0
  34. data/lib/braintree/merchant.rb +1 -1
  35. data/lib/braintree/merchant_account.rb +1 -1
  36. data/lib/braintree/merchant_account_gateway.rb +1 -1
  37. data/lib/braintree/merchant_gateway.rb +1 -1
  38. data/lib/braintree/modification.rb +1 -1
  39. data/lib/braintree/oauth_credentials.rb +1 -1
  40. data/lib/braintree/oauth_gateway.rb +5 -5
  41. data/lib/braintree/payment_instrument_type.rb +10 -10
  42. data/lib/braintree/payment_method_gateway.rb +11 -8
  43. data/lib/braintree/payment_method_nonce.rb +1 -1
  44. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  45. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  46. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  47. data/lib/braintree/plan.rb +1 -1
  48. data/lib/braintree/processor_response_types.rb +3 -3
  49. data/lib/braintree/resource_collection.rb +8 -3
  50. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  51. data/lib/braintree/risk_data.rb +3 -1
  52. data/lib/braintree/samsung_pay_card.rb +1 -1
  53. data/lib/braintree/settlement_batch_summary.rb +2 -2
  54. data/lib/braintree/subscription.rb +6 -6
  55. data/lib/braintree/test/credit_card.rb +1 -0
  56. data/lib/braintree/three_d_secure_info.rb +22 -12
  57. data/lib/braintree/transaction.rb +40 -24
  58. data/lib/braintree/transaction/installment.rb +28 -0
  59. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  60. data/lib/braintree/transaction_gateway.rb +27 -6
  61. data/lib/braintree/transaction_line_item.rb +1 -1
  62. data/lib/braintree/transaction_search.rb +3 -1
  63. data/lib/braintree/unknown_payment_method.rb +1 -1
  64. data/lib/braintree/us_bank_account.rb +3 -3
  65. data/lib/braintree/us_bank_account_verification.rb +1 -1
  66. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  67. data/lib/braintree/util.rb +4 -4
  68. data/lib/braintree/venmo_account.rb +1 -1
  69. data/lib/braintree/version.rb +1 -1
  70. data/lib/braintree/visa_checkout_card.rb +2 -2
  71. data/lib/braintree/webhook_notification.rb +30 -20
  72. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  73. data/lib/braintree/webhook_testing_gateway.rb +30 -0
  74. data/lib/braintree/xml/generator.rb +5 -4
  75. data/lib/braintree/xml/libxml.rb +0 -1
  76. data/lib/braintree/xml/parser.rb +22 -12
  77. data/lib/braintree/xml/rexml.rb +70 -0
  78. data/spec/integration/braintree/add_on_spec.rb +1 -1
  79. data/spec/integration/braintree/address_spec.rb +28 -24
  80. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  81. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  82. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  83. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  84. data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
  85. data/spec/integration/braintree/credit_card_spec.rb +213 -122
  86. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  87. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  88. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  89. data/spec/integration/braintree/customer_spec.rb +433 -149
  90. data/spec/integration/braintree/dispute_search_spec.rb +28 -3
  91. data/spec/integration/braintree/dispute_spec.rb +6 -6
  92. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  93. data/spec/integration/braintree/http_spec.rb +2 -2
  94. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  95. data/spec/integration/braintree/merchant_spec.rb +14 -14
  96. data/spec/integration/braintree/oauth_spec.rb +11 -11
  97. data/spec/integration/braintree/payment_method_nonce_spec.rb +26 -35
  98. data/spec/integration/braintree/payment_method_spec.rb +430 -149
  99. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  100. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  101. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  102. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  103. data/spec/integration/braintree/subscription_spec.rb +133 -133
  104. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  105. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  106. data/spec/integration/braintree/transaction_search_spec.rb +93 -67
  107. data/spec/integration/braintree/transaction_spec.rb +752 -383
  108. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  109. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  110. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  111. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  112. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  113. data/spec/integration/spec_helper.rb +9 -3
  114. data/spec/oauth_test_helper.rb +1 -1
  115. data/spec/script/httpsd.rb +6 -6
  116. data/spec/spec_helper.rb +6 -3
  117. data/spec/unit/braintree/address_spec.rb +1 -1
  118. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  119. data/spec/unit/braintree/client_token_spec.rb +2 -2
  120. data/spec/unit/braintree/configuration_spec.rb +42 -42
  121. data/spec/unit/braintree/credit_card_spec.rb +13 -13
  122. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  123. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  124. data/spec/unit/braintree/customer_spec.rb +21 -10
  125. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  126. data/spec/unit/braintree/dispute_search_spec.rb +1 -0
  127. data/spec/unit/braintree/dispute_spec.rb +34 -9
  128. data/spec/unit/braintree/error_result_spec.rb +5 -5
  129. data/spec/unit/braintree/errors_spec.rb +8 -8
  130. data/spec/unit/braintree/http_spec.rb +5 -5
  131. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  132. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  133. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  134. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  135. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  136. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  137. data/spec/unit/braintree/risk_data_spec.rb +9 -5
  138. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  139. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  140. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  141. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  142. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  143. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  144. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  145. data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
  146. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  147. data/spec/unit/braintree/transaction_spec.rb +25 -17
  148. data/spec/unit/braintree/util_spec.rb +18 -18
  149. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  150. data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
  151. data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
  152. data/spec/unit/braintree/xml_spec.rb +31 -31
  153. metadata +18 -8
  154. data/lib/braintree/settlement_batch.rb +0 -0
@@ -12,12 +12,12 @@ describe Braintree::PaymentMethodNonce do
12
12
  :number => "4111111111111111",
13
13
  :expiration_month => "11",
14
14
  :expiration_year => "2099",
15
- }
15
+ },
16
16
  )
17
17
 
18
18
  result = Braintree::PaymentMethod.create(
19
19
  :payment_method_nonce => nonce,
20
- :customer_id => customer.id
20
+ :customer_id => customer.id,
21
21
  )
22
22
 
23
23
  result.should be_success
@@ -49,12 +49,12 @@ describe Braintree::PaymentMethodNonce do
49
49
  :number => "4111111111111111",
50
50
  :expiration_month => "11",
51
51
  :expiration_year => "2099",
52
- }
52
+ },
53
53
  )
54
54
 
55
55
  payment_method = Braintree::PaymentMethod.create!(
56
56
  :payment_method_nonce => nonce,
57
- :customer_id => customer.id
57
+ :customer_id => customer.id,
58
58
  )
59
59
 
60
60
  payment_method.should be_a(Braintree::CreditCard)
@@ -79,33 +79,24 @@ describe Braintree::PaymentMethodNonce do
79
79
  result.should be_success
80
80
  nonce.nonce.should == "fake-valid-nonce"
81
81
  nonce.type.should == "CreditCard"
82
- nonce.details.fetch(:last_two).should == "81"
83
- nonce.details.fetch(:card_type).should == "Visa"
82
+ nonce.details.bin.should == "401288"
83
+ nonce.details.card_type.should == "Visa"
84
+ nonce.details.expiration_month.should == "12"
85
+ nonce.details.expiration_year.should == "2022"
86
+ nonce.details.is_network_tokenized?.should be_nil
87
+ nonce.details.last_two.should == "81"
88
+ nonce.details.payer_info.should be_nil
84
89
  end
85
90
 
86
91
  it "return paypal details if details exist" do
87
92
  result = Braintree::PaymentMethodNonce.find("fake-paypal-one-time-nonce")
88
93
  nonce = result.payment_method_nonce
89
-
90
- nonce.details.fetch(:cobranded_card_label).should_not be_nil
91
- nonce.details.fetch(:shipping_option_id).should_not be_nil
92
- nonce.details.fetch(:billing_address).fetch(:recipient_name).should_not be_nil
93
- nonce.details.fetch(:shipping_address).fetch(:recipient_name).should_not be_nil
94
-
95
- nonce.details.fetch(:payer_info).fetch(:first_name).should_not be_nil
96
- nonce.details.fetch(:payer_info).fetch(:last_name).should_not be_nil
97
- nonce.details.fetch(:payer_info).fetch(:email).should_not be_nil
98
- nonce.details.fetch(:payer_info).fetch(:payer_id).should_not be_nil
99
- end
100
-
101
- it "return venmo details if details exist" do
102
- result = Braintree::PaymentMethodNonce.find("fake-venmo-account-nonce")
103
-
104
- nonce = result.payment_method_nonce
105
-
106
- nonce.details.fetch(:last_two).should == "99"
107
- nonce.details.fetch(:username).should == "venmojoe"
108
- nonce.details.fetch(:venmo_user_id).should == "Venmo-Joe-1"
94
+ nonce.details.payer_info.billing_agreement_id.should be_nil
95
+ nonce.details.payer_info.country_code.should be_nil
96
+ nonce.details.payer_info.email.should_not be_nil
97
+ nonce.details.payer_info.first_name.should_not be_nil
98
+ nonce.details.payer_info.last_name.should_not be_nil
99
+ nonce.details.payer_info.payer_id.should_not be_nil
109
100
  end
110
101
 
111
102
  it "returns null 3ds_info if there isn't any" do
@@ -114,7 +105,7 @@ describe Braintree::PaymentMethodNonce do
114
105
  :number => "4111111111111111",
115
106
  :expiration_month => "11",
116
107
  :expiration_year => "2099",
117
- }
108
+ },
118
109
  )
119
110
 
120
111
  result = Braintree::PaymentMethodNonce.find(nonce)
@@ -131,7 +122,7 @@ describe Braintree::PaymentMethodNonce do
131
122
  nonce = result.payment_method_nonce
132
123
  result.should be_success
133
124
  nonce.details.should_not be_nil
134
- nonce.details[:bin].should == "401288"
125
+ nonce.details.bin.should == "401288"
135
126
  end
136
127
 
137
128
  it "returns bin_data with commercial set to Yes" do
@@ -257,19 +248,19 @@ describe Braintree::PaymentMethodNonce do
257
248
  context "regulation environments" do
258
249
  it "can get unregulated" do
259
250
  expect(
260
- request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment]
251
+ request_authentication_insights(european_merchant_token, indian_payment_token)[:regulation_environment],
261
252
  ).to eq "unregulated"
262
253
  end
263
254
 
264
255
  it "can get psd2" do
265
256
  expect(
266
- request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment]
257
+ request_authentication_insights(european_merchant_token, european_payment_token)[:regulation_environment],
267
258
  ).to eq "psd2"
268
259
  end
269
260
 
270
261
  it "can get rbi" do
271
262
  expect(
272
- request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment]
263
+ request_authentication_insights(indian_merchant_token, indian_payment_token)[:regulation_environment],
273
264
  ).to eq "rbi"
274
265
  end
275
266
  end
@@ -277,19 +268,19 @@ describe Braintree::PaymentMethodNonce do
277
268
  context "sca_indicator" do
278
269
  it "can get unavailable" do
279
270
  expect(
280
- request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator]
271
+ request_authentication_insights(indian_merchant_token, indian_payment_token)[:sca_indicator],
281
272
  ).to eq "unavailable"
282
273
  end
283
274
 
284
275
  it "can get sca_required" do
285
276
  expect(
286
- request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator]
277
+ request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2001})[:sca_indicator],
287
278
  ).to eq "sca_required"
288
279
  end
289
280
 
290
281
  it "can get sca_optional" do
291
282
  expect(
292
- request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator]
283
+ request_authentication_insights(indian_merchant_token, indian_payment_token, {amount: 2000, recurring_customer_consent: true, recurring_max_amount: 2000})[:sca_indicator],
293
284
 
294
285
  ).to eq "sca_optional"
295
286
  end
@@ -309,7 +300,7 @@ describe Braintree::PaymentMethodNonce do
309
300
 
310
301
  result = Braintree::PaymentMethodNonce.create(
311
302
  payment_method_token,
312
- payment_method_nonce: nonce_request
303
+ payment_method_nonce: nonce_request,
313
304
  )
314
305
  result.should be_success
315
306
 
@@ -17,20 +17,20 @@ describe Braintree::PaymentMethod do
17
17
  config,
18
18
  :authorization_fingerprint => authorization_fingerprint,
19
19
  :shared_customer_identifier => "fake_identifier",
20
- :shared_customer_identifier_type => "testing"
20
+ :shared_customer_identifier_type => "testing",
21
21
  )
22
22
 
23
23
  response = http.create_credit_card(
24
24
  :number => 4111111111111111,
25
25
  :expirationMonth => 12,
26
- :expirationYear => 2020
26
+ :expirationYear => 2020,
27
27
  )
28
28
  response.code.should == "201"
29
29
 
30
30
  nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
31
31
  result = Braintree::PaymentMethod.create(
32
32
  :payment_method_nonce => nonce,
33
- :customer_id => customer.id
33
+ :customer_id => customer.id,
34
34
  )
35
35
 
36
36
  result.should be_success
@@ -51,21 +51,21 @@ describe Braintree::PaymentMethod do
51
51
  config,
52
52
  :authorization_fingerprint => authorization_fingerprint,
53
53
  :shared_customer_identifier => "fake_identifier",
54
- :shared_customer_identifier_type => "testing"
54
+ :shared_customer_identifier_type => "testing",
55
55
  )
56
56
 
57
57
  response = http.create_credit_card(
58
58
  :number => "4111111111111111",
59
59
  :expirationMonth => "12",
60
60
  :expirationYear => "2020",
61
- :options => {:validate => false}
61
+ :options => {:validate => false},
62
62
  )
63
63
  response.code.should == "202"
64
64
 
65
65
  nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
66
66
  result = Braintree::PaymentMethod.create(
67
67
  :payment_method_nonce => nonce,
68
- :customer_id => customer.id
68
+ :customer_id => customer.id,
69
69
  )
70
70
 
71
71
  result.should be_success
@@ -82,7 +82,7 @@ describe Braintree::PaymentMethod do
82
82
  result = Braintree::PaymentMethod.create(
83
83
  :payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
84
84
  :customer_id => customer.id,
85
- :token => token
85
+ :token => token,
86
86
  )
87
87
 
88
88
  result.should be_success
@@ -107,7 +107,7 @@ describe Braintree::PaymentMethod do
107
107
  result = Braintree::PaymentMethod.create(
108
108
  :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
109
109
  :customer_id => customer.id,
110
- :token => token
110
+ :token => token,
111
111
  )
112
112
 
113
113
  result.should be_success
@@ -135,7 +135,7 @@ describe Braintree::PaymentMethod do
135
135
  result = Braintree::PaymentMethod.create(
136
136
  :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
137
137
  :customer_id => customer.id,
138
- :token => token
138
+ :token => token,
139
139
  )
140
140
 
141
141
  result.should be_success
@@ -163,7 +163,7 @@ describe Braintree::PaymentMethod do
163
163
  result = Braintree::PaymentMethod.create(
164
164
  :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
165
165
  :customer_id => customer.id,
166
- :token => token
166
+ :token => token,
167
167
  )
168
168
 
169
169
  result.should be_success
@@ -185,7 +185,7 @@ describe Braintree::PaymentMethod do
185
185
  :customer_id => customer.id,
186
186
  :number => Braintree::Test::CreditCardNumbers::Visa,
187
187
  :expiration_date => "05/2009",
188
- :cvv => "100"
188
+ :cvv => "100",
189
189
  )
190
190
  result.success?.should == true
191
191
  original_payment_method = result.credit_card
@@ -195,7 +195,7 @@ describe Braintree::PaymentMethod do
195
195
  result = Braintree::PaymentMethod.create(
196
196
  :payment_method_nonce => nonce,
197
197
  :customer_id => customer.id,
198
- :options => {:make_default => true}
198
+ :options => {:make_default => true},
199
199
  )
200
200
 
201
201
  result.should be_success
@@ -210,12 +210,12 @@ describe Braintree::PaymentMethod do
210
210
  second_token = make_token
211
211
  nonce = nonce_for_paypal_account(
212
212
  :consent_code => "PAYPAL_CONSENT_CODE",
213
- :token => first_token
213
+ :token => first_token,
214
214
  )
215
215
  result = Braintree::PaymentMethod.create(
216
216
  :payment_method_nonce => nonce,
217
217
  :customer_id => customer.id,
218
- :token => second_token
218
+ :token => second_token,
219
219
  )
220
220
 
221
221
  result.should be_success
@@ -229,7 +229,7 @@ describe Braintree::PaymentMethod do
229
229
  :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
230
230
  :expiration_month => "11",
231
231
  :expiration_year => "2099",
232
- }
232
+ },
233
233
  )
234
234
  customer = Braintree::Customer.create!
235
235
  result = Braintree::PaymentMethod.create(
@@ -238,7 +238,7 @@ describe Braintree::PaymentMethod do
238
238
  :options => {
239
239
  :verify_card => true,
240
240
  :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
241
- }
241
+ },
242
242
  )
243
243
 
244
244
  result.should_not be_success
@@ -254,7 +254,7 @@ describe Braintree::PaymentMethod do
254
254
  :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::Visa,
255
255
  :expiration_month => "11",
256
256
  :expiration_year => "2099",
257
- }
257
+ },
258
258
  )
259
259
  customer = Braintree::Customer.create!
260
260
  result = Braintree::PaymentMethod.create(
@@ -263,7 +263,7 @@ describe Braintree::PaymentMethod do
263
263
  :options => {
264
264
  :verify_card => true,
265
265
  :verification_amount => "100.00"
266
- }
266
+ },
267
267
  )
268
268
 
269
269
  result.should_not be_success
@@ -279,16 +279,16 @@ describe Braintree::PaymentMethod do
279
279
  :customer_id => customer.id,
280
280
  :payment_method_nonce => Braintree::Test::Nonce::Transactable,
281
281
  :three_d_secure_pass_thru => {
282
- :eci_flag => '02',
283
- :cavv => 'some_cavv',
284
- :xid => 'some_xid',
285
- :three_d_secure_version => 'xx',
286
- :authentication_response => 'Y',
287
- :directory_response => 'Y',
288
- :cavv_algorithm => '2',
289
- :ds_transaction_id => 'some_ds_transaction_id',
282
+ :eci_flag => "02",
283
+ :cavv => "some_cavv",
284
+ :xid => "some_xid",
285
+ :three_d_secure_version => "xx",
286
+ :authentication_response => "Y",
287
+ :directory_response => "Y",
288
+ :cavv_algorithm => "2",
289
+ :ds_transaction_id => "some_ds_transaction_id",
290
290
  },
291
- :options => {:verify_card => true}
291
+ :options => {:verify_card => true},
292
292
  )
293
293
  expect(result).not_to be_success
294
294
  error = result.errors.for(:verification).first
@@ -302,16 +302,16 @@ describe Braintree::PaymentMethod do
302
302
  :customer_id => customer.id,
303
303
  :payment_method_nonce => Braintree::Test::Nonce::Transactable,
304
304
  :three_d_secure_pass_thru => {
305
- :eci_flag => '02',
306
- :cavv => 'some_cavv',
307
- :xid => 'some_xid',
308
- :three_d_secure_version => '1.0.2',
309
- :authentication_response => 'Y',
310
- :directory_response => 'Y',
311
- :cavv_algorithm => '2',
312
- :ds_transaction_id => 'some_ds_transaction_id',
305
+ :eci_flag => "02",
306
+ :cavv => "some_cavv",
307
+ :xid => "some_xid",
308
+ :three_d_secure_version => "1.0.2",
309
+ :authentication_response => "Y",
310
+ :directory_response => "Y",
311
+ :cavv_algorithm => "2",
312
+ :ds_transaction_id => "some_ds_transaction_id",
313
313
  },
314
- :options => {:verify_card => true}
314
+ :options => {:verify_card => true},
315
315
  )
316
316
 
317
317
  expect(result).to be_success
@@ -343,7 +343,7 @@ describe Braintree::PaymentMethod do
343
343
  result = Braintree::CreditCard.create(
344
344
  :customer_id => customer.id,
345
345
  :number => Braintree::Test::CreditCardNumbers::Visa,
346
- :expiration_date => "05/2012"
346
+ :expiration_date => "05/2012",
347
347
  )
348
348
  result.should be_success
349
349
 
@@ -351,14 +351,14 @@ describe Braintree::PaymentMethod do
351
351
  :credit_card => {
352
352
  :number => Braintree::Test::CreditCardNumbers::Visa,
353
353
  :expiration_date => "05/2012"
354
- }
354
+ },
355
355
  )
356
356
  result = Braintree::PaymentMethod.create(
357
357
  :payment_method_nonce => nonce,
358
358
  :customer_id => customer.id,
359
359
  :options => {
360
360
  :fail_on_duplicate_payment_method => true
361
- }
361
+ },
362
362
  )
363
363
 
364
364
  result.should_not be_success
@@ -375,14 +375,14 @@ describe Braintree::PaymentMethod do
375
375
  config,
376
376
  :authorization_fingerprint => authorization_fingerprint,
377
377
  :shared_customer_identifier => "fake_identifier",
378
- :shared_customer_identifier_type => "testing"
378
+ :shared_customer_identifier_type => "testing",
379
379
  )
380
380
 
381
381
  response = http.create_credit_card(
382
382
  :number => "4111111111111111",
383
383
  :expirationMonth => "12",
384
384
  :expirationYear => "2020",
385
- :options => {:validate => false}
385
+ :options => {:validate => false},
386
386
  )
387
387
  response.code.should == "202"
388
388
 
@@ -392,7 +392,7 @@ describe Braintree::PaymentMethod do
392
392
  :customer_id => customer.id,
393
393
  :billing_address => {
394
394
  :street_address => "123 Abc Way"
395
- }
395
+ },
396
396
  )
397
397
 
398
398
  result.should be_success
@@ -414,14 +414,14 @@ describe Braintree::PaymentMethod do
414
414
  config,
415
415
  :authorization_fingerprint => authorization_fingerprint,
416
416
  :shared_customer_identifier => "fake_identifier",
417
- :shared_customer_identifier_type => "testing"
417
+ :shared_customer_identifier_type => "testing",
418
418
  )
419
419
 
420
420
  response = http.create_credit_card(
421
421
  :number => "4111111111111111",
422
422
  :expirationMonth => "12",
423
423
  :expirationYear => "2020",
424
- :options => {:validate => false}
424
+ :options => {:validate => false},
425
425
  )
426
426
  response.code.should == "202"
427
427
 
@@ -431,7 +431,7 @@ describe Braintree::PaymentMethod do
431
431
  result = Braintree::PaymentMethod.create(
432
432
  :payment_method_nonce => nonce,
433
433
  :customer_id => customer.id,
434
- :billing_address_id => address.id
434
+ :billing_address_id => address.id,
435
435
  )
436
436
 
437
437
  result.should be_success
@@ -454,7 +454,7 @@ describe Braintree::PaymentMethod do
454
454
  config,
455
455
  :authorization_fingerprint => authorization_fingerprint,
456
456
  :shared_customer_identifier => "fake_identifier",
457
- :shared_customer_identifier_type => "testing"
457
+ :shared_customer_identifier_type => "testing",
458
458
  )
459
459
 
460
460
  response = http.create_credit_card(
@@ -464,7 +464,7 @@ describe Braintree::PaymentMethod do
464
464
  :options => {:validate => false},
465
465
  :billing_address => {
466
466
  :street_address => "456 Xyz Way"
467
- }
467
+ },
468
468
  )
469
469
  response.code.should == "202"
470
470
 
@@ -474,7 +474,7 @@ describe Braintree::PaymentMethod do
474
474
  :customer_id => customer.id,
475
475
  :billing_address => {
476
476
  :street_address => "123 Abc Way"
477
- }
477
+ },
478
478
  )
479
479
 
480
480
  result.should be_success
@@ -496,7 +496,7 @@ describe Braintree::PaymentMethod do
496
496
  config,
497
497
  :authorization_fingerprint => authorization_fingerprint,
498
498
  :shared_customer_identifier => "fake_identifier",
499
- :shared_customer_identifier_type => "testing"
499
+ :shared_customer_identifier_type => "testing",
500
500
  )
501
501
 
502
502
  response = http.create_credit_card(
@@ -505,7 +505,7 @@ describe Braintree::PaymentMethod do
505
505
  :expirationYear => 2020,
506
506
  :billing_address => {
507
507
  :street_address => "456 Xyz Way"
508
- }
508
+ },
509
509
  )
510
510
  response.code.should == "201"
511
511
 
@@ -515,7 +515,7 @@ describe Braintree::PaymentMethod do
515
515
  :customer_id => customer.id,
516
516
  :billing_address => {
517
517
  :street_address => "123 Abc Way"
518
- }
518
+ },
519
519
  )
520
520
 
521
521
  result.should be_success
@@ -527,6 +527,58 @@ describe Braintree::PaymentMethod do
527
527
  found_credit_card.billing_address.street_address.should == "456 Xyz Way"
528
528
  end
529
529
 
530
+ it "includes risk data when skip_advanced_fraud_checking is false" do
531
+ with_fraud_protection_enterprise_merchant do
532
+ customer = Braintree::Customer.create!
533
+
534
+ nonce = nonce_for_new_payment_method(
535
+ :credit_card => {
536
+ :cvv => "123",
537
+ :number => Braintree::Test::CreditCardNumbers::Visa,
538
+ :expiration_date => "05/2009",
539
+ },
540
+ )
541
+ result = Braintree::PaymentMethod.create(
542
+ :payment_method_nonce => nonce,
543
+ :customer_id => customer.id,
544
+ :options => {
545
+ :verify_card => true,
546
+ :skip_advanced_fraud_checking => false,
547
+ },
548
+ )
549
+
550
+ expect(result).to be_success
551
+ verification = result.payment_method.verification
552
+ expect(verification.risk_data).not_to be_nil
553
+ end
554
+ end
555
+
556
+ it "does not include risk data when skip_advanced_fraud_checking is true" do
557
+ with_fraud_protection_enterprise_merchant do
558
+ customer = Braintree::Customer.create!
559
+
560
+ nonce = nonce_for_new_payment_method(
561
+ :credit_card => {
562
+ :cvv => "123",
563
+ :number => Braintree::Test::CreditCardNumbers::Visa,
564
+ :expiration_date => "05/2009",
565
+ },
566
+ )
567
+ result = Braintree::PaymentMethod.create(
568
+ :payment_method_nonce => nonce,
569
+ :customer_id => customer.id,
570
+ :options => {
571
+ :verify_card => true,
572
+ :skip_advanced_fraud_checking => true,
573
+ },
574
+ )
575
+
576
+ expect(result).to be_success
577
+ verification = result.payment_method.verification
578
+ expect(verification.risk_data).to be_nil
579
+ end
580
+ end
581
+
530
582
  context "account_type" do
531
583
  it "verifies card with account_type debit" do
532
584
  nonce = nonce_for_new_payment_method(
@@ -534,7 +586,7 @@ describe Braintree::PaymentMethod do
534
586
  :number => Braintree::Test::CreditCardNumbers::Hiper,
535
587
  :expiration_month => "11",
536
588
  :expiration_year => "2099",
537
- }
589
+ },
538
590
  )
539
591
  customer = Braintree::Customer.create!
540
592
  result = Braintree::PaymentMethod.create(
@@ -544,7 +596,7 @@ describe Braintree::PaymentMethod do
544
596
  :verify_card => true,
545
597
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
546
598
  :verification_account_type => "debit",
547
- }
599
+ },
548
600
  )
549
601
 
550
602
  result.should be_success
@@ -557,7 +609,7 @@ describe Braintree::PaymentMethod do
557
609
  :number => Braintree::Test::CreditCardNumbers::Hiper,
558
610
  :expiration_month => "11",
559
611
  :expiration_year => "2099",
560
- }
612
+ },
561
613
  )
562
614
  customer = Braintree::Customer.create!
563
615
  result = Braintree::PaymentMethod.create(
@@ -567,7 +619,7 @@ describe Braintree::PaymentMethod do
567
619
  :verify_card => true,
568
620
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
569
621
  :verification_account_type => "credit",
570
- }
622
+ },
571
623
  )
572
624
 
573
625
  result.should be_success
@@ -580,7 +632,7 @@ describe Braintree::PaymentMethod do
580
632
  :number => Braintree::Test::CreditCardNumbers::Hiper,
581
633
  :expiration_month => "11",
582
634
  :expiration_year => "2099",
583
- }
635
+ },
584
636
  )
585
637
  customer = Braintree::Customer.create!
586
638
  result = Braintree::PaymentMethod.create(
@@ -590,7 +642,7 @@ describe Braintree::PaymentMethod do
590
642
  :verify_card => true,
591
643
  :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
592
644
  :verification_account_type => "ach",
593
- }
645
+ },
594
646
  )
595
647
 
596
648
  result.should_not be_success
@@ -603,7 +655,7 @@ describe Braintree::PaymentMethod do
603
655
  :number => Braintree::Test::CreditCardNumbers::Visa,
604
656
  :expiration_month => "11",
605
657
  :expiration_year => "2099",
606
- }
658
+ },
607
659
  )
608
660
  customer = Braintree::Customer.create!
609
661
  result = Braintree::PaymentMethod.create(
@@ -612,7 +664,7 @@ describe Braintree::PaymentMethod do
612
664
  :options => {
613
665
  :verify_card => true,
614
666
  :verification_account_type => "credit",
615
- }
667
+ },
616
668
  )
617
669
 
618
670
  result.should_not be_success
@@ -626,7 +678,7 @@ describe Braintree::PaymentMethod do
626
678
  :customer_id => customer.id,
627
679
  :cvv => "123",
628
680
  :number => Braintree::Test::CreditCardNumbers::Visa,
629
- :expiration_date => "05/2012"
681
+ :expiration_date => "05/2012",
630
682
  )
631
683
  update_result = Braintree::PaymentMethod.update(credit_card.token,
632
684
  :cardholder_name => "New Holder",
@@ -650,7 +702,7 @@ describe Braintree::PaymentMethod do
650
702
  :customer_id => customer.id,
651
703
  :cvv => "123",
652
704
  :number => Braintree::Test::CreditCardNumbers::Visa,
653
- :expiration_date => "05/2012"
705
+ :expiration_date => "05/2012",
654
706
  )
655
707
  update_result = Braintree::PaymentMethod.update(credit_card.token,
656
708
  :cardholder_name => "New Holder",
@@ -674,7 +726,7 @@ describe Braintree::PaymentMethod do
674
726
  customer = Braintree::Customer.create.customer
675
727
  result = Braintree::PaymentMethod.create(
676
728
  :payment_method_nonce => nonce,
677
- :customer_id => customer.id
729
+ :customer_id => customer.id,
678
730
  )
679
731
 
680
732
  result.should be_success
@@ -751,7 +803,7 @@ describe Braintree::PaymentMethod do
751
803
  nonce = nonce_for_paypal_account(:access_token => "PAYPAL_ACCESS_TOKEN")
752
804
  result = Braintree::PaymentMethod.create(
753
805
  :payment_method_nonce => nonce,
754
- :customer_id => customer.id
806
+ :customer_id => customer.id,
755
807
  )
756
808
 
757
809
  result.should_not be_success
@@ -766,7 +818,7 @@ describe Braintree::PaymentMethod do
766
818
  :customer_id => customer.id,
767
819
  :billing_address => {
768
820
  :street_address => "123 Abc Way"
769
- }
821
+ },
770
822
  )
771
823
 
772
824
  result.should be_success
@@ -784,7 +836,7 @@ describe Braintree::PaymentMethod do
784
836
  result = Braintree::PaymentMethod.create(
785
837
  :payment_method_nonce => nonce,
786
838
  :customer_id => customer.id,
787
- :billing_address_id => "address_id"
839
+ :billing_address_id => "address_id",
788
840
  )
789
841
 
790
842
  result.should be_success
@@ -801,7 +853,7 @@ describe Braintree::PaymentMethod do
801
853
  nonce = nonce_for_paypal_account(:token => "PAYPAL_TOKEN")
802
854
  result = Braintree::PaymentMethod.create(
803
855
  :payment_method_nonce => nonce,
804
- :customer_id => customer.id
856
+ :customer_id => customer.id,
805
857
  )
806
858
 
807
859
  result.should_not be_success
@@ -815,7 +867,7 @@ describe Braintree::PaymentMethod do
815
867
  original_token = random_payment_method_token
816
868
  nonce = nonce_for_paypal_account(
817
869
  :consent_code => "consent-code",
818
- :token => original_token
870
+ :token => original_token,
819
871
  )
820
872
 
821
873
  result = Braintree::PaymentMethod.create(
@@ -825,7 +877,7 @@ describe Braintree::PaymentMethod do
825
877
  :verify_card => true,
826
878
  :fail_on_duplicate_payment_method => true,
827
879
  :verification_merchant_account_id => "not_a_real_merchant_account_id"
828
- }
880
+ },
829
881
  )
830
882
 
831
883
  result.should be_success
@@ -839,7 +891,7 @@ describe Braintree::PaymentMethod do
839
891
  result = Braintree::PaymentMethod.create(
840
892
  :payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
841
893
  :customer_id => customer.id,
842
- :token => token
894
+ :token => token,
843
895
  )
844
896
 
845
897
  result.should be_success
@@ -849,6 +901,99 @@ describe Braintree::PaymentMethod do
849
901
  payment_method.should be_a Braintree::UnknownPaymentMethod
850
902
  end
851
903
  end
904
+
905
+ context "verification_currency_iso_code" do
906
+ it "validates verification_currency_iso_code against currency configured in default merchant account" do
907
+ nonce = nonce_for_new_payment_method(
908
+ :credit_card => {
909
+ :number => Braintree::Test::CreditCardNumbers::Visa,
910
+ :expiration_month => "11",
911
+ :expiration_year => "2099",
912
+ },
913
+ )
914
+ customer = Braintree::Customer.create!
915
+ result = Braintree::PaymentMethod.create(
916
+ :payment_method_nonce => nonce,
917
+ :customer_id => customer.id,
918
+ :options => {
919
+ :verify_card => true,
920
+ :verification_currency_iso_code => "USD"
921
+ },
922
+ )
923
+
924
+ result.should be_success
925
+ result.payment_method.verification.currency_iso_code == "USD"
926
+ end
927
+
928
+ it "validates verification_currency_iso_code against currency configured in verification_merchant_account_id" do
929
+ nonce = nonce_for_new_payment_method(
930
+ :credit_card => {
931
+ :number => Braintree::Test::CreditCardNumbers::Visa,
932
+ :expiration_month => "11",
933
+ :expiration_year => "2099",
934
+ },
935
+ )
936
+ customer = Braintree::Customer.create!
937
+ result = Braintree::PaymentMethod.create(
938
+ :payment_method_nonce => nonce,
939
+ :customer_id => customer.id,
940
+ :options => {
941
+ :verify_card => true,
942
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
943
+ :verification_currency_iso_code => "USD"
944
+ },
945
+ )
946
+
947
+ result.should be_success
948
+ result.payment_method.verification.currency_iso_code == "USD"
949
+ result.payment_method.verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
950
+ end
951
+
952
+
953
+ it "errors with invalid presentment currency due to verification_currency_iso_code not matching with currency configured in default merchant account" do
954
+ nonce = nonce_for_new_payment_method(
955
+ :credit_card => {
956
+ :number => Braintree::Test::CreditCardNumbers::Visa,
957
+ :expiration_month => "11",
958
+ :expiration_year => "2099",
959
+ },
960
+ )
961
+ customer = Braintree::Customer.create!
962
+ result = Braintree::PaymentMethod.create(
963
+ :payment_method_nonce => nonce,
964
+ :customer_id => customer.id,
965
+ :options => {
966
+ :verify_card => true,
967
+ :verification_currency_iso_code => "GBP"
968
+ },
969
+ )
970
+ result.should_not be_success
971
+ result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
972
+ end
973
+
974
+ it "errors with invalid presentment currency due to verification_currency_iso_code not matching with currency configured in verification_merchant_account_id" do
975
+ nonce = nonce_for_new_payment_method(
976
+ :credit_card => {
977
+ :number => Braintree::Test::CreditCardNumbers::Visa,
978
+ :expiration_month => "11",
979
+ :expiration_year => "2099",
980
+ },
981
+ )
982
+ customer = Braintree::Customer.create!
983
+ result = Braintree::PaymentMethod.create(
984
+ :payment_method_nonce => nonce,
985
+ :customer_id => customer.id,
986
+ :options => {
987
+ :verify_card => true,
988
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
989
+ :verification_currency_iso_code => "GBP"
990
+ },
991
+ )
992
+
993
+ result.should_not be_success
994
+ result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
995
+ end
996
+ end
852
997
  end
853
998
 
854
999
  describe "self.create!" do
@@ -862,20 +1007,20 @@ describe Braintree::PaymentMethod do
862
1007
  config,
863
1008
  :authorization_fingerprint => authorization_fingerprint,
864
1009
  :shared_customer_identifier => "fake_identifier",
865
- :shared_customer_identifier_type => "testing"
1010
+ :shared_customer_identifier_type => "testing",
866
1011
  )
867
1012
 
868
1013
  response = http.create_credit_card(
869
1014
  :number => 4111111111111111,
870
1015
  :expirationMonth => 12,
871
- :expirationYear => 2020
1016
+ :expirationYear => 2020,
872
1017
  )
873
1018
  response.code.should == "201"
874
1019
 
875
1020
  nonce = JSON.parse(response.body)["creditCards"].first["nonce"]
876
1021
  payment_method = Braintree::PaymentMethod.create!(
877
1022
  :payment_method_nonce => nonce,
878
- :customer_id => customer.id
1023
+ :customer_id => customer.id,
879
1024
  )
880
1025
 
881
1026
  payment_method.should be_a(Braintree::CreditCard)
@@ -893,7 +1038,7 @@ describe Braintree::PaymentMethod do
893
1038
  result = Braintree::CreditCard.create(
894
1039
  :customer_id => customer.id,
895
1040
  :number => Braintree::Test::CreditCardNumbers::Visa,
896
- :expiration_date => "05/2012"
1041
+ :expiration_date => "05/2012",
897
1042
  )
898
1043
  result.success?.should == true
899
1044
 
@@ -909,13 +1054,13 @@ describe Braintree::PaymentMethod do
909
1054
  credit_card = Braintree::CreditCard.create(
910
1055
  :customer_id => customer.id,
911
1056
  :number => Braintree::Test::CreditCardNumbers::Visa,
912
- :expiration_date => "05/2012"
1057
+ :expiration_date => "05/2012",
913
1058
  ).credit_card
914
1059
 
915
1060
  subscription = Braintree::Subscription.create(
916
1061
  :payment_method_token => credit_card.token,
917
1062
  :plan_id => "integration_trialless_plan",
918
- :price => "1.00"
1063
+ :price => "1.00",
919
1064
  ).subscription
920
1065
 
921
1066
  found_card = Braintree::PaymentMethod.find(credit_card.token)
@@ -932,11 +1077,11 @@ describe Braintree::PaymentMethod do
932
1077
  payment_method_token = make_token
933
1078
  nonce = nonce_for_paypal_account(
934
1079
  :consent_code => "consent-code",
935
- :token => payment_method_token
1080
+ :token => payment_method_token,
936
1081
  )
937
1082
  result = Braintree::PaymentMethod.create(
938
1083
  :payment_method_nonce => nonce,
939
- :customer_id => customer.id
1084
+ :customer_id => customer.id,
940
1085
  )
941
1086
  result.should be_success
942
1087
 
@@ -955,7 +1100,7 @@ describe Braintree::PaymentMethod do
955
1100
  result = Braintree::PaymentMethod.create(
956
1101
  :payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
957
1102
  :customer_id => customer.id,
958
- :token => payment_method_token
1103
+ :token => payment_method_token,
959
1104
  )
960
1105
  result.should be_success
961
1106
 
@@ -980,7 +1125,7 @@ describe Braintree::PaymentMethod do
980
1125
  result = Braintree::PaymentMethod.create(
981
1126
  :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
982
1127
  :customer_id => customer.id,
983
- :token => payment_method_token
1128
+ :token => payment_method_token,
984
1129
  )
985
1130
  result.should be_success
986
1131
 
@@ -990,8 +1135,8 @@ describe Braintree::PaymentMethod do
990
1135
  venmo_account.token.should == payment_method_token
991
1136
  venmo_account.default.should == true
992
1137
  venmo_account.image_url.should =~ /venmo/
993
- venmo_account.username.should == 'venmojoe'
994
- venmo_account.venmo_user_id.should == 'Venmo-Joe-1'
1138
+ venmo_account.username.should == "venmojoe"
1139
+ venmo_account.venmo_user_id.should == "Venmo-Joe-1"
995
1140
  venmo_account.source_description.should == "Venmo Account: venmojoe"
996
1141
  venmo_account.customer_id.should == customer.id
997
1142
  end
@@ -1004,7 +1149,7 @@ describe Braintree::PaymentMethod do
1004
1149
  result = Braintree::PaymentMethod.create(
1005
1150
  :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
1006
1151
  :customer_id => customer.id,
1007
- :token => payment_method_token
1152
+ :token => payment_method_token,
1008
1153
  )
1009
1154
  result.should be_success
1010
1155
 
@@ -1032,7 +1177,7 @@ describe Braintree::PaymentMethod do
1032
1177
  result = Braintree::PaymentMethod.create(
1033
1178
  :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
1034
1179
  :customer_id => customer.id,
1035
- :token => payment_method_token
1180
+ :token => payment_method_token,
1036
1181
  )
1037
1182
  result.should be_success
1038
1183
 
@@ -1062,7 +1207,7 @@ describe Braintree::PaymentMethod do
1062
1207
  result = Braintree::PaymentMethod.create(
1063
1208
  :payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
1064
1209
  :customer_id => customer.id,
1065
- :token => payment_method_token
1210
+ :token => payment_method_token,
1066
1211
  )
1067
1212
  result.should be_success
1068
1213
 
@@ -1088,7 +1233,7 @@ describe Braintree::PaymentMethod do
1088
1233
 
1089
1234
  create_result = Braintree::PaymentMethod.create(
1090
1235
  :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
1091
- :customer_id => customer.id
1236
+ :customer_id => customer.id,
1092
1237
  )
1093
1238
 
1094
1239
  token = create_result.payment_method.token
@@ -1109,7 +1254,7 @@ describe Braintree::PaymentMethod do
1109
1254
 
1110
1255
  create_result = Braintree::PaymentMethod.create(
1111
1256
  :payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
1112
- :customer_id => customer.id
1257
+ :customer_id => customer.id,
1113
1258
  )
1114
1259
  token = create_result.payment_method.token
1115
1260
 
@@ -1130,11 +1275,11 @@ describe Braintree::PaymentMethod do
1130
1275
 
1131
1276
  nonce = nonce_for_paypal_account(
1132
1277
  :consent_code => "PAYPAL_CONSENT_CODE",
1133
- :token => paypal_account_token
1278
+ :token => paypal_account_token,
1134
1279
  )
1135
1280
  Braintree::PaymentMethod.create(
1136
1281
  :payment_method_nonce => nonce,
1137
- :customer_id => customer.id
1282
+ :customer_id => customer.id,
1138
1283
  )
1139
1284
 
1140
1285
  paypal_account = Braintree::PaymentMethod.find(paypal_account_token)
@@ -1163,7 +1308,7 @@ describe Braintree::PaymentMethod do
1163
1308
 
1164
1309
  Braintree::PaymentMethod.create(
1165
1310
  :payment_method_nonce => nonce,
1166
- :customer_id => customer.id
1311
+ :customer_id => customer.id,
1167
1312
  )
1168
1313
 
1169
1314
  result = Braintree::PaymentMethod.delete(token)
@@ -1200,14 +1345,14 @@ describe Braintree::PaymentMethod do
1200
1345
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
1201
1346
  :expiration_date => "06/2013",
1202
1347
  :three_d_secure_pass_thru => {
1203
- :eci_flag => '02',
1204
- :cavv => 'some_cavv',
1205
- :xid => 'some_xid',
1206
- :three_d_secure_version => 'xx',
1207
- :authentication_response => 'Y',
1208
- :directory_response => 'Y',
1209
- :cavv_algorithm => '2',
1210
- :ds_transaction_id => 'some_ds_transaction_id',
1348
+ :eci_flag => "02",
1349
+ :cavv => "some_cavv",
1350
+ :xid => "some_xid",
1351
+ :three_d_secure_version => "xx",
1352
+ :authentication_response => "Y",
1353
+ :directory_response => "Y",
1354
+ :cavv_algorithm => "2",
1355
+ :ds_transaction_id => "some_ds_transaction_id",
1211
1356
  },
1212
1357
  :options => {:verify_card => true},
1213
1358
  )
@@ -1231,14 +1376,14 @@ describe Braintree::PaymentMethod do
1231
1376
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
1232
1377
  :expiration_date => "06/2013",
1233
1378
  :three_d_secure_pass_thru => {
1234
- :eci_flag => '02',
1235
- :cavv => 'some_cavv',
1236
- :xid => 'some_xid',
1237
- :three_d_secure_version => '1.0.2',
1238
- :authentication_response => 'Y',
1239
- :directory_response => 'Y',
1240
- :cavv_algorithm => '2',
1241
- :ds_transaction_id => 'some_ds_transaction_id',
1379
+ :eci_flag => "02",
1380
+ :cavv => "some_cavv",
1381
+ :xid => "some_xid",
1382
+ :three_d_secure_version => "1.0.2",
1383
+ :authentication_response => "Y",
1384
+ :directory_response => "Y",
1385
+ :cavv_algorithm => "2",
1386
+ :ds_transaction_id => "some_ds_transaction_id",
1242
1387
  },
1243
1388
  :options => {:verify_card => true},
1244
1389
  )
@@ -1258,13 +1403,13 @@ describe Braintree::PaymentMethod do
1258
1403
  :customer_id => customer.id,
1259
1404
  :cvv => "123",
1260
1405
  :number => Braintree::Test::CreditCardNumbers::Visa,
1261
- :expiration_date => "05/2012"
1406
+ :expiration_date => "05/2012",
1262
1407
  )
1263
1408
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1264
1409
  :cardholder_name => "New Holder",
1265
1410
  :cvv => "456",
1266
1411
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
1267
- :expiration_date => "06/2013"
1412
+ :expiration_date => "06/2013",
1268
1413
  )
1269
1414
  update_result.success?.should == true
1270
1415
  update_result.payment_method.should == credit_card
@@ -1275,6 +1420,142 @@ describe Braintree::PaymentMethod do
1275
1420
  updated_credit_card.expiration_date.should == "06/2013"
1276
1421
  end
1277
1422
 
1423
+ it "includes risk data when skip_advanced_fraud_checking is false" do
1424
+ with_fraud_protection_enterprise_merchant do
1425
+ customer = Braintree::Customer.create!
1426
+ credit_card = Braintree::CreditCard.create!(
1427
+ :customer_id => customer.id,
1428
+ :cvv => "123",
1429
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1430
+ :expiration_date => "05/2012",
1431
+ )
1432
+ update_result = Braintree::PaymentMethod.update(
1433
+ credit_card.token,
1434
+ :cvv => "456",
1435
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1436
+ :expiration_date => "06/2013",
1437
+ :options => {
1438
+ :verify_card => true,
1439
+ :skip_advanced_fraud_checking => false
1440
+ },
1441
+ )
1442
+
1443
+ expect(update_result).to be_success
1444
+ verification = update_result.payment_method.verification
1445
+ expect(verification.risk_data).not_to be_nil
1446
+ end
1447
+ end
1448
+
1449
+ it "does not include risk data when skip_advanced_fraud_checking is true" do
1450
+ with_fraud_protection_enterprise_merchant do
1451
+ customer = Braintree::Customer.create!
1452
+ credit_card = Braintree::CreditCard.create!(
1453
+ :customer_id => customer.id,
1454
+ :cvv => "123",
1455
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1456
+ :expiration_date => "05/2012",
1457
+ )
1458
+ update_result = Braintree::PaymentMethod.update(
1459
+ credit_card.token,
1460
+ :cvv => "456",
1461
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1462
+ :expiration_date => "06/2013",
1463
+ :options => {
1464
+ :verify_card => true,
1465
+ :skip_advanced_fraud_checking => true
1466
+ },
1467
+ )
1468
+
1469
+ expect(update_result).to be_success
1470
+ verification = update_result.payment_method.verification
1471
+ expect(verification.risk_data).to be_nil
1472
+ end
1473
+ end
1474
+
1475
+ context "verification_currency_iso_code" do
1476
+ it "validates verification_currency_iso_code and updates the credit card " do
1477
+ customer = Braintree::Customer.create!
1478
+ credit_card = Braintree::CreditCard.create!(
1479
+ :cardholder_name => "Original Holder",
1480
+ :customer_id => customer.id,
1481
+ :cvv => "123",
1482
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1483
+ :expiration_date => "05/2012",
1484
+ )
1485
+ update_result = Braintree::PaymentMethod.update(credit_card.token,
1486
+ :cardholder_name => "New Holder",
1487
+ :cvv => "456",
1488
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1489
+ :expiration_date => "06/2013",
1490
+ :options => {:verify_card => true, :verification_currency_iso_code => "USD"},
1491
+ )
1492
+ update_result.success?.should == true
1493
+ update_result.payment_method.verification.currency_iso_code == "USD"
1494
+ end
1495
+
1496
+ it "validates verification_currency_iso_code against the given verification_merchant_account_id and updates the credit card " do
1497
+ customer = Braintree::Customer.create!
1498
+ credit_card = Braintree::CreditCard.create!(
1499
+ :cardholder_name => "Original Holder",
1500
+ :customer_id => customer.id,
1501
+ :cvv => "123",
1502
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1503
+ :expiration_date => "05/2012",
1504
+ )
1505
+ update_result = Braintree::PaymentMethod.update(credit_card.token,
1506
+ :cardholder_name => "New Holder",
1507
+ :cvv => "456",
1508
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1509
+ :expiration_date => "06/2013",
1510
+ :options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"},
1511
+ )
1512
+ update_result.success?.should == true
1513
+ update_result.payment_method.verification.currency_iso_code == "USD"
1514
+ update_result.payment_method.verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
1515
+ end
1516
+
1517
+ it "throws validation error when passing invalid verification_currency_iso_code" do
1518
+ customer = Braintree::Customer.create!
1519
+ credit_card = Braintree::CreditCard.create!(
1520
+ :cardholder_name => "Original Holder",
1521
+ :customer_id => customer.id,
1522
+ :cvv => "123",
1523
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1524
+ :expiration_date => "05/2012",
1525
+ )
1526
+ update_result = Braintree::PaymentMethod.update(credit_card.token,
1527
+ :cardholder_name => "New Holder",
1528
+ :cvv => "456",
1529
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1530
+ :expiration_date => "06/2013",
1531
+ :options => {:verify_card => true, :verification_currency_iso_code => "GBP"},
1532
+ )
1533
+ expect(update_result).to_not be_success
1534
+ update_result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
1535
+ end
1536
+
1537
+ it "throws validation error when passing invalid verification_currency_iso_code of the given verification merchant account id" do
1538
+ customer = Braintree::Customer.create!
1539
+ credit_card = Braintree::CreditCard.create!(
1540
+ :cardholder_name => "Original Holder",
1541
+ :customer_id => customer.id,
1542
+ :cvv => "123",
1543
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1544
+ :expiration_date => "05/2012",
1545
+ )
1546
+ update_result = Braintree::PaymentMethod.update(credit_card.token,
1547
+ :cardholder_name => "New Holder",
1548
+ :cvv => "456",
1549
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
1550
+ :expiration_date => "06/2013",
1551
+ :options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"},
1552
+ )
1553
+ expect(update_result).to_not be_success
1554
+ update_result.errors.for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code.should == Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
1555
+ end
1556
+ end
1557
+
1558
+
1278
1559
  context "billing address" do
1279
1560
  it "creates a new billing address by default" do
1280
1561
  customer = Braintree::Customer.create!
@@ -1284,12 +1565,12 @@ describe Braintree::PaymentMethod do
1284
1565
  :expiration_date => "05/2012",
1285
1566
  :billing_address => {
1286
1567
  :street_address => "123 Nigeria Ave"
1287
- }
1568
+ },
1288
1569
  )
1289
1570
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1290
1571
  :billing_address => {
1291
1572
  :region => "IL"
1292
- }
1573
+ },
1293
1574
  )
1294
1575
  update_result.success?.should == true
1295
1576
  updated_credit_card = update_result.payment_method
@@ -1306,13 +1587,13 @@ describe Braintree::PaymentMethod do
1306
1587
  :expiration_date => "05/2012",
1307
1588
  :billing_address => {
1308
1589
  :street_address => "123 Nigeria Ave"
1309
- }
1590
+ },
1310
1591
  )
1311
1592
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1312
1593
  :billing_address => {
1313
1594
  :region => "IL",
1314
1595
  :options => {:update_existing => true}
1315
- }
1596
+ },
1316
1597
  )
1317
1598
  update_result.success?.should == true
1318
1599
  updated_credit_card = update_result.payment_method
@@ -1329,7 +1610,7 @@ describe Braintree::PaymentMethod do
1329
1610
  :expiration_date => "05/2012",
1330
1611
  :billing_address => {
1331
1612
  :street_address => "123 Nigeria Ave"
1332
- }
1613
+ },
1333
1614
  )
1334
1615
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1335
1616
  :billing_address => {
@@ -1338,7 +1619,7 @@ describe Braintree::PaymentMethod do
1338
1619
  :country_code_alpha3 => "ASM",
1339
1620
  :country_code_numeric => "016",
1340
1621
  :options => {:update_existing => true}
1341
- }
1622
+ },
1342
1623
  )
1343
1624
  update_result.success?.should == true
1344
1625
  updated_credit_card = update_result.payment_method
@@ -1354,12 +1635,12 @@ describe Braintree::PaymentMethod do
1354
1635
  credit_card = Braintree::CreditCard.create!(
1355
1636
  :customer_id => customer.id,
1356
1637
  :number => Braintree::Test::CreditCardNumbers::Visa,
1357
- :expiration_date => "05/2012"
1638
+ :expiration_date => "05/2012",
1358
1639
  )
1359
1640
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1360
1641
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
1361
1642
  :expiration_month => "07",
1362
- :expiration_year => "2011"
1643
+ :expiration_year => "2011",
1363
1644
  )
1364
1645
  update_result.success?.should == true
1365
1646
  update_result.payment_method.should == credit_card
@@ -1375,14 +1656,14 @@ describe Braintree::PaymentMethod do
1375
1656
  :customer_id => customer.id,
1376
1657
  :cvv => "123",
1377
1658
  :number => Braintree::Test::CreditCardNumbers::Visa,
1378
- :expiration_date => "05/2012"
1659
+ :expiration_date => "05/2012",
1379
1660
  )
1380
1661
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1381
1662
  :cardholder_name => "New Holder",
1382
1663
  :cvv => "456",
1383
1664
  :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
1384
1665
  :expiration_date => "06/2013",
1385
- :options => {:verify_card => true}
1666
+ :options => {:verify_card => true},
1386
1667
  )
1387
1668
  update_result.success?.should == false
1388
1669
  update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
@@ -1396,11 +1677,11 @@ describe Braintree::PaymentMethod do
1396
1677
  :customer_id => customer.id,
1397
1678
  :cvv => "123",
1398
1679
  :number => Braintree::Test::CreditCardNumbers::Visa,
1399
- :expiration_date => "05/2020"
1680
+ :expiration_date => "05/2020",
1400
1681
  )
1401
1682
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1402
1683
  :payment_method_nonce => Braintree::Test::Nonce::ProcessorDeclinedMasterCard,
1403
- :options => {:verify_card => true, :verification_amount => "2.34"}
1684
+ :options => {:verify_card => true, :verification_amount => "2.34"},
1404
1685
  )
1405
1686
  update_result.success?.should == false
1406
1687
  update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
@@ -1426,7 +1707,7 @@ describe Braintree::PaymentMethod do
1426
1707
  :region => "Old State",
1427
1708
  :postal_code => "12345",
1428
1709
  :country_name => "Canada"
1429
- }
1710
+ },
1430
1711
  )
1431
1712
  result = Braintree::PaymentMethod.update(credit_card.token,
1432
1713
  :options => {:verify_card => false},
@@ -1440,7 +1721,7 @@ describe Braintree::PaymentMethod do
1440
1721
  :region => "New State",
1441
1722
  :postal_code => "56789",
1442
1723
  :country_name => "United States of America"
1443
- }
1724
+ },
1444
1725
  )
1445
1726
  result.success?.should == true
1446
1727
  address = result.payment_method.billing_address
@@ -1461,12 +1742,12 @@ describe Braintree::PaymentMethod do
1461
1742
  :cardholder_name => "Original Holder",
1462
1743
  :customer_id => customer.id,
1463
1744
  :number => Braintree::Test::CreditCardNumbers::Visa,
1464
- :expiration_date => "05/2012"
1745
+ :expiration_date => "05/2012",
1465
1746
  )
1466
1747
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1467
1748
  :cardholder_name => "New Holder",
1468
1749
  :number => "invalid",
1469
- :expiration_date => "05/2014"
1750
+ :expiration_date => "05/2014",
1470
1751
  )
1471
1752
  update_result.success?.should == false
1472
1753
  update_result.errors.for(:credit_card).on(:number)[0].message.should == "Credit card number must be 12-19 digits."
@@ -1477,12 +1758,12 @@ describe Braintree::PaymentMethod do
1477
1758
  card1 = Braintree::CreditCard.create(
1478
1759
  :customer_id => customer.id,
1479
1760
  :number => Braintree::Test::CreditCardNumbers::Visa,
1480
- :expiration_date => "05/2009"
1761
+ :expiration_date => "05/2009",
1481
1762
  ).credit_card
1482
1763
  card2 = Braintree::CreditCard.create(
1483
1764
  :customer_id => customer.id,
1484
1765
  :number => Braintree::Test::CreditCardNumbers::Visa,
1485
- :expiration_date => "05/2009"
1766
+ :expiration_date => "05/2009",
1486
1767
  ).credit_card
1487
1768
 
1488
1769
  card1.should be_default
@@ -1501,17 +1782,17 @@ describe Braintree::PaymentMethod do
1501
1782
  original_token = random_payment_method_token
1502
1783
  nonce = nonce_for_paypal_account(
1503
1784
  :consent_code => "consent-code",
1504
- :token => original_token
1785
+ :token => original_token,
1505
1786
  )
1506
1787
  original_result = Braintree::PaymentMethod.create(
1507
1788
  :payment_method_nonce => nonce,
1508
- :customer_id => customer.id
1789
+ :customer_id => customer.id,
1509
1790
  )
1510
1791
 
1511
1792
  updated_token = make_token
1512
1793
  updated_result = Braintree::PaymentMethod.update(
1513
1794
  original_token,
1514
- :token => updated_token
1795
+ :token => updated_token,
1515
1796
  )
1516
1797
 
1517
1798
  updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
@@ -1528,19 +1809,19 @@ describe Braintree::PaymentMethod do
1528
1809
  :customer_id => customer.id,
1529
1810
  :number => Braintree::Test::CreditCardNumbers::Visa,
1530
1811
  :expiration_date => "05/2009",
1531
- :options => {:make_default => true}
1812
+ :options => {:make_default => true},
1532
1813
  )
1533
1814
  result.should be_success
1534
1815
 
1535
1816
  nonce = nonce_for_paypal_account(:consent_code => "consent-code")
1536
1817
  original_token = Braintree::PaymentMethod.create(
1537
1818
  :payment_method_nonce => nonce,
1538
- :customer_id => customer.id
1819
+ :customer_id => customer.id,
1539
1820
  ).payment_method.token
1540
1821
 
1541
1822
  updated_result = Braintree::PaymentMethod.update(
1542
1823
  original_token,
1543
- :options => {:make_default => true}
1824
+ :options => {:make_default => true},
1544
1825
  )
1545
1826
 
1546
1827
  updated_paypal_account = Braintree::PayPalAccount.find(original_token)
@@ -1554,25 +1835,25 @@ describe Braintree::PaymentMethod do
1554
1835
 
1555
1836
  first_nonce = nonce_for_paypal_account(
1556
1837
  :consent_code => "consent-code",
1557
- :token => first_token
1838
+ :token => first_token,
1558
1839
  )
1559
1840
  first_result = Braintree::PaymentMethod.create(
1560
1841
  :payment_method_nonce => first_nonce,
1561
- :customer_id => customer.id
1842
+ :customer_id => customer.id,
1562
1843
  )
1563
1844
 
1564
1845
  second_nonce = nonce_for_paypal_account(
1565
1846
  :consent_code => "consent-code",
1566
- :token => second_token
1847
+ :token => second_token,
1567
1848
  )
1568
1849
  second_result = Braintree::PaymentMethod.create(
1569
1850
  :payment_method_nonce => second_nonce,
1570
- :customer_id => customer.id
1851
+ :customer_id => customer.id,
1571
1852
  )
1572
1853
 
1573
1854
  updated_result = Braintree::PaymentMethod.update(
1574
1855
  first_token,
1575
- :token => second_token
1856
+ :token => second_token,
1576
1857
  )
1577
1858
 
1578
1859
  updated_result.should_not be_success
@@ -1589,13 +1870,13 @@ describe Braintree::PaymentMethod do
1589
1870
  :customer_id => customer.id,
1590
1871
  :cvv => "123",
1591
1872
  :number => Braintree::Test::CreditCardNumbers::Visa,
1592
- :expiration_date => "05/2012"
1873
+ :expiration_date => "05/2012",
1593
1874
  )
1594
1875
  payment_method = Braintree::PaymentMethod.update!(credit_card.token,
1595
1876
  :cardholder_name => "New Holder",
1596
1877
  :cvv => "456",
1597
1878
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
1598
- :expiration_date => "06/2013"
1879
+ :expiration_date => "06/2013",
1599
1880
  )
1600
1881
  payment_method.should == credit_card
1601
1882
  payment_method.cardholder_name.should == "New Holder"
@@ -1612,7 +1893,7 @@ describe Braintree::PaymentMethod do
1612
1893
  :public_key => "oauth_app_partner_user_public_key",
1613
1894
  :private_key => "oauth_app_partner_user_private_key",
1614
1895
  :environment => Braintree::Configuration.environment,
1615
- :logger => Logger.new("/dev/null")
1896
+ :logger => Logger.new("/dev/null"),
1616
1897
  )
1617
1898
  customer = @partner_merchant_gateway.customer.create(
1618
1899
  :first_name => "Joe",
@@ -1621,19 +1902,19 @@ describe Braintree::PaymentMethod do
1621
1902
  :email => "joe@example.com",
1622
1903
  :phone => "312.555.1234",
1623
1904
  :fax => "614.555.5678",
1624
- :website => "www.example.com"
1905
+ :website => "www.example.com",
1625
1906
  ).customer
1626
1907
  @credit_card = @partner_merchant_gateway.credit_card.create(
1627
1908
  :customer_id => customer.id,
1628
1909
  :cardholder_name => "Adam Davis",
1629
1910
  :number => Braintree::Test::CreditCardNumbers::Visa,
1630
- :expiration_date => "05/2009"
1911
+ :expiration_date => "05/2009",
1631
1912
  ).credit_card
1632
1913
 
1633
1914
  @oauth_gateway = Braintree::Gateway.new(
1634
1915
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
1635
1916
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
1636
- :logger => Logger.new("/dev/null")
1917
+ :logger => Logger.new("/dev/null"),
1637
1918
  )
1638
1919
  access_token = Braintree::OAuthTestHelper.create_token(@oauth_gateway, {
1639
1920
  :merchant_public_id => "integration_merchant_id",
@@ -1642,7 +1923,7 @@ describe Braintree::PaymentMethod do
1642
1923
 
1643
1924
  @granting_gateway = Braintree::Gateway.new(
1644
1925
  :access_token => access_token,
1645
- :logger => Logger.new("/dev/null")
1926
+ :logger => Logger.new("/dev/null"),
1646
1927
  )
1647
1928
  end
1648
1929
 
@@ -1658,13 +1939,13 @@ describe Braintree::PaymentMethod do
1658
1939
 
1659
1940
  result = Braintree::Transaction.sale(
1660
1941
  :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1661
- :amount => Braintree::Test::TransactionAmounts::Authorize
1942
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1662
1943
  )
1663
1944
  result.should be_success
1664
1945
 
1665
1946
  result2 = Braintree::Transaction.sale(
1666
1947
  :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1667
- :amount => Braintree::Test::TransactionAmounts::Authorize
1948
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1668
1949
  )
1669
1950
  result2.should_not be_success
1670
1951
  end
@@ -1676,7 +1957,7 @@ describe Braintree::PaymentMethod do
1676
1957
 
1677
1958
  result = Braintree::PaymentMethod.create(
1678
1959
  :customer_id => customer_result.customer.id,
1679
- :payment_method_nonce => grant_result.payment_method_nonce.nonce
1960
+ :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1680
1961
  )
1681
1962
  result.should_not be_success
1682
1963
  end
@@ -1688,7 +1969,7 @@ describe Braintree::PaymentMethod do
1688
1969
 
1689
1970
  result = Braintree::PaymentMethod.create(
1690
1971
  :customer_id => customer_result.customer.id,
1691
- :payment_method_nonce => grant_result.payment_method_nonce.nonce
1972
+ :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1692
1973
  )
1693
1974
  result.should be_success
1694
1975
  end
@@ -1723,7 +2004,7 @@ describe Braintree::PaymentMethod do
1723
2004
 
1724
2005
  result = Braintree::PaymentMethod.create(
1725
2006
  :customer_id => customer_result.customer.id,
1726
- :payment_method_nonce => grant_result.payment_method_nonce.nonce
2007
+ :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1727
2008
  )
1728
2009
  result.should_not be_success
1729
2010
  end
@@ -1737,7 +2018,7 @@ describe Braintree::PaymentMethod do
1737
2018
 
1738
2019
  result = Braintree::PaymentMethod.create(
1739
2020
  :customer_id => customer_result.customer.id,
1740
- :payment_method_nonce => grant_result.payment_method_nonce.nonce
2021
+ :payment_method_nonce => grant_result.payment_method_nonce.nonce,
1741
2022
  )
1742
2023
  result.should_not be_success
1743
2024
  end