braintree 2.78.0 → 2.79.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +9 -0
  3. data/lib/braintree.rb +1 -0
  4. data/lib/braintree/configuration.rb +2 -2
  5. data/lib/braintree/customer_gateway.rb +11 -1
  6. data/lib/braintree/error_codes.rb +3 -0
  7. data/lib/braintree/granted_payment_instrument_update.rb +19 -0
  8. data/lib/braintree/payment_method_gateway.rb +6 -0
  9. data/lib/braintree/risk_data.rb +2 -2
  10. data/lib/braintree/subscription.rb +3 -2
  11. data/lib/braintree/subscription_gateway.rb +7 -2
  12. data/lib/braintree/transaction_gateway.rb +6 -3
  13. data/lib/braintree/version.rb +1 -1
  14. data/lib/braintree/webhook_notification.rb +4 -0
  15. data/lib/braintree/webhook_testing_gateway.rb +22 -0
  16. data/lib/braintree/xml/generator.rb +1 -0
  17. data/spec/integration/braintree/add_on_spec.rb +1 -1
  18. data/spec/integration/braintree/credit_card_spec.rb +1 -0
  19. data/spec/integration/braintree/customer_spec.rb +18 -0
  20. data/spec/integration/braintree/merchant_account_spec.rb +27 -0
  21. data/spec/integration/braintree/oauth_spec.rb +2 -0
  22. data/spec/integration/braintree/payment_method_spec.rb +69 -0
  23. data/spec/integration/braintree/subscription_spec.rb +87 -1
  24. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  25. data/spec/integration/braintree/transaction_spec.rb +25 -38
  26. data/spec/unit/braintree/configuration_spec.rb +11 -2
  27. data/spec/unit/braintree/credit_card_verification_spec.rb +7 -1
  28. data/spec/unit/braintree/customer_spec.rb +46 -2
  29. data/spec/unit/braintree/risk_data_spec.rb +6 -4
  30. data/spec/unit/braintree/webhook_notification_spec.rb +27 -8
  31. data/spec/unit/braintree/xml_spec.rb +7 -0
  32. data/spec/unit/braintree_spec.rb +1 -0
  33. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ff2f57752c2090e56f153c4b590152f48034845
4
- data.tar.gz: 2ccc9d6fdf906b351347c2c078756a12bd2eb51b
3
+ metadata.gz: 0e9443a409e302f9f139f6b8f43f6357671c4fb4
4
+ data.tar.gz: 58f33b08befa54a85859bda8277d6f556c4c834d
5
5
  SHA512:
6
- metadata.gz: 7836928d15d3627bad6d2fddb76c997a79d180c53cb2786be2a60e0d2fa165d3908f386cbd2b33e7c1651acd4c58586850badfc47c7524a9b36b4acf605c2f18
7
- data.tar.gz: 8eece8b27a133e15d677e95f609ca4bf93d4974a6b716f872c97b37c14d47868999b50bd725cf275519bdf650606da9dedd79814fe389bc39e9f501fc5e19642
6
+ metadata.gz: 2482192edfc3d977132a3fee6c9f1052746ec2fc20ce8b2be5ae02021978cfbb64c1c93248a7f3b27d20da680b7d6f92abdc3ed7d627768887812a1f30ffc84e
7
+ data.tar.gz: f33e4c21098180d53f3839d7f2039c2add7df880b0856e86717b450d3604803d8b92463a0d365657cb23f5749708eb1b23e352e7d84212a8a80e862b5e3f2f5c
data/README.rdoc CHANGED
@@ -88,6 +88,15 @@ The unit specs can be run by anyone on any system, but the integration specs are
88
88
  server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on
89
89
  your system. To run unit tests use rake: <tt>rake test:unit</tt>.
90
90
 
91
+ == Suppress Braintree Logs
92
+
93
+ To suppress logs from Braintree on environments where they are considered noise
94
+ (e.g. test) use the following configuration:
95
+
96
+ logger = Logger.new("/dev/null")
97
+ logger.level = Logger::INFO
98
+ Braintree::Configuration.logger = logger
99
+
91
100
  == License
92
101
 
93
102
  See the LICENSE[https://github.com/braintree/braintree_ruby/blob/master/LICENSE] file for more info.
data/lib/braintree.rb CHANGED
@@ -49,6 +49,7 @@ require "braintree/credit_card_verification_gateway"
49
49
  require "braintree/credit_card_verification_search"
50
50
  require "braintree/customer"
51
51
  require "braintree/customer_gateway"
52
+ require "braintree/granted_payment_instrument_update"
52
53
  require "braintree/customer_search"
53
54
  require "braintree/descriptor"
54
55
  require "braintree/digest"
@@ -201,7 +201,7 @@ module Braintree
201
201
  def server # :nodoc:
202
202
  case @environment
203
203
  when :development, :integration
204
- "localhost"
204
+ ENV['GATEWAY_HOST'] || "localhost"
205
205
  when :production
206
206
  "#{endpoint}.braintreegateway.com"
207
207
  when :qa
@@ -260,7 +260,7 @@ module Braintree
260
260
 
261
261
  def assert_has_access_token_or_keys
262
262
  if (public_key.nil? || private_key.nil?) && access_token.nil?
263
- raise ConfigurationError.new("Braintree::Gateway public_key and private_key are required.")
263
+ raise ConfigurationError.new("Braintree::Gateway access_token or public_key and private_key are required.")
264
264
  end
265
265
  end
266
266
 
@@ -74,6 +74,7 @@ module Braintree
74
74
  def self._create_signature # :nodoc:
75
75
  credit_card_signature = CreditCardGateway._create_signature - [:customer_id]
76
76
  paypal_account_signature = PayPalAccountGateway._create_nested_signature
77
+ paypal_options_shipping_signature = AddressGateway._shared_signature
77
78
  options = [
78
79
  :paypal => [
79
80
  :payee_email,
@@ -81,6 +82,7 @@ module Braintree
81
82
  :custom_field,
82
83
  :description,
83
84
  :amount,
85
+ {:shipping => paypal_options_shipping_signature}
84
86
  ],
85
87
  ]
86
88
  [
@@ -135,8 +137,16 @@ module Braintree
135
137
  credit_card_signature = CreditCardGateway._update_signature - [:customer_id]
136
138
  credit_card_options = credit_card_signature.find { |item| item.respond_to?(:keys) && item.keys == [:options] }
137
139
  credit_card_options[:options] << :update_existing_token
140
+ paypal_options_shipping_signature = AddressGateway._shared_signature
138
141
  options = [
139
- :paypal => [:payee_email, :order_id, :custom_field, :description, :amount],
142
+ :paypal => [
143
+ :payee_email,
144
+ :order_id,
145
+ :custom_field,
146
+ :description,
147
+ :amount,
148
+ {:shipping => paypal_options_shipping_signature}
149
+ ],
140
150
  ]
141
151
  [
142
152
  :company, :email, :fax, :first_name, :id, :last_name, :phone, :website,
@@ -305,6 +305,9 @@ module Braintree
305
305
  CustomerDefaultPaymentMethodCardTypeIsNotAccepted = "81509"
306
306
  CustomerDoesNotHaveCreditCard = "91511"
307
307
  CustomerIdIsInvalid = "91510"
308
+ FailedAuthAdjustmentAllowRetry = "95603"
309
+ FailedAuthAdjustmentHardDecline = "95602"
310
+ FinalAuthSubmitForSettlementForDifferentAmount = "95601"
308
311
  HasAlreadyBeenRefunded = "91512"
309
312
  IdealPaymentNotComplete = "815141"
310
313
  IdealPaymentsCannotBeVaulted = "915150"
@@ -0,0 +1,19 @@
1
+ module Braintree
2
+ class GrantedPaymentInstrumentUpdate
3
+ include BaseModule
4
+
5
+ attr_reader :grant_owner_merchant_id, :grant_recipient_merchant_id, :payment_method_nonce, :token, :updated_fields
6
+
7
+ def initialize(attributes)
8
+ set_instance_variables_from_hash(attributes)
9
+ @payment_method_nonce = attributes[:payment_method_nonce][:nonce]
10
+ end
11
+
12
+ class << self
13
+ protected :new
14
+ def _new(*args) # :nodoc:
15
+ self.new *args
16
+ end
17
+ end
18
+ end
19
+ end
@@ -72,6 +72,8 @@ module Braintree
72
72
  ApplePayCard._new(@gateway, response[:apple_pay_card])
73
73
  elsif response.has_key?(:android_pay_card)
74
74
  AndroidPayCard._new(@gateway, response[:android_pay_card])
75
+ elsif response.has_key?(:venmo_account)
76
+ VenmoAccount._new(@gateway, response[:venmo_account])
75
77
  else
76
78
  UnknownPaymentMethod._new(@gateway, response)
77
79
  end
@@ -148,6 +150,7 @@ module Braintree
148
150
 
149
151
  def self._signature(type) # :nodoc:
150
152
  billing_address_params = AddressGateway._shared_signature
153
+ paypal_options_shipping_signature = AddressGateway._shared_signature
151
154
  options = [
152
155
  :make_default, :verification_merchant_account_id, :verify_card, :venmo_sdk_session,
153
156
  :verification_amount,
@@ -157,6 +160,7 @@ module Braintree
157
160
  :custom_field,
158
161
  :description,
159
162
  :amount,
163
+ {:shipping => paypal_options_shipping_signature}
160
164
  ],
161
165
  ]
162
166
  signature = [
@@ -171,6 +175,8 @@ module Braintree
171
175
  when :create
172
176
  options << :fail_on_duplicate_payment_method
173
177
  signature << :customer_id
178
+ signature << :paypal_refresh_token
179
+ signature << :paypal_vault_without_upgrade
174
180
  when :update
175
181
  billing_address_params << {:options => [:update_existing]}
176
182
  else
@@ -2,14 +2,14 @@ module Braintree
2
2
  class RiskData # :nodoc:
3
3
  include BaseModule
4
4
 
5
- attr_reader :id, :decision
5
+ attr_reader :id, :decision, :device_data_captured
6
6
 
7
7
  def initialize(attributes)
8
8
  set_instance_variables_from_hash attributes unless attributes.nil?
9
9
  end
10
10
 
11
11
  def inspect
12
- attr_order = [:id, :decision]
12
+ attr_order = [:id, :decision, :device_data_captured]
13
13
  formatted_attrs = attr_order.map do |attr|
14
14
  "#{attr}: #{send(attr).inspect}"
15
15
  end
@@ -34,6 +34,7 @@ module Braintree
34
34
  attr_reader :number_of_billing_cycles, :billing_day_of_month
35
35
  attr_reader :add_ons, :discounts
36
36
  attr_reader :descriptor
37
+ attr_reader :description
37
38
  attr_reader :current_billing_cycle
38
39
  attr_reader :updated_at, :created_at
39
40
  attr_reader :status_history
@@ -54,8 +55,8 @@ module Braintree
54
55
  Configuration.gateway.subscription.find(id)
55
56
  end
56
57
 
57
- def self.retry_charge(subscription_id, amount=nil)
58
- Configuration.gateway.transaction.retry_subscription_charge(subscription_id, amount)
58
+ def self.retry_charge(subscription_id, amount=nil, submit_for_settlement=false)
59
+ Configuration.gateway.transaction.retry_subscription_charge(subscription_id, amount, submit_for_settlement)
59
60
  end
60
61
 
61
62
  def self.search(&block)
@@ -67,7 +67,11 @@ module Braintree
67
67
  :trial_duration,
68
68
  :trial_duration_unit,
69
69
  :trial_period,
70
- {:options => [:do_not_inherit_add_ons_or_discounts, :start_immediately]},
70
+ {:options => [
71
+ :do_not_inherit_add_ons_or_discounts,
72
+ :start_immediately,
73
+ {:paypal => [:description]},
74
+ ]},
71
75
  {:descriptor => [:name, :phone, :url]}
72
76
  ] + _add_on_discount_signature
73
77
  end
@@ -85,7 +89,8 @@ module Braintree
85
89
  {:options => [
86
90
  :prorate_charges,
87
91
  :replace_all_add_ons_and_discounts,
88
- :revert_subscription_on_proration_failure
92
+ :revert_subscription_on_proration_failure,
93
+ {:paypal => [:description]},
89
94
  ]},
90
95
  {:descriptor => [:name, :phone, :url]}
91
96
  ] + _add_on_discount_signature
@@ -73,11 +73,14 @@ module Braintree
73
73
  _handle_transaction_response(response)
74
74
  end
75
75
 
76
- def retry_subscription_charge(subscription_id, amount=nil)
76
+ def retry_subscription_charge(subscription_id, amount=nil, submit_for_settlement=false)
77
77
  attributes = {
78
78
  :amount => amount,
79
79
  :subscription_id => subscription_id,
80
- :type => Transaction::Type::Sale
80
+ :type => Transaction::Type::Sale,
81
+ :options => {
82
+ :submit_for_settlement => submit_for_settlement
83
+ }
81
84
  }
82
85
  _do_create "/transactions", :transaction => attributes
83
86
  end
@@ -144,7 +147,7 @@ module Braintree
144
147
  :purchase_order_number, :recurring, :transaction_source, :shipping_address_id, :type, :tax_amount, :tax_exempt,
145
148
  :venmo_sdk_payment_method_code, :device_session_id, :service_fee_amount, :device_data, :fraud_merchant_id,
146
149
  :billing_address_id, :payment_method_nonce, :three_d_secure_token,
147
- :shared_payment_method_token, :shared_billing_address_id, :shared_customer_id, :shared_shipping_address_id,
150
+ :shared_payment_method_token, :shared_billing_address_id, :shared_customer_id, :shared_shipping_address_id, :shared_payment_method_nonce,
148
151
  {:risk_data => [:customer_browser, :customer_ip]},
149
152
  {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number]},
150
153
  {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 78
4
+ Minor = 79
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -38,6 +38,8 @@ module Braintree
38
38
 
39
39
  ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
40
40
  ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
41
+
42
+ GrantedPaymentInstrumentUpdate = "granted_payment_instrument_update"
41
43
  end
42
44
 
43
45
  attr_reader :subscription
@@ -51,6 +53,7 @@ module Braintree
51
53
  attr_reader :ideal_payment
52
54
  attr_reader :connected_merchant_status_transitioned
53
55
  attr_reader :connected_merchant_paypal_status_changed
56
+ attr_reader :granted_payment_instrument_update
54
57
 
55
58
  def self.parse(signature, payload)
56
59
  Configuration.gateway.webhook_notification.parse(signature, payload)
@@ -74,6 +77,7 @@ module Braintree
74
77
  @ideal_payment = Braintree::IdealPayment._new(gateway, @subject[:ideal_payment]) if @subject.has_key?(:ideal_payment)
75
78
  @connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned._new(@subject[:connected_merchant_status_transitioned]) if @subject.has_key?(:connected_merchant_status_transitioned)
76
79
  @connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged._new(@subject[:connected_merchant_paypal_status_changed]) if @subject.has_key?(:connected_merchant_paypal_status_changed)
80
+ @granted_payment_instrument_update = GrantedPaymentInstrumentUpdate._new(@subject[:granted_payment_instrument_update]) if @subject.has_key?(:granted_payment_instrument_update)
77
81
  end
78
82
 
79
83
  def merchant_account
@@ -67,6 +67,8 @@ module Braintree
67
67
  _ideal_payment_complete_sample_xml(id)
68
68
  when Braintree::WebhookNotification::Kind::IdealPaymentFailed
69
69
  _ideal_payment_failed_sample_xml(id)
70
+ when Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentUpdate
71
+ _granted_payment_instrument_update_sample_xml(id)
70
72
  else
71
73
  _subscription_sample_xml(id)
72
74
  end
@@ -603,5 +605,25 @@ module Braintree
603
605
  </ideal-payment>
604
606
  XML
605
607
  end
608
+
609
+ def _granted_payment_instrument_update_sample_xml(id)
610
+
611
+ <<-XML
612
+ <granted-payment-instrument-update>
613
+ <grant-owner-merchant-id>vczo7jqrpwrsi2px</grant-owner-merchant-id>
614
+ <grant-recipient-merchant-id>cf0i8wgarszuy6hc</grant-recipient-merchant-id>
615
+ <payment-method-nonce>
616
+ <nonce>ee257d98-de40-47e8-96b3-a6954ea7a9a4</nonce>
617
+ <consumed type="boolean">false</consumed>
618
+ <locked type="boolean">false</locked>
619
+ </payment-method-nonce>
620
+ <token>abc123z</token>
621
+ <updated-fields type="array">
622
+ <item>expiration-month</item>
623
+ <item>expiration-year</item>
624
+ </updated-fields>
625
+ </granted-payment-instrument-update>
626
+ XML
627
+ end
606
628
  end
607
629
  end
@@ -6,6 +6,7 @@ module Braintree
6
6
  XML_TYPE_NAMES = {
7
7
  "Fixnum" => "integer",
8
8
  "Bignum" => "integer",
9
+ "Integer" => "integer",
9
10
  "TrueClass" => "boolean",
10
11
  "FalseClass" => "boolean",
11
12
  "Date" => "datetime",
@@ -40,7 +40,7 @@ describe Braintree::AddOn do
40
40
 
41
41
  expect do
42
42
  gateway.add_on.all
43
- end.to raise_error(Braintree::ConfigurationError, /public_key and private_key are required/)
43
+ end.to raise_error(Braintree::ConfigurationError, /access_token or public_key and private_key are required/)
44
44
  end
45
45
  end
46
46
  end
@@ -150,6 +150,7 @@ describe Braintree::CreditCard do
150
150
  verification = credit_card.verification
151
151
  verification.risk_data.should respond_to(:id)
152
152
  verification.risk_data.should respond_to(:decision)
153
+ verification.risk_data.should respond_to(:device_data_captured)
153
154
  end
154
155
 
155
156
  it "exposes the gateway rejection reason on verification" do
@@ -1493,6 +1493,15 @@ describe Braintree::Customer do
1493
1493
  :custom_field => "custom merchant field",
1494
1494
  :description => "merchant description",
1495
1495
  :amount => "1.23",
1496
+ :shipping => {
1497
+ :first_name => "first",
1498
+ :last_name => "last",
1499
+ :locality => "Austin",
1500
+ :postal_code => "78729",
1501
+ :street_address => "7700 W Parmer Ln",
1502
+ :country_name => "US",
1503
+ :region => "TX",
1504
+ },
1496
1505
  },
1497
1506
  },
1498
1507
  )
@@ -1530,6 +1539,15 @@ describe Braintree::Customer do
1530
1539
  :custom_field => "custom merchant field",
1531
1540
  :description => "merchant description",
1532
1541
  :amount => "1.23",
1542
+ :shipping => {
1543
+ :first_name => "first",
1544
+ :last_name => "last",
1545
+ :locality => "Austin",
1546
+ :postal_code => "78729",
1547
+ :street_address => "7700 W Parmer Ln",
1548
+ :country_name => "US",
1549
+ :region => "TX",
1550
+ },
1533
1551
  },
1534
1552
  },
1535
1553
  )
@@ -113,6 +113,33 @@ describe Braintree::MerchantAccount do
113
113
  result.merchant_accounts.first.status.should == "active"
114
114
  result.merchant_accounts.first.default.should == true
115
115
  end
116
+
117
+ it "returns all merchant accounts for read_only scoped grants" do
118
+ gateway = Braintree::Gateway.new(
119
+ :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
120
+ :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
121
+ :logger => Logger.new("/dev/null")
122
+ )
123
+
124
+ code = Braintree::OAuthTestHelper.create_grant(gateway, {
125
+ :merchant_public_id => "integration_merchant_id",
126
+ :scope => "read_only"
127
+ })
128
+
129
+ result = gateway.oauth.create_token_from_code(
130
+ :code => code,
131
+ :scope => "read_only"
132
+ )
133
+
134
+ gateway = Braintree::Gateway.new(
135
+ :access_token => result.credentials.access_token,
136
+ :logger => Logger.new("/dev/null")
137
+ )
138
+
139
+ result = gateway.merchant_account.all
140
+ result.should be_success
141
+ result.merchant_accounts.count.should > 20
142
+ end
116
143
  end
117
144
 
118
145
  describe "create" do
@@ -113,6 +113,7 @@ describe "OAuth" do
113
113
  :scope => "read_write",
114
114
  :state => "baz_state",
115
115
  :landing_page => "signup",
116
+ :login_only => false,
116
117
  :user => {
117
118
  :country => "USA",
118
119
  :email => "foo@example.com",
@@ -159,6 +160,7 @@ describe "OAuth" do
159
160
  query["scope"].should == ["read_write"]
160
161
  query["state"].should == ["baz_state"]
161
162
  query["landing_page"].should == ["signup"]
163
+ query["login_only"].should == ["false"]
162
164
 
163
165
  query["user[country]"].should == ["USA"]
164
166
  query["business[name]"].should == ["14 Ladders"]
@@ -85,6 +85,7 @@ describe Braintree::PaymentMethod do
85
85
  apple_pay_card = result.payment_method
86
86
  apple_pay_card.should be_a(Braintree::ApplePayCard)
87
87
  apple_pay_card.should_not be_nil
88
+ apple_pay_card.bin.should_not be_nil
88
89
  apple_pay_card.token.should == token
89
90
  apple_pay_card.card_type.should == Braintree::ApplePayCard::CardType::AmEx
90
91
  apple_pay_card.payment_instrument_name.should == "AmEx 41002"
@@ -552,6 +553,15 @@ describe Braintree::PaymentMethod do
552
553
  :custom_field => "custom merchant field",
553
554
  :description => "merchant description",
554
555
  :amount => "1.23",
556
+ :shipping => {
557
+ :first_name => "first",
558
+ :last_name => "last",
559
+ :locality => "Austin",
560
+ :postal_code => "78729",
561
+ :street_address => "7700 W Parmer Ln",
562
+ :country_name => "US",
563
+ :region => "TX",
564
+ },
555
565
  },
556
566
  },
557
567
  )
@@ -565,6 +575,41 @@ describe Braintree::PaymentMethod do
565
575
  found_paypal_account.should_not be_nil
566
576
  end
567
577
 
578
+ it "creates a billing agreement payment method from a refresh token" do
579
+ customer = Braintree::Customer.create.customer
580
+ result = Braintree::PaymentMethod.create(
581
+ :customer_id => customer.id,
582
+ :paypal_refresh_token => "some_future_payment_token",
583
+ )
584
+
585
+ result.should be_success
586
+ result.payment_method.should be_a(Braintree::PayPalAccount)
587
+ result.payment_method.billing_agreement_id.should eq("B_FAKE_ID")
588
+ token = result.payment_method.token
589
+
590
+ found_paypal_account = Braintree::PayPalAccount.find(token)
591
+ found_paypal_account.should_not be_nil
592
+ found_paypal_account.billing_agreement_id.should eq("B_FAKE_ID")
593
+ end
594
+
595
+ it "creates a billing agreement payment method from a refresh token without upgrading" do
596
+ customer = Braintree::Customer.create.customer
597
+ result = Braintree::PaymentMethod.create(
598
+ :customer_id => customer.id,
599
+ :paypal_refresh_token => "some_future_payment_token",
600
+ :paypal_vault_without_upgrade => true,
601
+ )
602
+
603
+ result.should be_success
604
+ result.payment_method.should be_a(Braintree::PayPalAccount)
605
+ result.payment_method.billing_agreement_id.should be_nil
606
+ token = result.payment_method.token
607
+
608
+ found_paypal_account = Braintree::PayPalAccount.find(token)
609
+ found_paypal_account.should_not be_nil
610
+ found_paypal_account.billing_agreement_id.should be_nil
611
+ end
612
+
568
613
  it "does not create a payment method from an unvalidated onetime paypal account nonce" do
569
614
  customer = Braintree::Customer.create.customer
570
615
  nonce = nonce_for_paypal_account(:access_token => "PAYPAL_ACCESS_TOKEN")
@@ -792,6 +837,30 @@ describe Braintree::PaymentMethod do
792
837
  end
793
838
  end
794
839
 
840
+ context "venmo accounts" do
841
+ it "finds the payment method with the given token" do
842
+ customer = Braintree::Customer.create!
843
+ payment_method_token = "PAYMENT_METHOD_TOKEN_#{rand(36**3).to_s(36)}"
844
+ result = Braintree::PaymentMethod.create(
845
+ :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
846
+ :customer_id => customer.id,
847
+ :token => payment_method_token
848
+ )
849
+ result.should be_success
850
+
851
+ venmo_account = Braintree::PaymentMethod.find(payment_method_token)
852
+ venmo_account.should be_a(Braintree::VenmoAccount)
853
+ venmo_account.should_not be_nil
854
+ venmo_account.token.should == payment_method_token
855
+ venmo_account.default.should == true
856
+ venmo_account.image_url.should =~ /venmo/
857
+ venmo_account.username.should == 'venmojoe'
858
+ venmo_account.venmo_user_id.should == 'Venmo-Joe-1'
859
+ venmo_account.source_description.should == "Venmo Account: venmojoe"
860
+ venmo_account.customer_id.should == customer.id
861
+ end
862
+ end
863
+
795
864
  context "android pay cards" do
796
865
  it "finds the proxy card payment method with the given token" do
797
866
  customer = Braintree::Customer.create!
@@ -113,6 +113,31 @@ describe Braintree::Subscription do
113
113
  transaction.paypal_details.payer_email.should == "payer@example.com"
114
114
  end
115
115
 
116
+ it "creates a subscription when given a paypal description" do
117
+ customer = Braintree::Customer.create!
118
+ payment_method_result = Braintree::PaymentMethod.create(
119
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
120
+ :customer_id => customer.id
121
+ )
122
+
123
+ result = Braintree::Subscription.create(
124
+ :payment_method_token => payment_method_result.payment_method.token,
125
+ :plan_id => SpecHelper::TriallessPlan[:id],
126
+ :options => {
127
+ :paypal => {
128
+ :description => "A great product",
129
+ },
130
+ },
131
+ )
132
+
133
+ result.should be_success
134
+ subscription = result.subscription
135
+ subscription.description.should == "A great product"
136
+ transaction = subscription.transactions[0]
137
+ transaction.paypal_details.payer_email.should == "payer@example.com"
138
+ transaction.paypal_details.description.should == "A great product"
139
+ end
140
+
116
141
  it "returns an error if the payment_method_nonce hasn't been vaulted" do
117
142
  customer = Braintree::Customer.create!
118
143
  result = Braintree::Subscription.create(
@@ -747,7 +772,7 @@ describe Braintree::Subscription do
747
772
  result.subscription.payment_method_token.should_not == @credit_card.token
748
773
  end
749
774
 
750
- it "allows chaning the descriptors" do
775
+ it "allows changing the descriptors" do
751
776
  result = Braintree::Subscription.update(@subscription.id,
752
777
  :descriptor => {
753
778
  :name => 'aaa*1234',
@@ -762,6 +787,31 @@ describe Braintree::Subscription do
762
787
  result.subscription.descriptor.url.should == 'ebay.com'
763
788
  end
764
789
 
790
+ it "allows changing the paypal description" do
791
+ customer = Braintree::Customer.create!
792
+ payment_method = Braintree::PaymentMethod.create(
793
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
794
+ :customer_id => customer.id
795
+ ).payment_method
796
+
797
+ subscription = Braintree::Subscription.create(
798
+ :payment_method_token => payment_method.token,
799
+ :plan_id => SpecHelper::TriallessPlan[:id]
800
+ ).subscription
801
+
802
+ result = Braintree::Subscription.update(
803
+ subscription.id,
804
+ :options => {
805
+ :paypal => {
806
+ :description => 'A great product',
807
+ },
808
+ },
809
+ )
810
+
811
+ result.success?.should == true
812
+ result.subscription.description.should == 'A great product'
813
+ end
814
+
765
815
  context "when successful" do
766
816
  it "returns a success response with the updated subscription if valid" do
767
817
  new_id = rand(36**9).to_s(36)
@@ -1653,5 +1703,41 @@ describe Braintree::Subscription do
1653
1703
  transaction.type.should == Braintree::Transaction::Type::Sale
1654
1704
  transaction.status.should == Braintree::Transaction::Status::Authorized
1655
1705
  end
1706
+
1707
+ it "is successful with subscription id and submit_for_settlement" do
1708
+ subscription = Braintree::Subscription.create(
1709
+ :payment_method_token => @credit_card.token,
1710
+ :plan_id => SpecHelper::TriallessPlan[:id]
1711
+ ).subscription
1712
+ SpecHelper.make_past_due(subscription)
1713
+
1714
+ result = Braintree::Subscription.retry_charge(subscription.id, Braintree::Test::TransactionAmounts::Authorize, true)
1715
+
1716
+ result.success?.should == true
1717
+ transaction = result.transaction
1718
+
1719
+ transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
1720
+ transaction.processor_authorization_code.should_not be_nil
1721
+ transaction.type.should == Braintree::Transaction::Type::Sale
1722
+ transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
1723
+ end
1724
+
1725
+ it "is successful with subscription id, amount and submit_for_settlement" do
1726
+ subscription = Braintree::Subscription.create(
1727
+ :payment_method_token => @credit_card.token,
1728
+ :plan_id => SpecHelper::TriallessPlan[:id]
1729
+ ).subscription
1730
+ SpecHelper.make_past_due(subscription)
1731
+
1732
+ result = Braintree::Subscription.retry_charge(subscription.id, Braintree::Test::TransactionAmounts::Authorize, true)
1733
+
1734
+ result.success?.should == true
1735
+ transaction = result.transaction
1736
+
1737
+ transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
1738
+ transaction.processor_authorization_code.should_not be_nil
1739
+ transaction.type.should == Braintree::Transaction::Type::Sale
1740
+ transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
1741
+ end
1656
1742
  end
1657
1743
  end
@@ -6,13 +6,13 @@ describe Braintree::TestTransaction do
6
6
  it "changes transaction status to settled" do
7
7
  sale_result = Braintree::Transaction.sale(
8
8
  :amount => "100",
9
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
9
+ :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa,
10
10
  :options => {
11
11
  :submit_for_settlement => true
12
12
  }
13
13
  )
14
14
  sale_result.success?.should == true
15
- sale_result.transaction.status.should == Braintree::Transaction::Status::Settling
15
+ sale_result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
16
16
 
17
17
  settle_result = Braintree::TestTransaction.settle(sale_result.transaction.id)
18
18
  settle_result.transaction.status.should == Braintree::Transaction::Status::Settled
@@ -22,13 +22,13 @@ describe Braintree::TestTransaction do
22
22
  it "changes transaction status to settlement_confirmed" do
23
23
  sale_result = Braintree::Transaction.sale(
24
24
  :amount => "100",
25
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
25
+ :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa,
26
26
  :options => {
27
27
  :submit_for_settlement => true
28
28
  }
29
29
  )
30
30
  sale_result.success?.should == true
31
- sale_result.transaction.status.should == Braintree::Transaction::Status::Settling
31
+ sale_result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
32
32
 
33
33
  settle_result = Braintree::TestTransaction.settlement_confirm(sale_result.transaction.id)
34
34
  settle_result.transaction.status.should == Braintree::Transaction::Status::SettlementConfirmed
@@ -38,13 +38,13 @@ describe Braintree::TestTransaction do
38
38
  it "changes transaction status to settlement_declined" do
39
39
  sale_result = Braintree::Transaction.sale(
40
40
  :amount => "100",
41
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
41
+ :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa,
42
42
  :options => {
43
43
  :submit_for_settlement => true
44
44
  }
45
45
  )
46
46
  sale_result.success?.should == true
47
- sale_result.transaction.status.should == Braintree::Transaction::Status::Settling
47
+ sale_result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
48
48
 
49
49
  settle_result = Braintree::TestTransaction.settlement_decline(sale_result.transaction.id)
50
50
  settle_result.transaction.status.should == Braintree::Transaction::Status::SettlementDeclined
@@ -54,13 +54,13 @@ describe Braintree::TestTransaction do
54
54
  it "changes transaction status to settlement_pending" do
55
55
  sale_result = Braintree::Transaction.sale(
56
56
  :amount => "100",
57
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
57
+ :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa,
58
58
  :options => {
59
59
  :submit_for_settlement => true
60
60
  }
61
61
  )
62
62
  sale_result.success?.should == true
63
- sale_result.transaction.status.should == Braintree::Transaction::Status::Settling
63
+ sale_result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
64
64
 
65
65
  settle_result = Braintree::TestTransaction.settlement_pending(sale_result.transaction.id)
66
66
  settle_result.transaction.status.should == Braintree::Transaction::Status::SettlementPending
@@ -70,7 +70,7 @@ describe Braintree::TestTransaction do
70
70
  it "returns a validation error when invalid transition is specified" do
71
71
  sale_result = Braintree::Transaction.sale(
72
72
  :amount => "100",
73
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
73
+ :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa
74
74
  )
75
75
  sale_result.success?.should == true
76
76
 
@@ -110,7 +110,7 @@ describe Braintree::TestTransaction do
110
110
 
111
111
  sale_result = transaction_gateway.sale(
112
112
  :amount => "100",
113
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
113
+ :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa
114
114
  )
115
115
  testing_gateway.settle(sale_result.transaction.id)
116
116
  end
@@ -123,7 +123,7 @@ describe Braintree::Transaction do
123
123
 
124
124
  describe "self.create" do
125
125
  describe "risk data" do
126
- it "returns decision and id" do
126
+ it "returns decision, device_data_captured and id" do
127
127
  result = Braintree::Transaction.create(
128
128
  :type => "sale",
129
129
  :amount => 1_00,
@@ -135,6 +135,7 @@ describe Braintree::Transaction do
135
135
  result.transaction.risk_data.should be_a(Braintree::RiskData)
136
136
  result.transaction.risk_data.should respond_to(:id)
137
137
  result.transaction.risk_data.should respond_to(:decision)
138
+ result.transaction.risk_data.should respond_to(:device_data_captured)
138
139
  end
139
140
  end
140
141
 
@@ -1943,7 +1944,7 @@ describe Braintree::Transaction do
1943
1944
  }
1944
1945
  )
1945
1946
  result.success?.should == true
1946
- result.transaction.status.should == Braintree::Transaction::Status::Settling
1947
+ result.transaction.status.should == Braintree::Transaction::Status::Settled
1947
1948
  end
1948
1949
  end
1949
1950
 
@@ -4622,50 +4623,18 @@ describe Braintree::Transaction do
4622
4623
  result.errors.for(:transaction).for(:paypal_account).first.code.should == Braintree::ErrorCodes::PayPalAccount::IncompletePayPalAccount
4623
4624
  end
4624
4625
  end
4625
-
4626
- context "inline capture" do
4627
- it "includes processor_settlement_response_code and processor_settlement_response_text for settlement declined transactions" do
4628
- result = Braintree::Transaction.sale(
4629
- :amount => "100",
4630
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
4631
- :options => { :submit_for_settlement => true }
4632
- )
4633
-
4634
- result.should be_success
4635
- Braintree::Configuration.gateway.testing.settlement_decline(result.transaction.id)
4636
-
4637
- settlement_declined_transaction = Braintree::Transaction.find(result.transaction.id)
4638
- settlement_declined_transaction.processor_settlement_response_code.should == "4001"
4639
- settlement_declined_transaction.processor_settlement_response_text.should == "Settlement Declined"
4640
- end
4641
-
4642
- it "includes processor_settlement_response_code and processor_settlement_response_text for settlement pending transactions" do
4643
- result = Braintree::Transaction.sale(
4644
- :amount => "100",
4645
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
4646
- :options => { :submit_for_settlement => true }
4647
- )
4648
-
4649
- result.should be_success
4650
- Braintree::Configuration.gateway.testing.settlement_pending(result.transaction.id)
4651
-
4652
- settlement_declined_transaction = Braintree::Transaction.find(result.transaction.id)
4653
- settlement_declined_transaction.processor_settlement_response_code.should == "4002"
4654
- settlement_declined_transaction.processor_settlement_response_text.should == "Settlement Pending"
4655
- end
4656
- end
4657
4626
  end
4658
4627
 
4659
4628
  context "shared payment method" do
4660
4629
  before(:each) do
4661
- partner_merchant_gateway = Braintree::Gateway.new(
4630
+ @partner_merchant_gateway = Braintree::Gateway.new(
4662
4631
  :merchant_id => "integration_merchant_public_id",
4663
4632
  :public_key => "oauth_app_partner_user_public_key",
4664
4633
  :private_key => "oauth_app_partner_user_private_key",
4665
4634
  :environment => Braintree::Configuration.environment,
4666
4635
  :logger => Logger.new("/dev/null")
4667
4636
  )
4668
- @customer = partner_merchant_gateway.customer.create(
4637
+ @customer = @partner_merchant_gateway.customer.create(
4669
4638
  :first_name => "Joe",
4670
4639
  :last_name => "Brown",
4671
4640
  :company => "ExampleCo",
@@ -4674,12 +4643,12 @@ describe Braintree::Transaction do
4674
4643
  :fax => "614.555.5678",
4675
4644
  :website => "www.example.com"
4676
4645
  ).customer
4677
- @address = partner_merchant_gateway.address.create(
4646
+ @address = @partner_merchant_gateway.address.create(
4678
4647
  :customer_id => @customer.id,
4679
4648
  :first_name => "Testy",
4680
4649
  :last_name => "McTesterson"
4681
4650
  ).address
4682
- @credit_card = partner_merchant_gateway.credit_card.create(
4651
+ @credit_card = @partner_merchant_gateway.credit_card.create(
4683
4652
  :customer_id => @customer.id,
4684
4653
  :cardholder_name => "Adam Davis",
4685
4654
  :number => Braintree::Test::CreditCardNumbers::Visa,
@@ -4705,6 +4674,7 @@ describe Braintree::Transaction do
4705
4674
  :access_token => access_token,
4706
4675
  :logger => Logger.new("/dev/null")
4707
4676
  )
4677
+
4708
4678
  end
4709
4679
 
4710
4680
  it "oauth app details are returned on transaction created via nonce granting" do
@@ -4759,5 +4729,22 @@ describe Braintree::Transaction do
4759
4729
  result.transaction.facilitator_details.oauth_application_client_id.should == "client_id$#{Braintree::Configuration.environment}$integration_client_id"
4760
4730
  result.transaction.facilitator_details.oauth_application_name.should == "PseudoShop"
4761
4731
  end
4732
+
4733
+ it "facilitated details are returned on transaction created via a shared_payment_method_nonce" do
4734
+ shared_nonce = @partner_merchant_gateway.payment_method_nonce.create(
4735
+ @credit_card.token
4736
+ ).payment_method_nonce.nonce
4737
+
4738
+ result = @granting_gateway.transaction.sale(
4739
+ :shared_payment_method_nonce => shared_nonce,
4740
+ :amount => Braintree::Test::TransactionAmounts::Authorize
4741
+ )
4742
+ result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
4743
+ result.transaction.facilitated_details.merchant_name.should == "14ladders"
4744
+ result.transaction.facilitated_details.payment_method_nonce.should == nil
4745
+ result.transaction.facilitator_details.should_not == nil
4746
+ result.transaction.facilitator_details.oauth_application_client_id.should == "client_id$#{Braintree::Configuration.environment}$integration_client_id"
4747
+ result.transaction.facilitator_details.oauth_application_name.should == "PseudoShop"
4748
+ end
4762
4749
  end
4763
4750
  end
@@ -307,9 +307,18 @@ describe Braintree::Configuration do
307
307
  end
308
308
 
309
309
  describe "server" do
310
- it "is localhost for development" do
310
+ it "is localhost or GATEWAY_HOST environment variable for development" do
311
311
  Braintree::Configuration.environment = :development
312
- Braintree::Configuration.instantiate.server.should == "localhost"
312
+ old_gateway_url = ENV['GATEWAY_HOST']
313
+ begin
314
+ ENV['GATEWAY_HOST'] = nil
315
+ Braintree::Configuration.instantiate.server.should == "localhost"
316
+
317
+ ENV['GATEWAY_HOST'] = 'gateway'
318
+ Braintree::Configuration.instantiate.server.should == 'gateway'
319
+ ensure
320
+ ENV['GATEWAY_HOST'] = old_gateway_url
321
+ end
313
322
  end
314
323
 
315
324
  it "is api.braintreegateway.com for production" do
@@ -105,9 +105,15 @@ describe Braintree::CreditCardVerification do
105
105
 
106
106
  describe "risk_data" do
107
107
  it "initializes a RiskData object" do
108
- verification = Braintree::CreditCardVerification._new(:risk_data => {:id => "123", :decision => "WOO YOU WON $1000 dollars" })
108
+ verification = Braintree::CreditCardVerification._new(:risk_data => {
109
+ :id => "123",
110
+ :decision => "WOO YOU WON $1000 dollars",
111
+ :device_data_captured => true
112
+ })
113
+
109
114
  verification.risk_data.id.should == "123"
110
115
  verification.risk_data.decision.should == "WOO YOU WON $1000 dollars"
116
+ verification.risk_data.device_data_captured.should == true
111
117
  end
112
118
 
113
119
  it "handles a nil risk_data" do
@@ -123,7 +123,29 @@ describe Braintree::Customer do
123
123
  :billing_agreement_id,
124
124
  {:options => [:make_default]},
125
125
  ]},
126
- {:options => [:paypal => [:payee_email, :order_id, :custom_field, :description, :amount]]},
126
+ {:options =>
127
+ [:paypal => [
128
+ :payee_email,
129
+ :order_id,
130
+ :custom_field,
131
+ :description,
132
+ :amount,
133
+ {:shipping => [
134
+ :company,
135
+ :country_code_alpha2,
136
+ :country_code_alpha3,
137
+ :country_code_numeric,
138
+ :country_name,
139
+ :extended_address,
140
+ :first_name,
141
+ :last_name,
142
+ :locality,
143
+ :postal_code,
144
+ :region,
145
+ :street_address,
146
+ ]}
147
+ ]]
148
+ },
127
149
  {:custom_fields => :_any_key_}
128
150
  ]
129
151
  end
@@ -182,7 +204,29 @@ describe Braintree::Customer do
182
204
  {:options => [:update_existing]}
183
205
  ]}
184
206
  ]},
185
- {:options => [:paypal => [:payee_email, :order_id, :custom_field, :description, :amount]]},
207
+ {:options =>
208
+ [:paypal => [
209
+ :payee_email,
210
+ :order_id,
211
+ :custom_field,
212
+ :description,
213
+ :amount,
214
+ {:shipping => [
215
+ :company,
216
+ :country_code_alpha2,
217
+ :country_code_alpha3,
218
+ :country_code_numeric,
219
+ :country_name,
220
+ :extended_address,
221
+ :first_name,
222
+ :last_name,
223
+ :locality,
224
+ :postal_code,
225
+ :region,
226
+ :street_address,
227
+ ]}
228
+ ]]
229
+ },
186
230
  {:custom_fields => :_any_key_}
187
231
  ]
188
232
  end
@@ -2,10 +2,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Braintree::RiskData do
4
4
  describe "#initialize" do
5
- it "sets id and decision" do
6
- risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS")
5
+ it "sets id, decision and device_data_captured" do
6
+ risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true)
7
7
  risk_data.id.should == "123"
8
8
  risk_data.decision.should == "YOU WON $1000 DOLLARS"
9
+ risk_data.device_data_captured.should be_truthy
9
10
  end
10
11
  end
11
12
 
@@ -13,9 +14,10 @@ describe Braintree::RiskData do
13
14
  it "prints the attributes" do
14
15
  details = Braintree::RiskData.new(
15
16
  :id => "123",
16
- :decision => "YOU WON $1000 DOLLARS"
17
+ :decision => "YOU WON $1000 DOLLARS",
18
+ :device_data_captured => true
17
19
  )
18
- details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS">)
20
+ details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", device_data_captured: true>)
19
21
  end
20
22
  end
21
23
  end
@@ -367,16 +367,35 @@ describe Braintree::WebhookNotification do
367
367
 
368
368
  context "account_updater_daily_report" do
369
369
  it "builds a sample notification for an account_updater_daily_report webhook" do
370
- sample_notification = Braintree::WebhookTesting.sample_notification(
371
- Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport,
372
- "my_id"
373
- )
370
+ sample_notification = Braintree::WebhookTesting.sample_notification(
371
+ Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport,
372
+ "my_id"
373
+ )
374
374
 
375
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
375
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
376
376
 
377
- notification.kind.should == Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport
378
- notification.account_updater_daily_report.report_url.should == "link-to-csv-report"
379
- notification.account_updater_daily_report.report_date.should == Date.parse("2016-01-14")
377
+ notification.kind.should == Braintree::WebhookNotification::Kind::AccountUpdaterDailyReport
378
+ notification.account_updater_daily_report.report_url.should == "link-to-csv-report"
379
+ notification.account_updater_daily_report.report_date.should == Date.parse("2016-01-14")
380
+ end
381
+ end
382
+
383
+ context "granted_payment_instrument_update" do
384
+ it "builds a sample notification for a granted_payment_instrument_update webhook" do
385
+ sample_notification = Braintree::WebhookTesting.sample_notification(
386
+ Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentUpdate,
387
+ "my_id"
388
+ )
389
+
390
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
391
+ update = notification.granted_payment_instrument_update
392
+
393
+ notification.kind.should == Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentUpdate
394
+ update.grant_owner_merchant_id.should == 'vczo7jqrpwrsi2px'
395
+ update.grant_recipient_merchant_id.should == 'cf0i8wgarszuy6hc'
396
+ update.payment_method_nonce.should == 'ee257d98-de40-47e8-96b3-a6954ea7a9a4'
397
+ update.token.should == 'abc123z'
398
+ update.updated_fields.should == ['expiration-month', 'expiration-year']
380
399
  end
381
400
  end
382
401
 
@@ -99,6 +99,13 @@ describe Braintree::Xml do
99
99
  verify_to_xml_and_back hash
100
100
  end
101
101
 
102
+ context "Integer" do
103
+ it "works for integers" do
104
+ hash = { :root => {:foo => 1 } }
105
+ Braintree::Xml.hash_to_xml(hash).should include("<foo type=\"integer\">1</foo>")
106
+ end
107
+ end
108
+
102
109
  context "BigDecimal" do
103
110
  it "works for BigDecimals" do
104
111
  hash = {:root => {:foo => BigDecimal.new("123.45")}}
@@ -6,6 +6,7 @@ describe Braintree do
6
6
  braintree_file = "#{lib_dir}/braintree.rb"
7
7
  File.exist?(braintree_file).should == true
8
8
  output = `ruby -r rubygems -I #{lib_dir} -e 'load #{braintree_file.inspect}; load #{braintree_file.inspect}' 2>&1`
9
+ output = output.gsub(/^.*warning: constant ::Fixnum is deprecated.*\n/, "")
9
10
  output.should == ""
10
11
  end
11
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.78.0
4
+ version: 2.79.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -88,6 +88,7 @@ files:
88
88
  - lib/braintree/facilitated_details.rb
89
89
  - lib/braintree/facilitator_details.rb
90
90
  - lib/braintree/gateway.rb
91
+ - lib/braintree/granted_payment_instrument_update.rb
91
92
  - lib/braintree/http.rb
92
93
  - lib/braintree/ideal_payment.rb
93
94
  - lib/braintree/ideal_payment_gateway.rb
@@ -292,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
293
  version: '0'
293
294
  requirements: []
294
295
  rubyforge_project: braintree
295
- rubygems_version: 2.6.12
296
+ rubygems_version: 2.4.5.1
296
297
  signing_key:
297
298
  specification_version: 4
298
299
  summary: Braintree Gateway Ruby Client Library