braintree 4.17.0 → 4.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/advanced_search.rb +1 -2
  3. data/lib/braintree/configuration.rb +1 -1
  4. data/lib/braintree/disbursement.rb +1 -1
  5. data/lib/braintree/dispute.rb +1 -0
  6. data/lib/braintree/error_codes.rb +4 -0
  7. data/lib/braintree/http.rb +2 -4
  8. data/lib/braintree/transaction/package_details.rb +16 -0
  9. data/lib/braintree/transaction.rb +10 -0
  10. data/lib/braintree/transaction_gateway.rb +21 -3
  11. data/lib/braintree/transaction_line_item.rb +11 -8
  12. data/lib/braintree/util.rb +1 -1
  13. data/lib/braintree/version.rb +1 -1
  14. data/lib/braintree/webhook_notification.rb +4 -3
  15. data/lib/braintree/webhook_testing_gateway.rb +78 -6
  16. data/lib/braintree/xml/parser.rb +2 -2
  17. data/lib/braintree.rb +1 -0
  18. data/spec/integration/braintree/address_spec.rb +3 -3
  19. data/spec/integration/braintree/advanced_search_spec.rb +3 -3
  20. data/spec/integration/braintree/client_api/client_token_spec.rb +0 -2
  21. data/spec/integration/braintree/client_api/spec_helper.rb +1 -1
  22. data/spec/integration/braintree/credit_card_spec.rb +11 -15
  23. data/spec/integration/braintree/credit_card_verification_spec.rb +2 -2
  24. data/spec/integration/braintree/customer_spec.rb +12 -12
  25. data/spec/integration/braintree/dispute_search_spec.rb +0 -1
  26. data/spec/integration/braintree/dispute_spec.rb +1 -1
  27. data/spec/integration/braintree/document_upload_spec.rb +1 -1
  28. data/spec/integration/braintree/http_spec.rb +0 -2
  29. data/spec/integration/braintree/oauth_spec.rb +1 -1
  30. data/spec/integration/braintree/package_tracking_spec.rb +111 -0
  31. data/spec/integration/braintree/payment_method_nonce_spec.rb +2 -2
  32. data/spec/integration/braintree/payment_method_spec.rb +12 -14
  33. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +3 -3
  34. data/spec/integration/braintree/paypal_account_spec.rb +6 -6
  35. data/spec/integration/braintree/plan_spec.rb +0 -1
  36. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +0 -2
  37. data/spec/integration/braintree/subscription_spec.rb +5 -6
  38. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -0
  39. data/spec/integration/braintree/transaction_search_spec.rb +3 -7
  40. data/spec/integration/braintree/transaction_spec.rb +117 -49
  41. data/spec/unit/braintree/client_token_spec.rb +1 -1
  42. data/spec/unit/braintree/digest_spec.rb +0 -1
  43. data/spec/unit/braintree/error_result_spec.rb +1 -1
  44. data/spec/unit/braintree/package_tracking_spec.rb +74 -0
  45. data/spec/unit/braintree/paypal_account_spec.rb +1 -1
  46. data/spec/unit/braintree/transaction_gateway_spec.rb +3 -3
  47. data/spec/unit/braintree/transaction_spec.rb +2 -2
  48. data/spec/unit/braintree/webhook_notification_spec.rb +16 -0
  49. metadata +5 -2
@@ -924,11 +924,11 @@ describe Braintree::Customer do
924
924
  },
925
925
  ).credit_card
926
926
 
927
- subscription = Braintree::Subscription.create(
927
+ Braintree::Subscription.create(
928
928
  :payment_method_token => credit_card.token,
929
929
  :plan_id => "integration_trialless_plan",
930
930
  :price => "1.00",
931
- ).subscription
931
+ )
932
932
 
933
933
  found_customer = Braintree::Customer.find(customer.id, {
934
934
  :association_filter_id => "customernoassociations"
@@ -958,11 +958,11 @@ describe Braintree::Customer do
958
958
  },
959
959
  ).credit_card
960
960
 
961
- subscription = Braintree::Subscription.create(
961
+ Braintree::Subscription.create(
962
962
  :payment_method_token => credit_card.token,
963
963
  :plan_id => "integration_trialless_plan",
964
964
  :price => "1.00",
965
- ).subscription
965
+ )
966
966
 
967
967
  found_customer = Braintree::Customer.find(customer.id, {
968
968
  :association_filter_id => "customertoplevelassociations"
@@ -1132,7 +1132,7 @@ describe Braintree::Customer do
1132
1132
  :number => 4111111111111111,
1133
1133
  :expiration_date => "05/2060",
1134
1134
  :three_d_secure_pass_thru => {
1135
- :eci_flag => "02",
1135
+ :eci_flag => "05",
1136
1136
  :cavv => "some_cavv",
1137
1137
  :xid => "some_xid",
1138
1138
  :three_d_secure_version => "1.0.2",
@@ -1167,7 +1167,7 @@ describe Braintree::Customer do
1167
1167
  :number => 4111111111111111,
1168
1168
  :expiration_date => "05/2060",
1169
1169
  :three_d_secure_pass_thru => {
1170
- :eci_flag => "02",
1170
+ :eci_flag => "05",
1171
1171
  :cavv => "some_cavv",
1172
1172
  :xid => "some_xid",
1173
1173
  :authentication_response => "Y",
@@ -1233,7 +1233,7 @@ describe Braintree::Customer do
1233
1233
 
1234
1234
  token1 = random_payment_method_token
1235
1235
 
1236
- payment_method1 = Braintree::PaymentMethod.create(
1236
+ Braintree::PaymentMethod.create(
1237
1237
  :customer_id => customer.id,
1238
1238
  :payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
1239
1239
  :token => token1,
@@ -1244,7 +1244,7 @@ describe Braintree::Customer do
1244
1244
 
1245
1245
  token2 = random_payment_method_token
1246
1246
 
1247
- payment_method2 = Braintree::PaymentMethod.create(
1247
+ Braintree::PaymentMethod.create(
1248
1248
  :customer_id => customer.id,
1249
1249
  :payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
1250
1250
  :token => token2,
@@ -1266,7 +1266,7 @@ describe Braintree::Customer do
1266
1266
 
1267
1267
  token1 = random_payment_method_token
1268
1268
 
1269
- payment_method1 = Braintree::PaymentMethod.create(
1269
+ Braintree::PaymentMethod.create(
1270
1270
  :customer_id => customer.id,
1271
1271
  :payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
1272
1272
  :token => token1,
@@ -1277,7 +1277,7 @@ describe Braintree::Customer do
1277
1277
 
1278
1278
  token2 = random_payment_method_token
1279
1279
 
1280
- payment_method2 = Braintree::PaymentMethod.create(
1280
+ Braintree::PaymentMethod.create(
1281
1281
  :customer_id => customer.id,
1282
1282
  :payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
1283
1283
  :token => token2,
@@ -1451,7 +1451,7 @@ describe Braintree::Customer do
1451
1451
  :payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
1452
1452
  :credit_card => {
1453
1453
  :three_d_secure_pass_thru => {
1454
- :eci_flag => "02",
1454
+ :eci_flag => "05",
1455
1455
  :cavv => "some_cavv",
1456
1456
  :xid => "some_xid",
1457
1457
  :three_d_secure_version => "xx",
@@ -1475,7 +1475,7 @@ describe Braintree::Customer do
1475
1475
  :payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
1476
1476
  :credit_card => {
1477
1477
  :three_d_secure_pass_thru => {
1478
- :eci_flag => "02",
1478
+ :eci_flag => "05",
1479
1479
  :cavv => "some_cavv",
1480
1480
  :xid => "some_xid",
1481
1481
  :three_d_secure_version => "2.2.1",
@@ -74,7 +74,6 @@ describe Braintree::Dispute, "search" do
74
74
  end
75
75
 
76
76
  expect(collection.disputes.count).to be >= 2
77
- dispute = collection.disputes.first
78
77
  end
79
78
 
80
79
  it "correctly returns disputes by chargeback protection level flag" do
@@ -6,7 +6,7 @@ describe Braintree::Dispute do
6
6
  let(:document_upload) do
7
7
  file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
8
8
  response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
9
- document_upload = response.document_upload
9
+ response.document_upload
10
10
  end
11
11
 
12
12
  let(:transaction) do
@@ -67,7 +67,7 @@ describe Braintree::DocumentUploadGateway do
67
67
 
68
68
  it "returns invalid keys error if signature is invalid" do
69
69
  expect do
70
- response = Braintree::DocumentUpload.create({:invalid_key => "do not add", :kind => Braintree::DocumentUpload::Kind::EvidenceDocument})
70
+ Braintree::DocumentUpload.create({:invalid_key => "do not add", :kind => Braintree::DocumentUpload::Kind::EvidenceDocument})
71
71
  end.to raise_error(ArgumentError, "invalid keys: invalid_key")
72
72
  end
73
73
  end
@@ -255,7 +255,6 @@ describe Braintree::Http do
255
255
  old_logger = Braintree::Configuration.logger
256
256
  output = StringIO.new
257
257
  Braintree::Configuration.logger = Logger.new(output)
258
- utc_or_gmt = Time.now.utc.strftime("%Z")
259
258
  context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
260
259
  context.error = 19
261
260
  expect(Braintree::Configuration.instantiate.http._verify_ssl_certificate(false, context)).to eq(false)
@@ -270,7 +269,6 @@ describe Braintree::Http do
270
269
  old_logger = Braintree::Configuration.logger
271
270
  output = StringIO.new
272
271
  Braintree::Configuration.logger = Logger.new(output)
273
- utc_or_gmt = Time.now.utc.strftime("%Z")
274
272
  context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
275
273
  expect do
276
274
  Braintree::Configuration.instantiate.http._verify_ssl_certificate(true, context)
@@ -36,7 +36,7 @@ describe "OAuth" do
36
36
  )
37
37
 
38
38
  expect(result).not_to be_success
39
- errors = expect(result.errors.for(:credentials).on(:code)[0].code).to eq(Braintree::ErrorCodes::OAuth::InvalidGrant)
39
+ expect(result.errors.for(:credentials).on(:code)[0].code).to eq(Braintree::ErrorCodes::OAuth::InvalidGrant)
40
40
  expect(result.message).to match(/Invalid grant: code not found/)
41
41
  end
42
42
 
@@ -0,0 +1,111 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::Transaction do
4
+ describe "self.package_tracking" do
5
+ it "returns validation error message from gateway api" do
6
+ # Create Transaction
7
+ result = Braintree::Transaction.sale(
8
+ :amount => "100",
9
+ :options => {
10
+ :submit_for_settlement => true
11
+ },
12
+ :paypal_account => {
13
+ :payer_id => "fake-payer-id",
14
+ :payment_id => "fake-payment-id",
15
+ },
16
+ )
17
+
18
+ expect(result.success?).to eq(true)
19
+
20
+ # Carrier name is required
21
+ invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {tracking_number: "tracking_number_1"})
22
+ expect(invalidResult.message).to eq("Carrier name is required.")
23
+
24
+ # Tracking number is required
25
+ invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {carrier: "UPS"})
26
+ expect(invalidResult.message).to eq("Tracking number is required.")
27
+ end
28
+
29
+ it "successfully calls gateway API and adds package tracking information" do
30
+
31
+ # Create Transaction
32
+ result = Braintree::Transaction.sale(
33
+ :amount => "100",
34
+ :options => {
35
+ :submit_for_settlement => true
36
+ },
37
+ :paypal_account => {
38
+ :payer_id => "fake-payer-id",
39
+ :payment_id => "fake-payment-id",
40
+ },
41
+ )
42
+
43
+ expect(result.success?).to eq(true)
44
+
45
+ # Create First Package with 2 products
46
+ firstPackageResult = Braintree::Transaction.package_tracking(
47
+ result.transaction.id,
48
+ {
49
+ carrier: "UPS",
50
+ notify_payer: true,
51
+ tracking_number: "tracking_number_1",
52
+ line_items: [
53
+ {
54
+ product_code: "ABC 01",
55
+ name: "Best Product Ever",
56
+ quantity: "1",
57
+ description: "Best Description Ever",
58
+ upc_code: "51234567890",
59
+ upc_type: "UPC-A",
60
+ image_url: "https://example.com/image.png",
61
+ },
62
+ {
63
+ product_code: "ABC 02",
64
+ name: "Best Product Ever",
65
+ quantity: "1",
66
+ description: "Best Description Ever",
67
+ upc_code: "51234567891",
68
+ upc_type: "UPC-A",
69
+ image_url: "https://example.com/image.png",
70
+ },
71
+ ],
72
+ },
73
+ )
74
+
75
+ # First package is shipped by the merchant
76
+ expect(firstPackageResult.success?).to eq(true)
77
+ expect(firstPackageResult.transaction.packages[0].id).not_to be_nil
78
+ expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS")
79
+ expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1")
80
+
81
+
82
+ # Create second package with 1 product
83
+ secondPackageResult = Braintree::Transaction.package_tracking(
84
+ result.transaction.id,
85
+ {
86
+ carrier: "FEDEX",
87
+ notify_payer: true,
88
+ tracking_number: "tracking_number_2",
89
+ line_items: [
90
+ {
91
+ product_code: "ABC 03",
92
+ name: "Best Product Ever",
93
+ quantity: "1",
94
+ description: "Best Description Ever",
95
+ },
96
+ ]
97
+ },
98
+ )
99
+
100
+ # Second package is shipped by the merchant
101
+ expect(secondPackageResult.success?).to eq(true)
102
+ expect(secondPackageResult.transaction.packages[1].id).not_to be_nil
103
+ expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX")
104
+ expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2")
105
+
106
+ # Find transaction gives both packages
107
+ findTransaction = Braintree::Transaction.find(result.transaction.id)
108
+ expect(findTransaction.packages.length).to eq(2)
109
+ end
110
+ end
111
+ end
@@ -97,7 +97,7 @@ describe Braintree::PaymentMethodNonce do
97
97
  nonce.details.bin.should == "401288"
98
98
  nonce.details.last_two.should == "81"
99
99
  nonce.details.card_type.should == "Visa"
100
- nonce.details.expiration_year.should == "2024"
100
+ nonce.details.expiration_year.should == Date.today().next_year().year.to_s
101
101
  nonce.details.expiration_month.should == "12"
102
102
  end
103
103
 
@@ -107,7 +107,7 @@ describe Braintree::PaymentMethodNonce do
107
107
  nonce.details.bin.should == "401288"
108
108
  nonce.details.last_two.should == "81"
109
109
  nonce.details.card_type.should == "Visa"
110
- nonce.details.expiration_year.should == "2024"
110
+ nonce.details.expiration_year.should == Date.today().next_year().year.to_s
111
111
  nonce.details.expiration_month.should == "12"
112
112
  end
113
113
 
@@ -342,7 +342,7 @@ describe Braintree::PaymentMethod do
342
342
  :customer_id => customer.id,
343
343
  :payment_method_nonce => Braintree::Test::Nonce::Transactable,
344
344
  :three_d_secure_pass_thru => {
345
- :eci_flag => "02",
345
+ :eci_flag => "05",
346
346
  :cavv => "some_cavv",
347
347
  :xid => "some_xid",
348
348
  :three_d_secure_version => "xx",
@@ -365,7 +365,7 @@ describe Braintree::PaymentMethod do
365
365
  :customer_id => customer.id,
366
366
  :payment_method_nonce => Braintree::Test::Nonce::Transactable,
367
367
  :three_d_secure_pass_thru => {
368
- :eci_flag => "02",
368
+ :eci_flag => "05",
369
369
  :cavv => "some_cavv",
370
370
  :xid => "some_xid",
371
371
  :three_d_secure_version => "1.0.2",
@@ -390,15 +390,14 @@ describe Braintree::PaymentMethod do
390
390
  expect(result.success?).to eq(true)
391
391
 
392
392
  three_d_secure_info = result.payment_method.verification.three_d_secure_info
393
- expect(three_d_secure_info.enrolled).to eq("Y")
393
+ expect(three_d_secure_info.status).to eq("authenticate_successful")
394
394
  expect(three_d_secure_info).to be_liability_shifted
395
395
  expect(three_d_secure_info).to be_liability_shift_possible
396
- expect(three_d_secure_info.status).to eq("authenticate_successful")
397
- expect(three_d_secure_info.cavv).to eq("cavv_value")
398
- expect(three_d_secure_info.xid).to eq("xid_value")
399
- expect(three_d_secure_info.eci_flag).to eq("05")
400
- expect(three_d_secure_info.three_d_secure_version).to eq("1.0.2")
401
- expect(three_d_secure_info.ds_transaction_id).to eq(nil)
396
+ expect(three_d_secure_info.enrolled).to be_a(String)
397
+ expect(three_d_secure_info.cavv).to be_a(String)
398
+ expect(three_d_secure_info.xid).to be_a(String)
399
+ expect(three_d_secure_info.eci_flag).to be_a(String)
400
+ expect(three_d_secure_info.three_d_secure_version).to be_a(String)
402
401
  end
403
402
 
404
403
  it "respects fail_on_duplicate_payment_method when included outside of the nonce" do
@@ -1409,7 +1408,6 @@ describe Braintree::PaymentMethod do
1409
1408
 
1410
1409
  it "raises a NotFoundError exception if payment method cannot be found" do
1411
1410
  token = make_token
1412
- customer = Braintree::Customer.create!
1413
1411
 
1414
1412
  expect do
1415
1413
  Braintree::PaymentMethod.delete(token)
@@ -1878,7 +1876,7 @@ describe Braintree::PaymentMethod do
1878
1876
  )
1879
1877
 
1880
1878
  updated_token = make_token
1881
- updated_result = Braintree::PaymentMethod.update(
1879
+ Braintree::PaymentMethod.update(
1882
1880
  original_token,
1883
1881
  :token => updated_token,
1884
1882
  )
@@ -1907,7 +1905,7 @@ describe Braintree::PaymentMethod do
1907
1905
  :customer_id => customer.id,
1908
1906
  ).payment_method.token
1909
1907
 
1910
- updated_result = Braintree::PaymentMethod.update(
1908
+ Braintree::PaymentMethod.update(
1911
1909
  original_token,
1912
1910
  :options => {:make_default => true},
1913
1911
  )
@@ -1925,7 +1923,7 @@ describe Braintree::PaymentMethod do
1925
1923
  :consent_code => "consent-code",
1926
1924
  :token => first_token,
1927
1925
  )
1928
- first_result = Braintree::PaymentMethod.create(
1926
+ Braintree::PaymentMethod.create(
1929
1927
  :payment_method_nonce => first_nonce,
1930
1928
  :customer_id => customer.id,
1931
1929
  )
@@ -1934,7 +1932,7 @@ describe Braintree::PaymentMethod do
1934
1932
  :consent_code => "consent-code",
1935
1933
  :token => second_token,
1936
1934
  )
1937
- second_result = Braintree::PaymentMethod.create(
1935
+ Braintree::PaymentMethod.create(
1938
1936
  :payment_method_nonce => second_nonce,
1939
1937
  :customer_id => customer.id,
1940
1938
  )
@@ -116,7 +116,7 @@ describe Braintree::PaymentMethod do
116
116
 
117
117
  it "returns additional processor response for failed NetworkCheck" do
118
118
  customer = Braintree::Customer.create.customer
119
- invalid_nonce = generate_non_plaid_us_bank_account_nonce(account_number = "1000000005")
119
+ invalid_nonce = generate_non_plaid_us_bank_account_nonce("1000000005")
120
120
  result = Braintree::PaymentMethod.create(
121
121
  :payment_method_nonce => invalid_nonce,
122
122
  :customer_id => customer.id,
@@ -189,7 +189,7 @@ describe Braintree::PaymentMethod do
189
189
  context "unverified token" do
190
190
  let(:payment_method) do
191
191
  customer = Braintree::Customer.create.customer
192
- result = Braintree::PaymentMethod.create(
192
+ Braintree::PaymentMethod.create(
193
193
  :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
194
194
  :customer_id => customer.id,
195
195
  :options => {
@@ -260,7 +260,7 @@ describe Braintree::PaymentMethod do
260
260
  context "unverified token" do
261
261
  let(:payment_method) do
262
262
  customer = Braintree::Customer.create.customer
263
- result = Braintree::PaymentMethod.create(
263
+ Braintree::PaymentMethod.create(
264
264
  :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
265
265
  :customer_id => customer.id,
266
266
  :options => {
@@ -51,7 +51,7 @@ describe Braintree::PayPalAccount do
51
51
 
52
52
  it "does not return a different payment method type" do
53
53
  customer = Braintree::Customer.create!
54
- result = Braintree::CreditCard.create(
54
+ Braintree::CreditCard.create(
55
55
  :customer_id => customer.id,
56
56
  :number => Braintree::Test::CreditCardNumbers::Visa,
57
57
  :expiration_date => "05/2009",
@@ -171,7 +171,7 @@ describe Braintree::PayPalAccount do
171
171
  )
172
172
 
173
173
  updated_token = "UPDATED_TOKEN-" + rand(36**3).to_s(36)
174
- updated_result = Braintree::PayPalAccount.update(
174
+ Braintree::PayPalAccount.update(
175
175
  original_token,
176
176
  :token => updated_token,
177
177
  )
@@ -200,7 +200,7 @@ describe Braintree::PayPalAccount do
200
200
  :customer_id => customer.id,
201
201
  ).payment_method.token
202
202
 
203
- updated_result = Braintree::PayPalAccount.update(
203
+ Braintree::PayPalAccount.update(
204
204
  original_token,
205
205
  :options => {:make_default => true},
206
206
  )
@@ -218,7 +218,7 @@ describe Braintree::PayPalAccount do
218
218
  :consent_code => "consent-code",
219
219
  :token => first_token,
220
220
  )
221
- first_result = Braintree::PaymentMethod.create(
221
+ Braintree::PaymentMethod.create(
222
222
  :payment_method_nonce => first_nonce,
223
223
  :customer_id => customer.id,
224
224
  )
@@ -227,7 +227,7 @@ describe Braintree::PayPalAccount do
227
227
  :consent_code => "consent-code",
228
228
  :token => second_token,
229
229
  )
230
- second_result = Braintree::PaymentMethod.create(
230
+ Braintree::PaymentMethod.create(
231
231
  :payment_method_nonce => second_nonce,
232
232
  :customer_id => customer.id,
233
233
  )
@@ -256,7 +256,7 @@ describe Braintree::PayPalAccount do
256
256
  :customer_id => customer.id,
257
257
  )
258
258
 
259
- result = Braintree::PayPalAccount.delete(token)
259
+ Braintree::PayPalAccount.delete(token)
260
260
 
261
261
  expect do
262
262
  Braintree::PayPalAccount.find(token)
@@ -113,7 +113,6 @@ describe Braintree::Plan do
113
113
  end
114
114
 
115
115
  it "returns the updated plan if valid" do
116
- new_id = rand(36**9).to_s(36)
117
116
  plan = Braintree::Plan.update!(@plan.id,
118
117
  :name => "updated name",
119
118
  :price => 99.88,
@@ -53,8 +53,6 @@ describe Braintree::SepaDirectDebitAccount do
53
53
 
54
54
  context "subscriptions" do
55
55
  it "returns subscriptions associated with a SEPA direct debit account" do
56
- customer = Braintree::Customer.create!
57
-
58
56
  subscription1 = Braintree::Subscription.create(
59
57
  :payment_method_token => token,
60
58
  :plan_id => SpecHelper::TriallessPlan[:id],
@@ -136,7 +136,6 @@ describe Braintree::Subscription do
136
136
  end
137
137
 
138
138
  it "returns an error if the payment_method_nonce hasn't been vaulted" do
139
- customer = Braintree::Customer.create!
140
139
  result = Braintree::Subscription.create(
141
140
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
142
141
  :plan_id => SpecHelper::TriallessPlan[:id],
@@ -937,17 +936,17 @@ describe Braintree::Subscription do
937
936
 
938
937
  it "has validation errors on duplicate id" do
939
938
  duplicate_id = "new_id_#{rand(36**6).to_s(36)}"
940
- duplicate = Braintree::Subscription.create(
939
+ Braintree::Subscription.create(
941
940
  :payment_method_token => @credit_card.token,
942
941
  :plan_id => SpecHelper::TrialPlan[:id],
943
942
  :id => duplicate_id,
944
943
  )
945
- result = Braintree::Subscription.update(
944
+ duplicate = Braintree::Subscription.update(
946
945
  @subscription.id,
947
946
  :id => duplicate_id,
948
947
  )
949
- expect(result.success?).to eq(false)
950
- expect(result.errors.for(:subscription).on(:id)[0].code).to eq(Braintree::ErrorCodes::Subscription::IdIsInUse)
948
+ expect(duplicate.success?).to eq(false)
949
+ expect(duplicate.errors.for(:subscription).on(:id)[0].code).to eq(Braintree::ErrorCodes::Subscription::IdIsInUse)
951
950
  end
952
951
 
953
952
  it "cannot update a canceled subscription" do
@@ -1203,7 +1202,7 @@ describe Braintree::Subscription do
1203
1202
 
1204
1203
  it "returns a validation error if record not found" do
1205
1204
  expect {
1206
- r = Braintree::Subscription.cancel("noSuchSubscription")
1205
+ Braintree::Subscription.cancel("noSuchSubscription")
1207
1206
  }.to raise_error(Braintree::NotFoundError, 'subscription with id "noSuchSubscription" not found')
1208
1207
  end
1209
1208
 
@@ -18,6 +18,9 @@ describe Braintree::TransactionLineItem do
18
18
  :kind => "debit",
19
19
  :unit_amount => "45.1232",
20
20
  :total_amount => "45.15",
21
+ :upc_code => "11223344556677889",
22
+ :upc_type => "UPC-A",
23
+ :image_url => "https://google.com/image.png",
21
24
  },
22
25
  ],
23
26
  )
@@ -32,6 +35,9 @@ describe Braintree::TransactionLineItem do
32
35
  expect(line_item.kind).to eq("debit")
33
36
  expect(line_item.unit_amount).to eq(BigDecimal("45.1232"))
34
37
  expect(line_item.total_amount).to eq(BigDecimal("45.15"))
38
+ expect(line_item.upc_type).to eq("UPC-A")
39
+ expect(line_item.upc_code).to eq("11223344556677889")
40
+ expect(line_item.image_url).to eq("https://google.com/image.png")
35
41
  end
36
42
  end
37
43
  end
@@ -640,7 +640,7 @@ describe Braintree::Transaction, "search" do
640
640
  context "invalid search" do
641
641
  it "raises an exception on invalid transaction type" do
642
642
  expect do
643
- collection = Braintree::Transaction.search do |search|
643
+ Braintree::Transaction.search do |search|
644
644
  search.customer_id.is "9171566"
645
645
  search.type.is "settled"
646
646
  end
@@ -649,7 +649,7 @@ describe Braintree::Transaction, "search" do
649
649
 
650
650
  it "raises an exception on invalid debit network" do
651
651
  expect do
652
- collection = Braintree::Transaction.search do |search|
652
+ Braintree::Transaction.search do |search|
653
653
  search.debit_network.is "invalid_network"
654
654
  end
655
655
  end.to raise_error(ArgumentError)
@@ -849,8 +849,6 @@ describe Braintree::Transaction, "search" do
849
849
 
850
850
  context "ach return response created at" do
851
851
  it "it finds records within date range of the custom field" do
852
- reason_code = "any_reason_code"
853
-
854
852
  date_search = Braintree::Transaction.search do |search|
855
853
  search.ach_return_responses_created_at.between(DateTime.now - 1.0, DateTime.now + 1.0)
856
854
  end
@@ -859,8 +857,6 @@ describe Braintree::Transaction, "search" do
859
857
  end
860
858
 
861
859
  it "it does not find records not within date range of the custom field" do
862
- reason_code = "any_reason_code"
863
-
864
860
  neg_date_search = Braintree::Transaction.search do |search|
865
861
  search.ach_return_responses_created_at.between(DateTime.now + 1.0, DateTime.now - 1.0)
866
862
  end
@@ -1488,7 +1484,7 @@ describe Braintree::Transaction, "search" do
1488
1484
  context "when the search times out" do
1489
1485
  it "raises a UnexpectedError" do
1490
1486
  expect {
1491
- collection = Braintree::Transaction.search do |search|
1487
+ Braintree::Transaction.search do |search|
1492
1488
  search.amount.is(-10)
1493
1489
  end
1494
1490
  }.to raise_error(Braintree::UnexpectedError)