braintree 2.93.0 → 2.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree.rb +2 -0
  3. data/lib/braintree/error_codes.rb +1 -0
  4. data/lib/braintree/payment_method_gateway.rb +32 -43
  5. data/lib/braintree/payment_method_parser.rb +32 -0
  6. data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
  7. data/lib/braintree/util.rb +1 -1
  8. data/lib/braintree/version.rb +1 -1
  9. data/lib/braintree/webhook_notification.rb +3 -0
  10. data/spec/fixtures/files/too_long.pdf +0 -0
  11. data/spec/integration/braintree/add_on_spec.rb +1 -1
  12. data/spec/integration/braintree/credit_card_spec.rb +10 -10
  13. data/spec/integration/braintree/customer_spec.rb +9 -9
  14. data/spec/integration/braintree/discount_spec.rb +1 -1
  15. data/spec/integration/braintree/document_upload_spec.rb +7 -0
  16. data/spec/integration/braintree/ideal_payment_spec.rb +2 -2
  17. data/spec/integration/braintree/payment_method_nonce_spec.rb +19 -0
  18. data/spec/integration/braintree/payment_method_spec.rb +2 -2
  19. data/spec/integration/braintree/paypal_account_spec.rb +2 -2
  20. data/spec/integration/braintree/subscription_spec.rb +39 -39
  21. data/spec/integration/braintree/transaction_line_item_spec.rb +3 -3
  22. data/spec/integration/braintree/transaction_search_spec.rb +2 -2
  23. data/spec/integration/braintree/transaction_spec.rb +60 -60
  24. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +7 -7
  25. data/spec/integration/braintree/transparent_redirect_spec.rb +2 -2
  26. data/spec/integration/braintree/us_bank_account_spec.rb +2 -2
  27. data/spec/spec_helper.rb +4 -4
  28. data/spec/unit/braintree/credit_card_verification_spec.rb +2 -2
  29. data/spec/unit/braintree/modification_spec.rb +1 -1
  30. data/spec/unit/braintree/subscription_spec.rb +2 -2
  31. data/spec/unit/braintree/transaction_spec.rb +2 -2
  32. data/spec/unit/braintree/util_spec.rb +2 -2
  33. data/spec/unit/braintree/webhook_notification_spec.rb +133 -0
  34. data/spec/unit/braintree/xml_spec.rb +3 -3
  35. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe7e71dc2faed60283e8b70c632dcc9f60c5402897caed595cf7689b6d8152c1
4
- data.tar.gz: aa6b2334db4ee60824c5fd84d0a665f4709f328337fae8ee3f081c9237093148
3
+ metadata.gz: dce496fbd494eb6d7c00260e5f7ac5ce0082e588874e5ff85f8b1130009164c6
4
+ data.tar.gz: 827b5db86f4b2144bbbe795f2bbd2abd06b7f4c85d577e99842c544705b234d1
5
5
  SHA512:
6
- metadata.gz: f50449f12b8e0c806a36a7111fd007c4d4bbc877a46dac3e50fe655e3258a6832983911f6354d0d361e59d4d2d9540b134f5f3fd45a0f6f8402b638a29b77229
7
- data.tar.gz: f124d8089b885395f91fe95e88533fbe26e52e008a603cafd5ddb743b2abaee8b3416a6953c8a877a213503d8aeb95ffde7035694f67a8dd700e1af1fc7f06d7
6
+ metadata.gz: 2d879cf0a13d3d799ecf92f8f447e91a75897ecc77a75ee9ed1a39a5d96f81b7e82b4f6edfa57147e689230ea5941ecb5f92e1e4fb3e0f8524cb2d8a66542bf8
7
+ data.tar.gz: e402c7a9f7d351a89ad7c205012b26e66f9ca82ac15c73fc5ff432c2e00296dc78422ef8c2e80ad45d12f2e9901a8f343b9164736cecd3c578546316e0a26e0d
@@ -91,6 +91,7 @@ require "braintree/payment_method"
91
91
  require "braintree/payment_method_gateway"
92
92
  require "braintree/payment_method_nonce"
93
93
  require "braintree/payment_method_nonce_gateway"
94
+ require "braintree/payment_method_parser"
94
95
  require "braintree/paypal_account"
95
96
  require "braintree/paypal_account_gateway"
96
97
  require "braintree/plan"
@@ -103,6 +104,7 @@ require "braintree/three_d_secure_info"
103
104
  require "braintree/settlement_batch_summary"
104
105
  require "braintree/settlement_batch_summary_gateway"
105
106
  require "braintree/resource_collection"
107
+ require "braintree/revoked_payment_method_metadata"
106
108
  require "braintree/paginated_collection"
107
109
  require "braintree/paginated_result"
108
110
  require "braintree/europe_bank_account"
@@ -177,6 +177,7 @@ module Braintree
177
177
  FileIsTooLarge = "84902"
178
178
  FileTypeIsInvalid = "84903"
179
179
  FileIsMalformedOrEncrypted = "84904"
180
+ FileIsTooLong = "84905"
180
181
  end
181
182
 
182
183
  module PayPalAccount
@@ -19,36 +19,11 @@ module Braintree
19
19
 
20
20
  def _do_create(path, params=nil) # :nodoc:
21
21
  response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
22
- if response[:credit_card]
23
- SuccessfulResult.new(:payment_method => CreditCard._new(@gateway, response[:credit_card]))
24
- elsif response[:paypal_account]
25
- SuccessfulResult.new(:payment_method => PayPalAccount._new(@gateway, response[:paypal_account]))
26
- elsif response[:coinbase_account]
27
- SuccessfulResult.new(:payment_method => CoinbaseAccount._new(@gateway, response[:coinbase_account]))
28
- elsif response[:us_bank_account]
29
- SuccessfulResult.new(:payment_method => UsBankAccount._new(@gateway, response[:us_bank_account]))
30
- elsif response[:apple_pay_card]
31
- SuccessfulResult.new(:payment_method => ApplePayCard._new(@gateway, response[:apple_pay_card]))
32
- elsif response[:android_pay_card]
33
- SuccessfulResult.new(:payment_method => AndroidPayCard._new(@gateway, response[:android_pay_card]))
34
- elsif response[:amex_express_checkout_card]
35
- SuccessfulResult.new(:payment_method => AmexExpressCheckoutCard._new(@gateway, response[:amex_express_checkout_card]))
36
- elsif response[:venmo_account]
37
- SuccessfulResult.new(:payment_method => VenmoAccount._new(@gateway, response[:venmo_account]))
38
- elsif response[:visa_checkout_card]
39
- SuccessfulResult.new(:payment_method => VisaCheckoutCard._new(@gateway, response[:visa_checkout_card]))
40
- elsif response[:masterpass_card]
41
- SuccessfulResult.new(:payment_method => MasterpassCard._new(@gateway, response[:masterpass_card]))
42
- elsif response[:samsung_pay_card]
43
- SuccessfulResult.new(:payment_method => SamsungPayCard._new(@gateway, response[:samsung_pay_card]))
44
- elsif response[:payment_method_nonce]
45
- SuccessfulResult.new(:payment_method_nonce => PaymentMethodNonce._new(@gateway, response[:payment_method_nonce]))
46
- elsif response[:success]
47
- SuccessfulResult.new
48
- elsif response[:api_error_response]
22
+
23
+ if response[:api_error_response]
49
24
  ErrorResult.new(@gateway, response[:api_error_response])
50
25
  elsif response
51
- SuccessfulResult.new(:payment_method => UnknownPaymentMethod._new(@gateway, response))
26
+ SuccessfulResult.new(:payment_method => PaymentMethodParser.parse_payment_method(@gateway, response))
52
27
  else
53
28
  raise UnexpectedError, "expected :payment_method or :api_error_response"
54
29
  end
@@ -96,6 +71,17 @@ module Braintree
96
71
  return_object_or_raise(:payment_method) { update(*args) }
97
72
  end
98
73
 
74
+ def _do_update(http_verb, path, params) # :nodoc:
75
+ response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params)
76
+ if response[:api_error_response]
77
+ ErrorResult.new(@gateway, response[:api_error_response])
78
+ elsif response
79
+ SuccessfulResult.new(:payment_method => PaymentMethodParser.parse_payment_method(@gateway, response))
80
+ else
81
+ raise UnexpectedError, "expected :payment_method or :api_error_response"
82
+ end
83
+ end
84
+
99
85
  def grant(token, options = {})
100
86
  raise ArgumentError if token.nil? || token.to_s.strip == ""
101
87
  if options.class == Hash
@@ -106,7 +92,7 @@ module Braintree
106
92
  raise ArgumentError
107
93
  end
108
94
 
109
- _do_create(
95
+ _do_grant(
110
96
  "/payment_methods/grant",
111
97
  :payment_method => {
112
98
  :shared_payment_method_token => token,
@@ -116,10 +102,21 @@ module Braintree
116
102
  raise NotFoundError, "payment method with token #{token.inspect} not found"
117
103
  end
118
104
 
105
+ def _do_grant(path, params=nil)
106
+ response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
107
+ if response[:payment_method_nonce]
108
+ SuccessfulResult.new(:payment_method_nonce => PaymentMethodNonce._new(@gateway, response[:payment_method_nonce]))
109
+ elsif response[:api_error_response]
110
+ ErrorResult.new(@gateway, response[:api_error_response])
111
+ else
112
+ raise UnexpectedError, "expected :payment_method_nonce or :api_error_response"
113
+ end
114
+ end
115
+
119
116
  def revoke(token)
120
117
  raise ArgumentError if token.nil? || token.to_s.strip == ""
121
118
 
122
- _do_create(
119
+ _do_revoke(
123
120
  "/payment_methods/revoke",
124
121
  :payment_method => {
125
122
  :shared_payment_method_token => token
@@ -129,22 +126,14 @@ module Braintree
129
126
  raise NotFoundError, "payment method with token #{token.inspect} not found"
130
127
  end
131
128
 
132
- def _do_update(http_verb, path, params) # :nodoc:
133
- response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params)
134
- if response[:credit_card]
135
- SuccessfulResult.new(:payment_method => CreditCard._new(@gateway, response[:credit_card]))
136
- elsif response[:paypal_account]
137
- SuccessfulResult.new(:payment_method => PayPalAccount._new(@gateway, response[:paypal_account]))
138
- elsif response[:coinbase_account]
139
- SuccessfulResult.new(:payment_method => CoinbaseAccount._new(@gateway, response[:coinbase_account]))
129
+ def _do_revoke(path, params=nil)
130
+ response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
131
+ if response[:success]
132
+ SuccessfulResult.new
140
133
  elsif response[:api_error_response]
141
134
  ErrorResult.new(@gateway, response[:api_error_response])
142
- elsif response[:us_bank_account]
143
- SuccessfulResult.new(:payment_method => UsBankAccount._new(@gateway, response[:us_bank_account]))
144
- elsif response
145
- SuccessfulResult.new(:payment_method => UnknownPaymentMethod._new(@gateway, response))
146
135
  else
147
- raise UnexpectedError, "expected :payment_method or :api_error_response"
136
+ raise UnexpectedError, "expected :success or :api_error_response"
148
137
  end
149
138
  end
150
139
 
@@ -0,0 +1,32 @@
1
+ module Braintree
2
+ module PaymentMethodParser
3
+
4
+ def self.parse_payment_method(gateway, attributes)
5
+ if attributes[:credit_card]
6
+ CreditCard._new(gateway, attributes[:credit_card])
7
+ elsif attributes[:paypal_account]
8
+ PayPalAccount._new(gateway, attributes[:paypal_account])
9
+ elsif attributes[:coinbase_account]
10
+ CoinbaseAccount._new(gateway, attributes[:coinbase_account])
11
+ elsif attributes[:us_bank_account]
12
+ UsBankAccount._new(gateway, attributes[:us_bank_account])
13
+ elsif attributes[:apple_pay_card]
14
+ ApplePayCard._new(gateway, attributes[:apple_pay_card])
15
+ elsif attributes[:android_pay_card]
16
+ AndroidPayCard._new(gateway, attributes[:android_pay_card])
17
+ elsif attributes[:amex_express_checkout_card]
18
+ AmexExpressCheckoutCard._new(gateway, attributes[:amex_express_checkout_card])
19
+ elsif attributes[:venmo_account]
20
+ VenmoAccount._new(gateway, attributes[:venmo_account])
21
+ elsif attributes[:visa_checkout_card]
22
+ VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
23
+ elsif attributes[:masterpass_card]
24
+ MasterpassCard._new(gateway, attributes[:masterpass_card])
25
+ elsif attributes[:samsung_pay_card]
26
+ SamsungPayCard._new(gateway, attributes[:samsung_pay_card])
27
+ else
28
+ UnknownPaymentMethod._new(gateway, attributes)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ module Braintree
2
+ class RevokedPaymentMethodMetadata
3
+ include BaseModule
4
+
5
+ attr_reader :customer_id
6
+ attr_reader :token
7
+ attr_reader :revoked_payment_method
8
+
9
+ def initialize(gateway, attributes)
10
+ @revoked_payment_method = PaymentMethodParser.parse_payment_method(gateway, attributes)
11
+ @customer_id = @revoked_payment_method.customer_id
12
+ @token = @revoked_payment_method.token
13
+ end
14
+
15
+ class << self
16
+ protected :new
17
+ def _new(*args) # :nodoc:
18
+ self.new *args
19
+ end
20
+ end
21
+ end
22
+ end
@@ -102,7 +102,7 @@ module Braintree
102
102
  when BigDecimal, NilClass
103
103
  decimal
104
104
  when String
105
- BigDecimal.new(decimal)
105
+ BigDecimal(decimal)
106
106
  else
107
107
  raise ArgumentError, "Argument must be a String or BigDecimal"
108
108
  end
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 93
4
+ Minor = 94
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -41,6 +41,7 @@ module Braintree
41
41
  ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
42
42
 
43
43
  GrantedPaymentInstrumentUpdate = "granted_payment_instrument_update"
44
+ GrantedPaymentInstrumentRevoked = "granted_payment_instrument_revoked"
44
45
 
45
46
  LocalPaymentCompleted = "local_payment_completed"
46
47
  end
@@ -51,6 +52,7 @@ module Braintree
51
52
  attr_reader :disbursement
52
53
  attr_reader :dispute
53
54
  attr_reader :granted_payment_instrument_update
55
+ attr_reader :revoked_payment_method_metadata
54
56
  attr_reader :ideal_payment
55
57
  attr_reader :kind
56
58
  attr_reader :local_payment_completed
@@ -85,6 +87,7 @@ module Braintree
85
87
  @connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned._new(@subject[:connected_merchant_status_transitioned]) if @subject.has_key?(:connected_merchant_status_transitioned)
86
88
  @connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged._new(@subject[:connected_merchant_paypal_status_changed]) if @subject.has_key?(:connected_merchant_paypal_status_changed)
87
89
  @granted_payment_instrument_update = GrantedPaymentInstrumentUpdate._new(@subject[:granted_payment_instrument_update]) if @subject.has_key?(:granted_payment_instrument_update)
90
+ @revoked_payment_method_metadata = RevokedPaymentMethodMetadata._new(gateway, @subject) if @kind == Kind::GrantedPaymentInstrumentRevoked
88
91
  @local_payment_completed = LocalPaymentCompleted._new(@subject[:local_payment]) if @subject.has_key?(:local_payment)
89
92
  end
90
93
 
@@ -21,7 +21,7 @@ describe Braintree::AddOn do
21
21
  add_on = add_ons.select { |add_on| add_on.id == id }.first
22
22
 
23
23
  add_on.should_not be_nil
24
- add_on.amount.should == BigDecimal.new(expected[:amount])
24
+ add_on.amount.should == BigDecimal(expected[:amount])
25
25
  add_on.created_at.should_not be_nil
26
26
  add_on.description.should == expected[:description]
27
27
  add_on.kind.should == expected[:kind]
@@ -592,7 +592,7 @@ describe Braintree::CreditCard do
592
592
  :amount => "100.00"
593
593
  )
594
594
  result.success?.should == true
595
- result.transaction.amount.should == BigDecimal.new("100.00")
595
+ result.transaction.amount.should == BigDecimal("100.00")
596
596
  result.transaction.type.should == "credit"
597
597
  result.transaction.customer_details.id.should == customer.id
598
598
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -614,7 +614,7 @@ describe Braintree::CreditCard do
614
614
  customer.credit_cards[0].token,
615
615
  :amount => "100.00"
616
616
  )
617
- transaction.amount.should == BigDecimal.new("100.00")
617
+ transaction.amount.should == BigDecimal("100.00")
618
618
  transaction.type.should == "credit"
619
619
  transaction.customer_details.id.should == customer.id
620
620
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1064,7 +1064,7 @@ describe Braintree::CreditCard do
1064
1064
  :amount => "100.00"
1065
1065
  )
1066
1066
  result.success?.should == true
1067
- result.transaction.amount.should == BigDecimal.new("100.00")
1067
+ result.transaction.amount.should == BigDecimal("100.00")
1068
1068
  result.transaction.type.should == "credit"
1069
1069
  result.transaction.customer_details.id.should == customer.id
1070
1070
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1083,7 +1083,7 @@ describe Braintree::CreditCard do
1083
1083
  }
1084
1084
  )
1085
1085
  transaction = customer.credit_cards[0].credit!(:amount => "100.00")
1086
- transaction.amount.should == BigDecimal.new("100.00")
1086
+ transaction.amount.should == BigDecimal("100.00")
1087
1087
  transaction.type.should == "credit"
1088
1088
  transaction.customer_details.id.should == customer.id
1089
1089
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1208,7 +1208,7 @@ describe Braintree::CreditCard do
1208
1208
  found_card.subscriptions.first.id.should == subscription.id
1209
1209
  found_card.subscriptions.first.plan_id.should == "integration_trialless_plan"
1210
1210
  found_card.subscriptions.first.payment_method_token.should == credit_card.token
1211
- found_card.subscriptions.first.price.should == BigDecimal.new("1.00")
1211
+ found_card.subscriptions.first.price.should == BigDecimal("1.00")
1212
1212
  end
1213
1213
 
1214
1214
  it "raises a NotFoundError exception if payment method cannot be found" do
@@ -1295,7 +1295,7 @@ describe Braintree::CreditCard do
1295
1295
  result = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00")
1296
1296
 
1297
1297
  result.success?.should == true
1298
- result.transaction.amount.should == BigDecimal.new("100.00")
1298
+ result.transaction.amount.should == BigDecimal("100.00")
1299
1299
  result.transaction.type.should == "sale"
1300
1300
  result.transaction.customer_details.id.should == customer.id
1301
1301
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1319,7 +1319,7 @@ describe Braintree::CreditCard do
1319
1319
  )
1320
1320
 
1321
1321
  result.success?.should == true
1322
- result.transaction.amount.should == BigDecimal.new("100.00")
1322
+ result.transaction.amount.should == BigDecimal("100.00")
1323
1323
  result.transaction.type.should == "sale"
1324
1324
  result.transaction.customer_details.id.should == customer.id
1325
1325
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1336,7 +1336,7 @@ describe Braintree::CreditCard do
1336
1336
  }
1337
1337
  )
1338
1338
  transaction = Braintree::CreditCard.sale!(customer.credit_cards[0].token, :amount => "100.00")
1339
- transaction.amount.should == BigDecimal.new("100.00")
1339
+ transaction.amount.should == BigDecimal("100.00")
1340
1340
  transaction.type.should == "sale"
1341
1341
  transaction.customer_details.id.should == customer.id
1342
1342
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1358,7 +1358,7 @@ describe Braintree::CreditCard do
1358
1358
  :amount => "100.00"
1359
1359
  )
1360
1360
  result.success?.should == true
1361
- result.transaction.amount.should == BigDecimal.new("100.00")
1361
+ result.transaction.amount.should == BigDecimal("100.00")
1362
1362
  result.transaction.type.should == "sale"
1363
1363
  result.transaction.customer_details.id.should == customer.id
1364
1364
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -1377,7 +1377,7 @@ describe Braintree::CreditCard do
1377
1377
  }
1378
1378
  )
1379
1379
  transaction = customer.credit_cards[0].sale!(:amount => "100.00")
1380
- transaction.amount.should == BigDecimal.new("100.00")
1380
+ transaction.amount.should == BigDecimal("100.00")
1381
1381
  transaction.type.should == "sale"
1382
1382
  transaction.customer_details.id.should == customer.id
1383
1383
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -531,7 +531,7 @@ describe Braintree::Customer do
531
531
  )
532
532
  result = Braintree::Customer.credit(customer.id, :amount => "100.00")
533
533
  result.success?.should == true
534
- result.transaction.amount.should == BigDecimal.new("100.00")
534
+ result.transaction.amount.should == BigDecimal("100.00")
535
535
  result.transaction.type.should == "credit"
536
536
  result.transaction.customer_details.id.should == customer.id
537
537
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -550,7 +550,7 @@ describe Braintree::Customer do
550
550
  }
551
551
  )
552
552
  transaction = Braintree::Customer.credit!(customer.id, :amount => "100.00")
553
- transaction.amount.should == BigDecimal.new("100.00")
553
+ transaction.amount.should == BigDecimal("100.00")
554
554
  transaction.type.should == "credit"
555
555
  transaction.customer_details.id.should == customer.id
556
556
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -570,7 +570,7 @@ describe Braintree::Customer do
570
570
  )
571
571
  result = Braintree::Customer.sale(customer.id, :amount => "100.00")
572
572
  result.success?.should == true
573
- result.transaction.amount.should == BigDecimal.new("100.00")
573
+ result.transaction.amount.should == BigDecimal("100.00")
574
574
  result.transaction.type.should == "sale"
575
575
  result.transaction.customer_details.id.should == customer.id
576
576
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -589,7 +589,7 @@ describe Braintree::Customer do
589
589
  }
590
590
  )
591
591
  transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
592
- transaction.amount.should == BigDecimal.new("100.00")
592
+ transaction.amount.should == BigDecimal("100.00")
593
593
  transaction.type.should == "sale"
594
594
  transaction.customer_details.id.should == customer.id
595
595
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -626,7 +626,7 @@ describe Braintree::Customer do
626
626
  :amount => "100.00"
627
627
  )
628
628
  result.success?.should == true
629
- result.transaction.amount.should == BigDecimal.new("100.00")
629
+ result.transaction.amount.should == BigDecimal("100.00")
630
630
  result.transaction.type.should == "sale"
631
631
  result.transaction.customer_details.id.should == customer.id
632
632
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -645,7 +645,7 @@ describe Braintree::Customer do
645
645
  }
646
646
  )
647
647
  transaction = customer.sale!(:amount => "100.00")
648
- transaction.amount.should == BigDecimal.new("100.00")
648
+ transaction.amount.should == BigDecimal("100.00")
649
649
  transaction.type.should == "sale"
650
650
  transaction.customer_details.id.should == customer.id
651
651
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -681,7 +681,7 @@ describe Braintree::Customer do
681
681
  :amount => "100.00"
682
682
  )
683
683
  result.success?.should == true
684
- result.transaction.amount.should == BigDecimal.new("100.00")
684
+ result.transaction.amount.should == BigDecimal("100.00")
685
685
  result.transaction.type.should == "credit"
686
686
  result.transaction.customer_details.id.should == customer.id
687
687
  result.transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -700,7 +700,7 @@ describe Braintree::Customer do
700
700
  }
701
701
  )
702
702
  transaction = customer.credit!(:amount => "100.00")
703
- transaction.amount.should == BigDecimal.new("100.00")
703
+ transaction.amount.should == BigDecimal("100.00")
704
704
  transaction.type.should == "credit"
705
705
  transaction.customer_details.id.should == customer.id
706
706
  transaction.credit_card_details.token.should == customer.credit_cards[0].token
@@ -820,7 +820,7 @@ describe Braintree::Customer do
820
820
  found_customer.credit_cards.first.subscriptions.first.id.should == subscription.id
821
821
  found_customer.credit_cards.first.subscriptions.first.plan_id.should == "integration_trialless_plan"
822
822
  found_customer.credit_cards.first.subscriptions.first.payment_method_token.should == credit_card.token
823
- found_customer.credit_cards.first.subscriptions.first.price.should == BigDecimal.new("1.00")
823
+ found_customer.credit_cards.first.subscriptions.first.price.should == BigDecimal("1.00")
824
824
  end
825
825
 
826
826
  context "when given an association filter id" do
@@ -21,7 +21,7 @@ describe Braintree::Discount do
21
21
  discount = discounts.select { |discount| discount.id == id }.first
22
22
 
23
23
  discount.should_not be_nil
24
- discount.amount.should == BigDecimal.new(expected[:amount])
24
+ discount.amount.should == BigDecimal(expected[:amount])
25
25
  discount.created_at.should_not be_nil
26
26
  discount.description.should == expected[:description]
27
27
  discount.kind.should == expected[:kind]
@@ -46,6 +46,13 @@ describe Braintree::DocumentUploadGateway do
46
46
  end
47
47
  end
48
48
 
49
+ it "returns file too long error with file over 50 pages" do
50
+ filename = "#{File.dirname(__FILE__)}/../../fixtures/files/too_long.pdf"
51
+ file = File.new(filename, "r")
52
+ response = Braintree::DocumentUpload.create({:kind => Braintree::DocumentUpload::Kind::EvidenceDocument, :file => file})
53
+ response.errors.for(:document_upload).first.code.should == Braintree::ErrorCodes::DocumentUpload::FileIsTooLong
54
+ end
55
+
49
56
  it "returns invalid keys error if signature is invalid" do
50
57
  expect do
51
58
  response = Braintree::DocumentUpload.create({:invalid_key => "do not add", :kind => Braintree::DocumentUpload::Kind::EvidenceDocument})