braintree 2.50.0 → 2.54.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.
data/README.rdoc CHANGED
@@ -83,7 +83,7 @@ Otherwise, we recommend using the non-bang methods.
83
83
 
84
84
  The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development
85
85
  server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on
86
- your system.
86
+ your system. To run unit tests use rake: `rake test:unit`.
87
87
 
88
88
  == Open Source Attribution
89
89
 
data/lib/braintree.rb CHANGED
@@ -27,6 +27,7 @@ require "braintree/address/country_names"
27
27
  require "braintree/address_gateway"
28
28
  require "braintree/advanced_search"
29
29
  require "braintree/android_pay_card"
30
+ require "braintree/amex_express_checkout_card"
30
31
  require "braintree/apple_pay_card"
31
32
  require "braintree/client_token"
32
33
  require "braintree/client_token_gateway"
@@ -97,6 +98,7 @@ require "braintree/test_transaction"
97
98
  require "braintree/transaction/address_details"
98
99
  require "braintree/transaction/apple_pay_details"
99
100
  require "braintree/transaction/android_pay_details"
101
+ require "braintree/transaction/amex_express_checkout_details"
100
102
  require "braintree/transaction/coinbase_details"
101
103
  require "braintree/transaction/credit_card_details"
102
104
  require "braintree/transaction/customer_details"
@@ -0,0 +1,26 @@
1
+ module Braintree
2
+ class AmexExpressCheckoutCard
3
+ include BaseModule # :nodoc:
4
+
5
+ attr_reader :bin, :card_member_expiry_date, :card_member_number, :card_type, :created_at, :customer_id, :default,
6
+ :expiration_month, :expiration_year, :image_url, :source_description, :subscriptions, :token, :updated_at
7
+
8
+ def initialize(gateway, attributes) # :nodoc:
9
+ @gateway = gateway
10
+ set_instance_variables_from_hash(attributes)
11
+ @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
12
+ end
13
+
14
+ def default?
15
+ @default
16
+ end
17
+
18
+ class << self
19
+ protected :new
20
+ end
21
+
22
+ def self._new(*args) # :nodoc:
23
+ self.new *args
24
+ end
25
+ end
26
+ end
@@ -87,6 +87,7 @@ module Braintree
87
87
  Configuration.gateway.credit_card.from_nonce(nonce)
88
88
  end
89
89
 
90
+ # Deprecated. Use Braintree::PaymentMethod.grant
90
91
  def self.grant(token, allow_vaulting)
91
92
  Configuration.gateway.credit_card.grant(token, allow_vaulting)
92
93
  end
@@ -57,18 +57,9 @@ module Braintree
57
57
  raise NotFoundError, "nonce #{nonce.inspect} locked, consumed, or not found"
58
58
  end
59
59
 
60
+ # Deprecated in favor of PaymentMethodGateway.grant
60
61
  def grant(token, allow_vaulting)
61
- raise ArgumentError if token.nil? || token.to_s.strip == ""
62
- response = @config.http.post(
63
- "#{@config.base_merchant_path}/payment_methods/grant",
64
- :payment_method => {
65
- :shared_payment_method_token => token,
66
- :allow_vaulting => allow_vaulting
67
- }
68
- )
69
- PaymentMethodNonce._new(@gateway, response[:payment_method_nonce])
70
- rescue NotFoundError
71
- raise NotFoundError, "payment method with token #{token.inspect} not found"
62
+ @gateway.payment_method.grant(token, allow_vaulting)
72
63
  end
73
64
 
74
65
  def update(token, attributes)
@@ -4,7 +4,7 @@ module Braintree
4
4
 
5
5
  attr_reader :addresses, :company, :created_at, :credit_cards, :email, :fax, :first_name, :id, :last_name,
6
6
  :phone, :updated_at, :website, :custom_fields, :paypal_accounts, :apple_pay_cards, :coinbase_accounts,
7
- :android_pay_cards
7
+ :android_pay_cards, :amex_express_checkout_cards
8
8
 
9
9
  def self.all
10
10
  Configuration.gateway.customer.all
@@ -92,6 +92,7 @@ module Braintree
92
92
  @apple_pay_cards = (@apple_pay_cards || []).map { |pm| ApplePayCard._new gateway, pm }
93
93
  @europe_bank_accounts = (@europe_bank_Accounts || []).map { |pm| EuropeBankAccount._new gateway, pm }
94
94
  @android_pay_cards = (@android_pay_cards || []).map { |pm| AndroidPayCard._new gateway, pm }
95
+ @amex_express_checkout_cards = (@amex_express_checkout_cards || []).map { |pm| AmexExpressCheckoutCard._new gateway, pm }
95
96
  @addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
96
97
  @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
97
98
  end
@@ -123,7 +124,7 @@ module Braintree
123
124
 
124
125
  # Returns the customer's payment methods
125
126
  def payment_methods
126
- @credit_cards.dup + @paypal_accounts.dup + @apple_pay_cards.dup + @coinbase_accounts.dup
127
+ @credit_cards.dup + @paypal_accounts.dup + @apple_pay_cards.dup + @coinbase_accounts.dup + @android_pay_cards.dup + @amex_express_checkout_cards.dup
127
128
  end
128
129
 
129
130
  def inspect # :nodoc:
@@ -10,6 +10,9 @@ module Braintree
10
10
  attr_reader :currency_iso_code
11
11
  attr_reader :id
12
12
  attr_reader :transaction_details
13
+ attr_reader :kind
14
+ attr_reader :date_opened
15
+ attr_reader :date_won
13
16
 
14
17
  module Status
15
18
  Open = "open"
@@ -31,6 +34,12 @@ module Braintree
31
34
  Retrieval = "retrieval"
32
35
  end
33
36
 
37
+ module Kind
38
+ Chargeback = "chargeback"
39
+ PreArbitration = "pre_arbitration"
40
+ Retrieval = "retrieval"
41
+ end
42
+
34
43
  class << self
35
44
  protected :new
36
45
  def _new(*args) # :nodoc:
@@ -44,6 +53,8 @@ module Braintree
44
53
  @reply_by_date = Date.parse(reply_by_date) unless reply_by_date.nil?
45
54
  @amount = Util.to_big_decimal(amount)
46
55
  @transaction_details = TransactionDetails.new(@transaction)
56
+ @date_opened = Date.parse(date_opened) unless date_opened.nil?
57
+ @date_won = Date.parse(date_won) unless date_won.nil?
47
58
  end
48
59
  end
49
60
  end
@@ -41,8 +41,8 @@ module Braintree
41
41
  concat(business_params).
42
42
  concat(payment_methods)
43
43
 
44
- query_string = query.map { |k, v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join("&")
45
- url = "#{@config.base_url}/oauth/connect?#{CGI.escape(query_string)}"
44
+ query_string = query.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join("&")
45
+ url = "#{@config.base_url}/oauth/connect?#{query_string}"
46
46
  "#{url}&signature=#{_compute_signature(url)}&algorithm=SHA256"
47
47
  end
48
48
 
@@ -17,5 +17,9 @@ module Braintree
17
17
  def self.delete(token)
18
18
  Configuration.gateway.payment_method.delete(token)
19
19
  end
20
+
21
+ def self.grant(token, allow_vaulting)
22
+ Configuration.gateway.payment_method.grant(token, allow_vaulting)
23
+ end
20
24
  end
21
25
  end
@@ -25,6 +25,8 @@ module Braintree
25
25
  SuccessfulResult.new(:payment_method => ApplePayCard._new(@gateway, response[:apple_pay_card]))
26
26
  elsif response[:android_pay_card]
27
27
  SuccessfulResult.new(:payment_method => AndroidPayCard._new(@gateway, response[:android_pay_card]))
28
+ elsif response[:amex_express_checkout_card]
29
+ SuccessfulResult.new(:payment_method => AmexExpressCheckoutCard._new(@gateway, response[:amex_express_checkout_card]))
28
30
  elsif response[:api_error_response]
29
31
  ErrorResult.new(@gateway, response[:api_error_response])
30
32
  elsif response
@@ -66,6 +68,20 @@ module Braintree
66
68
  _do_update(:put, "/payment_methods/any/#{token}", :payment_method => attributes)
67
69
  end
68
70
 
71
+ def grant(token, allow_vaulting)
72
+ raise ArgumentError if token.nil? || token.to_s.strip == ""
73
+ response = @config.http.post(
74
+ "#{@config.base_merchant_path}/payment_methods/grant",
75
+ :payment_method => {
76
+ :shared_payment_method_token => token,
77
+ :allow_vaulting => allow_vaulting
78
+ }
79
+ )
80
+ PaymentMethodNonce._new(@gateway, response[:payment_method_nonce])
81
+ rescue NotFoundError
82
+ raise NotFoundError, "payment method with token #{token.inspect} not found"
83
+ end
84
+
69
85
  def _do_update(http_verb, path, params) # :nodoc:
70
86
  response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params)
71
87
  if response[:credit_card]
@@ -16,6 +16,7 @@ module Braintree
16
16
  AndroidPayVisa = "fake-android-pay-visa-nonce"
17
17
  AndroidPayMasterCard = "fake-android-pay-mastercard-nonce"
18
18
  AndroidPayAmEx = "fake-android-pay-amex-nonce"
19
+ AmexExpressCheckout = "fake-amex-express-checkout-nonce"
19
20
  TransactableVisa = "fake-valid-visa-nonce"
20
21
  TransactableAmEx = "fake-valid-amex-nonce"
21
22
  TransactableMasterCard = "fake-valid-mastercard-nonce"
@@ -85,6 +85,7 @@ module Braintree
85
85
  attr_reader :paypal_details
86
86
  attr_reader :apple_pay_details
87
87
  attr_reader :android_pay_details
88
+ attr_reader :amex_express_checkout_details
88
89
  attr_reader :coinbase_details
89
90
  attr_reader :plan_id
90
91
  # The authorization code from the processor.
@@ -242,6 +243,7 @@ module Braintree
242
243
  @paypal_details = PayPalDetails.new(@paypal)
243
244
  @apple_pay_details = ApplePayDetails.new(@apple_pay)
244
245
  @android_pay_details = AndroidPayDetails.new(@android_pay_card)
246
+ @amex_express_checkout_details = AmexExpressCheckoutDetails.new(@amex_express_checkout_card)
245
247
  @coinbase_details = CoinbaseDetails.new(@coinbase_account)
246
248
  disputes.map! { |attrs| Dispute._new(attrs) } if disputes
247
249
  @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
@@ -0,0 +1,14 @@
1
+ module Braintree
2
+ class Transaction
3
+ class AmexExpressCheckoutDetails
4
+ include BaseModule
5
+
6
+ attr_reader :card_type, :token, :bin, :expiration_month, :expiration_year,
7
+ :card_member_number, :card_member_expiry_date, :image_url, :source_description
8
+
9
+ def initialize(attributes)
10
+ set_instance_variables_from_hash attributes unless attributes.nil?
11
+ end
12
+ end
13
+ end
14
+ end
@@ -144,6 +144,8 @@ module Braintree
144
144
  :store_shipping_address_in_vault,
145
145
  :venmo_sdk_session,
146
146
  :payee_email,
147
+ :skip_avs,
148
+ :skip_cvv,
147
149
  {:paypal => [:custom_field, :payee_email, :description]},
148
150
  {:three_d_secure => [:required]},
149
151
  {:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]}]
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 50
4
+ Minor = 54
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -194,6 +194,7 @@ module Braintree
194
194
  <currency-iso-code>USD</currency-iso-code>
195
195
  <received-date type="date">2014-03-01</received-date>
196
196
  <reply-by-date type="date">2014-03-21</reply-by-date>
197
+ <kind>chargeback</kind>
197
198
  <status>open</status>
198
199
  <reason>fraud</reason>
199
200
  <id>#{id}</id>
@@ -201,6 +202,7 @@ module Braintree
201
202
  <id>#{id}</id>
202
203
  <amount>250.00</amount>
203
204
  </transaction>
205
+ <date-opened type=\"date\">2014-03-21</date-opened>
204
206
  </dispute>
205
207
  XML
206
208
  end
@@ -213,6 +215,7 @@ module Braintree
213
215
  <currency-iso-code>USD</currency-iso-code>
214
216
  <received-date type="date">2014-03-01</received-date>
215
217
  <reply-by-date type="date">2014-03-21</reply-by-date>
218
+ <kind>chargeback</kind>
216
219
  <status>lost</status>
217
220
  <reason>fraud</reason>
218
221
  <id>#{id}</id>
@@ -220,6 +223,7 @@ module Braintree
220
223
  <id>#{id}</id>
221
224
  <amount>250.00</amount>
222
225
  </transaction>
226
+ <date-opened type=\"date\">2014-03-21</date-opened>
223
227
  </dispute>
224
228
  XML
225
229
  end
@@ -232,6 +236,7 @@ module Braintree
232
236
  <currency-iso-code>USD</currency-iso-code>
233
237
  <received-date type="date">2014-03-01</received-date>
234
238
  <reply-by-date type="date">2014-03-21</reply-by-date>
239
+ <kind>chargeback</kind>
235
240
  <status>won</status>
236
241
  <reason>fraud</reason>
237
242
  <id>#{id}</id>
@@ -239,6 +244,8 @@ module Braintree
239
244
  <id>#{id}</id>
240
245
  <amount>250.00</amount>
241
246
  </transaction>
247
+ <date-opened type=\"date\">2014-03-21</date-opened>
248
+ <date-won type=\"date\">2014-03-22</date-won>
242
249
  </dispute>
243
250
  XML
244
251
  end
data/spec/httpsd.pid CHANGED
@@ -1 +1 @@
1
- 10834
1
+ 14756
@@ -797,7 +797,8 @@ describe Braintree::Customer do
797
797
  result.success?.should == true
798
798
 
799
799
  found_customer = Braintree::Customer.find(result.customer.id)
800
- found_customer.android_pay_cards.should_not be_nil
800
+ found_customer.android_pay_cards.size.should == 1
801
+ found_customer.payment_methods.size.should == 1
801
802
  android_pay_card = found_customer.android_pay_cards.first
802
803
  android_pay_card.should be_a Braintree::AndroidPayCard
803
804
  android_pay_card.token.should_not be_nil
@@ -811,13 +812,29 @@ describe Braintree::Customer do
811
812
  result.success?.should == true
812
813
 
813
814
  found_customer = Braintree::Customer.find(result.customer.id)
814
- found_customer.android_pay_cards.should_not be_nil
815
+ found_customer.android_pay_cards.size.should == 1
816
+ found_customer.payment_methods.size.should == 1
815
817
  android_pay_card = found_customer.android_pay_cards.first
816
818
  android_pay_card.should be_a Braintree::AndroidPayCard
817
819
  android_pay_card.token.should_not be_nil
818
820
  android_pay_card.expiration_year.should_not be_nil
819
821
  end
820
822
 
823
+ it "returns associated amex express checkout cards" do
824
+ result = Braintree::Customer.create(
825
+ :payment_method_nonce => Braintree::Test::Nonce::AmexExpressCheckout
826
+ )
827
+ result.success?.should == true
828
+
829
+ found_customer = Braintree::Customer.find(result.customer.id)
830
+ found_customer.amex_express_checkout_cards.size.should == 1
831
+ found_customer.payment_methods.size.should == 1
832
+ amex_express_checkout_card = found_customer.amex_express_checkout_cards.first
833
+ amex_express_checkout_card.should be_a Braintree::AmexExpressCheckoutCard
834
+ amex_express_checkout_card.token.should_not be_nil
835
+ amex_express_checkout_card.expiration_year.should_not be_nil
836
+ end
837
+
821
838
  it "works for a blank customer" do
822
839
  created_customer = Braintree::Customer.create!
823
840
  found_customer = Braintree::Customer.find(created_customer.id)
@@ -28,9 +28,9 @@ describe Braintree::MerchantGateway do
28
28
 
29
29
  credentials = result.credentials
30
30
  credentials.access_token.should start_with("access_token$")
31
+ credentials.refresh_token.should start_with("refresh_token$")
31
32
  credentials.expires_at.should_not be_nil
32
33
  credentials.token_type.should == "bearer"
33
- credentials.refresh_token.should be_nil
34
34
  end
35
35
 
36
36
  it "gives an error when using invalid payment_methods" do
@@ -126,7 +126,7 @@ describe "OAuth" do
126
126
  uri.host.should == "localhost"
127
127
  uri.path.should == "/oauth/connect"
128
128
 
129
- query = CGI.parse(CGI.unescape(uri.query))
129
+ query = CGI.parse(uri.query)
130
130
  query["merchant_id"].should == ["integration_merchant_id"]
131
131
  query["client_id"].should == ["client_id$development$integration_client_id"]
132
132
  query["redirect_uri"].should == ["http://bar.example.com"]
@@ -150,6 +150,33 @@ describe Braintree::PaymentMethod do
150
150
  android_pay_card.customer_id.should == customer.id
151
151
  end
152
152
 
153
+ it "creates a payment method from an amex express checkout card nonce" do
154
+ customer = Braintree::Customer.create.customer
155
+ token = SecureRandom.hex(16)
156
+ result = Braintree::PaymentMethod.create(
157
+ :payment_method_nonce => Braintree::Test::Nonce::AmexExpressCheckout,
158
+ :customer_id => customer.id,
159
+ :token => token
160
+ )
161
+
162
+ result.should be_success
163
+ amex_express_checkout_card = result.payment_method
164
+ amex_express_checkout_card.should be_a(Braintree::AmexExpressCheckoutCard)
165
+ amex_express_checkout_card.should_not be_nil
166
+
167
+ amex_express_checkout_card.default.should == true
168
+ amex_express_checkout_card.card_type.should == "American Express"
169
+ amex_express_checkout_card.token.should == token
170
+ amex_express_checkout_card.bin.should =~ /\A\d{6}\z/
171
+ amex_express_checkout_card.expiration_month.should =~ /\A\d{2}\z/
172
+ amex_express_checkout_card.expiration_year.should =~ /\A\d{4}\z/
173
+ amex_express_checkout_card.card_member_number.should =~ /\A\d{4}\z/
174
+ amex_express_checkout_card.card_member_expiry_date.should =~ /\A\d{2}\/\d{2}\z/
175
+ amex_express_checkout_card.image_url.should include(".png")
176
+ amex_express_checkout_card.source_description.should =~ /\AAmEx \d{4}\z/
177
+ amex_express_checkout_card.customer_id.should == customer.id
178
+ end
179
+
153
180
  it "allows passing the make_default option alongside the nonce" do
154
181
  customer = Braintree::Customer.create!
155
182
  result = Braintree::CreditCard.create(
@@ -1149,4 +1176,92 @@ describe Braintree::PaymentMethod do
1149
1176
  end
1150
1177
  end
1151
1178
  end
1179
+
1180
+ describe "self.grant" do
1181
+ before(:each) do
1182
+ partner_merchant_gateway = Braintree::Gateway.new(
1183
+ :merchant_id => "integration_merchant_public_id",
1184
+ :public_key => "oauth_app_partner_user_public_key",
1185
+ :private_key => "oauth_app_partner_user_private_key",
1186
+ :environment => :development,
1187
+ :logger => Logger.new("/dev/null")
1188
+ )
1189
+ customer = partner_merchant_gateway.customer.create(
1190
+ :first_name => "Joe",
1191
+ :last_name => "Brown",
1192
+ :company => "ExampleCo",
1193
+ :email => "joe@example.com",
1194
+ :phone => "312.555.1234",
1195
+ :fax => "614.555.5678",
1196
+ :website => "www.example.com"
1197
+ ).customer
1198
+ @credit_card = partner_merchant_gateway.credit_card.create(
1199
+ :customer_id => customer.id,
1200
+ :cardholder_name => "Adam Davis",
1201
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1202
+ :expiration_date => "05/2009"
1203
+ ).credit_card
1204
+
1205
+ oauth_gateway = Braintree::Gateway.new(
1206
+ :client_id => "client_id$development$integration_client_id",
1207
+ :client_secret => "client_secret$development$integration_client_secret",
1208
+ :logger => Logger.new("/dev/null")
1209
+ )
1210
+ access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
1211
+ :merchant_public_id => "integration_merchant_id",
1212
+ :scope => "grant_payment_method"
1213
+ }).credentials.access_token
1214
+
1215
+ @granting_gateway = Braintree::Gateway.new(
1216
+ :access_token => access_token,
1217
+ :logger => Logger.new("/dev/null")
1218
+ )
1219
+ end
1220
+
1221
+ it "returns a nonce that is transactable by a partner merchant exactly once" do
1222
+ grant_result = @granting_gateway.payment_method.grant(@credit_card.token, false)
1223
+
1224
+ result = Braintree::Transaction.sale(
1225
+ :payment_method_nonce => grant_result.nonce,
1226
+ :amount => Braintree::Test::TransactionAmounts::Authorize
1227
+ )
1228
+ result.success?.should == true
1229
+
1230
+ result2 = Braintree::Transaction.sale(
1231
+ :payment_method_nonce => grant_result.nonce,
1232
+ :amount => Braintree::Test::TransactionAmounts::Authorize
1233
+ )
1234
+ result2.success?.should == false
1235
+ end
1236
+
1237
+ it "returns a nonce that is not vaultable" do
1238
+ grant_result = @granting_gateway.payment_method.grant(@credit_card.token, false)
1239
+
1240
+ customer_result = Braintree::Customer.create()
1241
+
1242
+ result = Braintree::PaymentMethod.create(
1243
+ :customer_id => customer_result.customer.id,
1244
+ :payment_method_nonce => grant_result.nonce
1245
+ )
1246
+ result.success?.should == false
1247
+ end
1248
+
1249
+ it "returns a nonce that is vaultable" do
1250
+ grant_result = @granting_gateway.payment_method.grant(@credit_card.token, true)
1251
+
1252
+ customer_result = Braintree::Customer.create()
1253
+
1254
+ result = Braintree::PaymentMethod.create(
1255
+ :customer_id => customer_result.customer.id,
1256
+ :payment_method_nonce => grant_result.nonce
1257
+ )
1258
+ result.success?.should == true
1259
+ end
1260
+
1261
+ it "raises an error if the token isn't found" do
1262
+ expect do
1263
+ @granting_gateway.payment_method.grant("not_a_real_token", false)
1264
+ end.to raise_error
1265
+ end
1266
+ end
1152
1267
  end
@@ -1379,6 +1379,29 @@ describe Braintree::Transaction do
1379
1379
  android_pay_details.google_transaction_id.should == "google_transaction_id"
1380
1380
  end
1381
1381
 
1382
+ it "can create a transaction with a fake amex express checkout card nonce" do
1383
+ result = Braintree::Transaction.create(
1384
+ :type => "sale",
1385
+ :merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
1386
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1387
+ :payment_method_nonce => Braintree::Test::Nonce::AmexExpressCheckout,
1388
+ :options => {:store_in_vault => true}
1389
+ )
1390
+ result.success?.should == true
1391
+ result.transaction.should_not be_nil
1392
+ checkout_details = result.transaction.amex_express_checkout_details
1393
+ checkout_details.should_not be_nil
1394
+ checkout_details.card_type.should == "American Express"
1395
+ checkout_details.token.should respond_to(:to_str)
1396
+ checkout_details.bin.should =~ /\A\d{6}\z/
1397
+ checkout_details.expiration_month.should =~ /\A\d{2}\z/
1398
+ checkout_details.expiration_year.should =~ /\A\d{4}\z/
1399
+ checkout_details.card_member_number.should =~ /\A\d{4}\z/
1400
+ checkout_details.card_member_expiry_date.should =~ /\A\d{2}\/\d{2}\z/
1401
+ checkout_details.image_url.should include(".png")
1402
+ checkout_details.source_description.should =~ /\AAmEx \d{4}\z/
1403
+ end
1404
+
1382
1405
  it "can create a transaction with an unknown nonce" do
1383
1406
  customer = Braintree::Customer.create!
1384
1407
  result = Braintree::Transaction.create(
@@ -3150,6 +3173,9 @@ describe Braintree::Transaction do
3150
3173
  dispute.status.should == Braintree::Dispute::Status::Won
3151
3174
  dispute.transaction_details.amount.should == Braintree::Util.to_big_decimal("1000.00")
3152
3175
  dispute.transaction_details.id.should == "disputedtransaction"
3176
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
3177
+ dispute.date_opened.should == Date.new(2014, 3, 1)
3178
+ dispute.date_won.should == Date.new(2014, 3, 7)
3153
3179
  end
3154
3180
 
3155
3181
  it "includes disputes on found transactions" do
@@ -72,6 +72,8 @@ describe Braintree::WebhookNotification do
72
72
  dispute = notification.dispute
73
73
  dispute.status.should == Braintree::Dispute::Status::Open
74
74
  dispute.id.should == "my_id"
75
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
76
+ dispute.date_opened.should == Date.new(2014,03,21)
75
77
  end
76
78
 
77
79
  it "builds a sample notification for a dispute lost webhook" do
@@ -87,6 +89,8 @@ describe Braintree::WebhookNotification do
87
89
  dispute = notification.dispute
88
90
  dispute.status.should == Braintree::Dispute::Status::Lost
89
91
  dispute.id.should == "my_id"
92
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
93
+ dispute.date_opened.should == Date.new(2014,03,21)
90
94
  end
91
95
 
92
96
  it "builds a sample notification for a dispute won webhook" do
@@ -102,6 +106,9 @@ describe Braintree::WebhookNotification do
102
106
  dispute = notification.dispute
103
107
  dispute.status.should == Braintree::Dispute::Status::Won
104
108
  dispute.id.should == "my_id"
109
+ dispute.kind.should == Braintree::Dispute::Kind::Chargeback
110
+ dispute.date_opened.should == Date.new(2014,03,21)
111
+ dispute.date_won.should == Date.new(2014,03,22)
105
112
  end
106
113
  end
107
114
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.50.0
4
+ version: 2.54.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-09 00:00:00.000000000 Z
12
+ date: 2015-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -35,202 +35,204 @@ extra_rdoc_files: []
35
35
  files:
36
36
  - README.rdoc
37
37
  - LICENSE
38
- - lib/braintree.rb
39
- - lib/braintree/transaction_gateway.rb
40
- - lib/braintree/credit_card_verification.rb
41
- - lib/braintree/transparent_redirect_gateway.rb
42
- - lib/braintree/resource_collection.rb
43
- - lib/braintree/subscription.rb
44
- - lib/braintree/dispute/transaction_details.rb
45
- - lib/braintree/address/country_names.rb
46
- - lib/braintree/subscription/status_details.rb
47
- - lib/braintree/credit_card_verification_search.rb
48
- - lib/braintree/merchant_account_gateway.rb
49
- - lib/braintree/util.rb
50
- - lib/braintree/paypal_account_gateway.rb
51
- - lib/braintree/address_gateway.rb
52
- - lib/braintree/webhook_notification_gateway.rb
53
- - lib/braintree/transaction/android_pay_details.rb
54
- - lib/braintree/transaction/apple_pay_details.rb
55
- - lib/braintree/transaction/subscription_details.rb
56
- - lib/braintree/transaction/status_details.rb
57
- - lib/braintree/transaction/disbursement_details.rb
58
- - lib/braintree/transaction/address_details.rb
59
- - lib/braintree/transaction/coinbase_details.rb
60
- - lib/braintree/transaction/customer_details.rb
61
- - lib/braintree/transaction/paypal_details.rb
62
- - lib/braintree/transaction/credit_card_details.rb
63
- - lib/braintree/errors.rb
64
- - lib/braintree/transaction_search.rb
65
- - lib/braintree/validation_error_collection.rb
66
38
  - lib/braintree/webhook_testing_gateway.rb
67
- - lib/braintree/payment_method_gateway.rb
68
- - lib/braintree/discount.rb
69
- - lib/braintree/credit_card.rb
70
- - lib/braintree/credentials_parser.rb
71
39
  - lib/braintree/version.rb
40
+ - lib/braintree/plan.rb
41
+ - lib/braintree/configuration.rb
72
42
  - lib/braintree/disbursement.rb
73
- - lib/braintree/paypal_account.rb
74
- - lib/braintree/subscription_search.rb
43
+ - lib/braintree/successful_result.rb
44
+ - lib/braintree/dispute.rb
75
45
  - lib/braintree/exceptions.rb
76
- - lib/braintree/settlement_batch_summary.rb
77
- - lib/braintree/coinbase_account.rb
78
- - lib/braintree/europe_bank_account.rb
79
- - lib/braintree/transaction.rb
80
- - lib/braintree/discount_gateway.rb
81
- - lib/braintree/android_pay_card.rb
82
- - lib/braintree/gateway.rb
83
- - lib/braintree/merchant.rb
84
- - lib/braintree/advanced_search.rb
85
- - lib/braintree/oauth_gateway.rb
86
46
  - lib/braintree/add_on_gateway.rb
87
- - lib/braintree/payment_method.rb
88
- - lib/braintree/settlement_batch.rb
89
- - lib/braintree/payment_method_nonce.rb
90
- - lib/braintree/customer_search.rb
91
- - lib/braintree/transparent_redirect.rb
92
47
  - lib/braintree/payment_instrument_type.rb
93
- - lib/braintree/digest.rb
94
- - lib/braintree/customer.rb
95
- - lib/braintree/subscription_gateway.rb
96
- - lib/braintree/client_token_gateway.rb
97
- - lib/braintree/customer_gateway.rb
98
- - lib/braintree/signature_service.rb
48
+ - lib/braintree/transaction_search.rb
49
+ - lib/braintree/util.rb
50
+ - lib/braintree/credit_card_verification.rb
51
+ - lib/braintree/test/nonce.rb
99
52
  - lib/braintree/test/credit_card.rb
100
53
  - lib/braintree/test/transaction_amounts.rb
101
- - lib/braintree/test/nonce.rb
102
54
  - lib/braintree/test/merchant_account.rb
103
55
  - lib/braintree/test/venmo_sdk.rb
104
- - lib/braintree/dispute.rb
105
- - lib/braintree/testing_gateway.rb
106
- - lib/braintree/error_result.rb
56
+ - lib/braintree/transaction/credit_card_details.rb
57
+ - lib/braintree/transaction/subscription_details.rb
58
+ - lib/braintree/transaction/status_details.rb
59
+ - lib/braintree/transaction/disbursement_details.rb
60
+ - lib/braintree/transaction/address_details.rb
61
+ - lib/braintree/transaction/amex_express_checkout_details.rb
62
+ - lib/braintree/transaction/customer_details.rb
63
+ - lib/braintree/transaction/android_pay_details.rb
64
+ - lib/braintree/transaction/paypal_details.rb
65
+ - lib/braintree/transaction/apple_pay_details.rb
66
+ - lib/braintree/transaction/coinbase_details.rb
107
67
  - lib/braintree/risk_data.rb
108
- - lib/braintree/successful_result.rb
109
- - lib/braintree/xml/generator.rb
110
- - lib/braintree/xml/libxml.rb
111
- - lib/braintree/xml/parser.rb
112
- - lib/braintree/xml/rexml.rb
113
- - lib/braintree/webhook_notification.rb
114
- - lib/braintree/error_codes.rb
115
- - lib/braintree/base_module.rb
116
- - lib/braintree/credit_card_verification_gateway.rb
68
+ - lib/braintree/credit_card_verification_search.rb
69
+ - lib/braintree/transparent_redirect_gateway.rb
117
70
  - lib/braintree/three_d_secure_info.rb
118
- - lib/braintree/client_token.rb
119
- - lib/braintree/add_on.rb
71
+ - lib/braintree/merchant_gateway.rb
72
+ - lib/braintree/subscription/status_details.rb
73
+ - lib/braintree/address/country_names.rb
74
+ - lib/braintree/settlement_batch.rb
75
+ - lib/braintree/validation_error.rb
76
+ - lib/braintree/webhook_notification.rb
77
+ - lib/braintree/client_token_gateway.rb
78
+ - lib/braintree/subscription_gateway.rb
79
+ - lib/braintree/testing_gateway.rb
80
+ - lib/braintree/address_gateway.rb
81
+ - lib/braintree/payment_method.rb
82
+ - lib/braintree/webhook_notification_gateway.rb
120
83
  - lib/braintree/webhook_testing.rb
121
- - lib/braintree/configuration.rb
122
- - lib/braintree/http.rb
123
- - lib/braintree/unknown_payment_method.rb
124
- - lib/braintree/xml.rb
125
- - lib/braintree/credit_card_gateway.rb
126
- - lib/braintree/apple_pay_card.rb
127
- - lib/braintree/europe_bank_account_gateway.rb
84
+ - lib/braintree/base_module.rb
85
+ - lib/braintree/oauth_credentials.rb
86
+ - lib/braintree/customer_gateway.rb
87
+ - lib/braintree/modification.rb
88
+ - lib/braintree/payment_method_nonce_gateway.rb
89
+ - lib/braintree/plan_gateway.rb
90
+ - lib/braintree/credit_card.rb
91
+ - lib/braintree/merchant.rb
92
+ - lib/braintree/advanced_search.rb
93
+ - lib/braintree/test_transaction.rb
94
+ - lib/braintree/transaction_gateway.rb
95
+ - lib/braintree/payment_method_gateway.rb
96
+ - lib/braintree/settlement_batch_summary.rb
128
97
  - lib/braintree/merchant_account/funding_details.rb
129
- - lib/braintree/merchant_account/individual_details.rb
130
98
  - lib/braintree/merchant_account/address_details.rb
131
99
  - lib/braintree/merchant_account/business_details.rb
132
- - lib/braintree/plan_gateway.rb
133
- - lib/braintree/payment_method_nonce_gateway.rb
134
- - lib/braintree/settlement_batch_summary_gateway.rb
135
- - lib/braintree/address.rb
136
- - lib/braintree/plan.rb
137
- - lib/braintree/merchant_gateway.rb
138
- - lib/braintree/merchant_account.rb
100
+ - lib/braintree/merchant_account/individual_details.rb
101
+ - lib/braintree/dispute/transaction_details.rb
102
+ - lib/braintree/facilitator_details.rb
103
+ - lib/braintree/validation_error_collection.rb
139
104
  - lib/braintree/sha256_digest.rb
105
+ - lib/braintree/europe_bank_account.rb
106
+ - lib/braintree/transaction.rb
107
+ - lib/braintree/subscription.rb
108
+ - lib/braintree/xml.rb
109
+ - lib/braintree/merchant_account.rb
110
+ - lib/braintree/apple_pay_card.rb
111
+ - lib/braintree/error_result.rb
112
+ - lib/braintree/payment_method_nonce.rb
113
+ - lib/braintree/oauth_gateway.rb
140
114
  - lib/braintree/descriptor.rb
141
- - lib/braintree/oauth_credentials.rb
142
- - lib/braintree/facilitator_details.rb
143
- - lib/braintree/validation_error.rb
144
- - lib/braintree/modification.rb
145
- - lib/braintree/test_transaction.rb
115
+ - lib/braintree/add_on.rb
116
+ - lib/braintree/resource_collection.rb
117
+ - lib/braintree/coinbase_account.rb
118
+ - lib/braintree/digest.rb
119
+ - lib/braintree/gateway.rb
120
+ - lib/braintree/amex_express_checkout_card.rb
121
+ - lib/braintree/customer.rb
122
+ - lib/braintree/client_token.rb
123
+ - lib/braintree/paypal_account_gateway.rb
124
+ - lib/braintree/europe_bank_account_gateway.rb
125
+ - lib/braintree/transparent_redirect.rb
126
+ - lib/braintree/credentials_parser.rb
127
+ - lib/braintree/errors.rb
128
+ - lib/braintree/unknown_payment_method.rb
129
+ - lib/braintree/customer_search.rb
130
+ - lib/braintree/error_codes.rb
131
+ - lib/braintree/discount_gateway.rb
132
+ - lib/braintree/subscription_search.rb
133
+ - lib/braintree/http.rb
134
+ - lib/braintree/address.rb
135
+ - lib/braintree/credit_card_gateway.rb
136
+ - lib/braintree/credit_card_verification_gateway.rb
137
+ - lib/braintree/merchant_account_gateway.rb
138
+ - lib/braintree/android_pay_card.rb
139
+ - lib/braintree/paypal_account.rb
140
+ - lib/braintree/signature_service.rb
141
+ - lib/braintree/settlement_batch_summary_gateway.rb
142
+ - lib/braintree/discount.rb
143
+ - lib/braintree/xml/rexml.rb
144
+ - lib/braintree/xml/generator.rb
145
+ - lib/braintree/xml/libxml.rb
146
+ - lib/braintree/xml/parser.rb
147
+ - lib/braintree.rb
146
148
  - lib/ssl/www_braintreegateway_com.ca.crt
147
149
  - lib/ssl/api_braintreegateway_com.ca.crt
148
150
  - lib/ssl/securetrust_ca.crt
149
151
  - lib/ssl/sandbox_braintreegateway_com.ca.crt
150
- - spec/unit/braintree_spec.rb
151
- - spec/unit/spec_helper.rb
152
- - spec/unit/braintree/resource_collection_spec.rb
153
- - spec/unit/braintree/transaction/credit_card_details_spec.rb
154
- - spec/unit/braintree/transaction/customer_details_spec.rb
155
- - spec/unit/braintree/transaction/deposit_details_spec.rb
152
+ - spec/httpsd.pid
153
+ - spec/script/httpsd.rb
156
154
  - spec/unit/braintree/base_module_spec.rb
157
- - spec/unit/braintree/transaction_search_spec.rb
158
- - spec/unit/braintree/disbursement_spec.rb
159
- - spec/unit/braintree/risk_data_spec.rb
155
+ - spec/unit/braintree/signature_service_spec.rb
156
+ - spec/unit/braintree/http_spec.rb
157
+ - spec/unit/braintree/modification_spec.rb
160
158
  - spec/unit/braintree/credit_card_verification_search_spec.rb
159
+ - spec/unit/braintree/transaction/deposit_details_spec.rb
160
+ - spec/unit/braintree/transaction/customer_details_spec.rb
161
+ - spec/unit/braintree/transaction/credit_card_details_spec.rb
162
+ - spec/unit/braintree/error_result_spec.rb
163
+ - spec/unit/braintree/unknown_payment_method_spec.rb
164
+ - spec/unit/braintree/credit_card_spec.rb
165
+ - spec/unit/braintree/disbursement_spec.rb
166
+ - spec/unit/braintree/credentials_parser_spec.rb
167
+ - spec/unit/braintree/subscription_spec.rb
168
+ - spec/unit/braintree/successful_result_spec.rb
169
+ - spec/unit/braintree/merchant_account_spec.rb
170
+ - spec/unit/braintree/sha256_digest_spec.rb
171
+ - spec/unit/braintree/transaction_search_spec.rb
161
172
  - spec/unit/braintree/util_spec.rb
162
- - spec/unit/braintree/three_d_secure_info_spec.rb
163
- - spec/unit/braintree/payment_method_spec.rb
164
- - spec/unit/braintree/address_spec.rb
173
+ - spec/unit/braintree/validation_error_spec.rb
165
174
  - spec/unit/braintree/transaction_spec.rb
166
- - spec/unit/braintree/subscription_search_spec.rb
175
+ - spec/unit/braintree/resource_collection_spec.rb
176
+ - spec/unit/braintree/paypal_account_spec.rb
177
+ - spec/unit/braintree/address_spec.rb
178
+ - spec/unit/braintree/webhook_notification_spec.rb
179
+ - spec/unit/braintree/transparent_redirect_spec.rb
180
+ - spec/unit/braintree/configuration_spec.rb
181
+ - spec/unit/braintree/credit_card_verification_spec.rb
167
182
  - spec/unit/braintree/client_token_spec.rb
168
- - spec/unit/braintree/validation_error_collection_spec.rb
169
- - spec/unit/braintree/merchant_account_spec.rb
170
183
  - spec/unit/braintree/apple_pay_card_spec.rb
171
- - spec/unit/braintree/credentials_parser_spec.rb
172
- - spec/unit/braintree/sha256_digest_spec.rb
173
- - spec/unit/braintree/signature_service_spec.rb
174
- - spec/unit/braintree/digest_spec.rb
175
- - spec/unit/braintree/credit_card_verification_spec.rb
176
- - spec/unit/braintree/xml_spec.rb
177
- - spec/unit/braintree/http_spec.rb
178
- - spec/unit/braintree/configuration_spec.rb
184
+ - spec/unit/braintree/risk_data_spec.rb
179
185
  - spec/unit/braintree/customer_spec.rb
186
+ - spec/unit/braintree/xml_spec.rb
187
+ - spec/unit/braintree/validation_error_collection_spec.rb
188
+ - spec/unit/braintree/payment_method_spec.rb
189
+ - spec/unit/braintree/subscription_search_spec.rb
190
+ - spec/unit/braintree/three_d_secure_info_spec.rb
191
+ - spec/unit/braintree/digest_spec.rb
192
+ - spec/unit/braintree/errors_spec.rb
193
+ - spec/unit/braintree/dispute_spec.rb
180
194
  - spec/unit/braintree/xml/parser_spec.rb
181
- - spec/unit/braintree/xml/rexml_spec.rb
182
195
  - spec/unit/braintree/xml/libxml_spec.rb
183
- - spec/unit/braintree/paypal_account_spec.rb
184
- - spec/unit/braintree/subscription_spec.rb
185
- - spec/unit/braintree/transparent_redirect_spec.rb
186
- - spec/unit/braintree/validation_error_spec.rb
187
- - spec/unit/braintree/webhook_notification_spec.rb
188
- - spec/unit/braintree/dispute_spec.rb
189
- - spec/unit/braintree/credit_card_spec.rb
190
- - spec/unit/braintree/error_result_spec.rb
191
- - spec/unit/braintree/unknown_payment_method_spec.rb
192
- - spec/unit/braintree/modification_spec.rb
193
- - spec/unit/braintree/errors_spec.rb
194
- - spec/unit/braintree/successful_result_spec.rb
195
- - spec/integration/spec_helper.rb
196
- - spec/integration/braintree/plan_spec.rb
197
- - spec/integration/braintree/transaction_search_spec.rb
198
- - spec/integration/braintree/disbursement_spec.rb
196
+ - spec/unit/braintree/xml/rexml_spec.rb
197
+ - spec/unit/braintree_spec.rb
198
+ - spec/unit/spec_helper.rb
199
+ - spec/hacks/tcp_socket.rb
200
+ - spec/oauth_test_helper.rb
201
+ - spec/integration/braintree/http_spec.rb
199
202
  - spec/integration/braintree/credit_card_verification_search_spec.rb
200
- - spec/integration/braintree/payment_method_spec.rb
201
- - spec/integration/braintree/address_spec.rb
202
- - spec/integration/braintree/transaction_spec.rb
203
203
  - spec/integration/braintree/payment_method_nonce_spec.rb
204
- - spec/integration/braintree/customer_search_spec.rb
205
- - spec/integration/braintree/settlement_batch_summary_spec.rb
206
- - spec/integration/braintree/discount_spec.rb
207
- - spec/integration/braintree/oauth_spec.rb
208
- - spec/integration/braintree/merchant_spec.rb
209
- - spec/integration/braintree/merchant_account_spec.rb
210
- - spec/integration/braintree/test_transaction_spec.rb
211
- - spec/integration/braintree/credit_card_verification_spec.rb
212
204
  - spec/integration/braintree/test/transaction_amounts_spec.rb
213
- - spec/integration/braintree/http_spec.rb
205
+ - spec/integration/braintree/client_api/client_token_spec.rb
206
+ - spec/integration/braintree/client_api/spec_helper.rb
207
+ - spec/integration/braintree/test_transaction_spec.rb
208
+ - spec/integration/braintree/merchant_spec.rb
214
209
  - spec/integration/braintree/add_on_spec.rb
215
- - spec/integration/braintree/customer_spec.rb
216
- - spec/integration/braintree/paypal_account_spec.rb
210
+ - spec/integration/braintree/credit_card_spec.rb
211
+ - spec/integration/braintree/disbursement_spec.rb
217
212
  - spec/integration/braintree/subscription_spec.rb
218
- - spec/integration/braintree/transparent_redirect_spec.rb
213
+ - spec/integration/braintree/merchant_account_spec.rb
219
214
  - spec/integration/braintree/advanced_search_spec.rb
220
- - spec/integration/braintree/credit_card_spec.rb
221
- - spec/integration/braintree/client_api/client_token_spec.rb
222
- - spec/integration/braintree/client_api/spec_helper.rb
223
- - spec/integration/braintree/error_codes_spec.rb
215
+ - spec/integration/braintree/transaction_search_spec.rb
216
+ - spec/integration/braintree/transaction_spec.rb
217
+ - spec/integration/braintree/plan_spec.rb
218
+ - spec/integration/braintree/paypal_account_spec.rb
219
+ - spec/integration/braintree/discount_spec.rb
220
+ - spec/integration/braintree/address_spec.rb
221
+ - spec/integration/braintree/transparent_redirect_spec.rb
222
+ - spec/integration/braintree/credit_card_verification_spec.rb
224
223
  - spec/integration/braintree/coinbase_spec.rb
225
- - spec/oauth_test_helper.rb
224
+ - spec/integration/braintree/customer_spec.rb
225
+ - spec/integration/braintree/payment_method_spec.rb
226
+ - spec/integration/braintree/settlement_batch_summary_spec.rb
227
+ - spec/integration/braintree/oauth_spec.rb
228
+ - spec/integration/braintree/error_codes_spec.rb
229
+ - spec/integration/braintree/customer_search_spec.rb
230
+ - spec/integration/spec_helper.rb
226
231
  - spec/spec_helper.rb
227
232
  - spec/spec.opts
228
- - spec/hacks/tcp_socket.rb
229
233
  - spec/ssl/geotrust_global.crt
230
- - spec/ssl/certificate.crt
231
234
  - spec/ssl/privateKey.key
232
- - spec/script/httpsd.rb
233
- - spec/httpsd.pid
235
+ - spec/ssl/certificate.crt
234
236
  - braintree.gemspec
235
237
  homepage: http://www.braintreepayments.com/
236
238
  licenses:
@@ -253,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
255
  version: '0'
254
256
  requirements: []
255
257
  rubyforge_project: braintree
256
- rubygems_version: 1.8.25
258
+ rubygems_version: 1.8.24
257
259
  signing_key:
258
260
  specification_version: 3
259
261
  summary: Braintree Gateway Ruby Client Library