braintree 2.88.0 → 2.89.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c971a0bacc5df30ce7c762b37047e83bb86b6036
4
- data.tar.gz: 8adfabbcb3d4855170eb3c2e66d6ecd5b8e48a7d
3
+ metadata.gz: 1dbdc2a3360539354ac8dee567e437609b10047e
4
+ data.tar.gz: b79dfe5dc9dc997325c094d76e35fe8e952cfe54
5
5
  SHA512:
6
- metadata.gz: 78286324c7e94afc9281390b7ae4f465a34e823d97e7bdb268ebd899becd492db89ba0695ccf99f07bdf3c3fb854dffb26a1e85ba8a314e1808ec3f1096ac378
7
- data.tar.gz: ca5421117f2d7e2d324cf65651071ff1fb3e26eecfeb175a2d8a6efc08a8cb95188cfcdd3b6270a023bc76f76bd0588df2033ffa6051ba3264c48c36387f78d9
6
+ metadata.gz: 2997abeff62b6067f00979a8fb13d215f7716dcdd994f3451e77c09d0ecf2649dc267e3dfaadc165e6e36c54a915be58fe1b6ad1930ec641dffe8b3f72232e32
7
+ data.tar.gz: 6f0d883162764a99a777d84c33c9ff04a41c175a1acde9ec10738e10fde37ee9e46a66dd99882b5219cbd2153125362eb0aef641231d4766131aaac9f777142d
@@ -123,6 +123,9 @@ module Braintree
123
123
  @environment = parser.environment
124
124
  elsif options[:access_token]
125
125
  parser.parse_access_token(options[:access_token])
126
+
127
+ _check_for_mixed_environment(options[:environment], parser.environment)
128
+
126
129
  @access_token = parser.access_token
127
130
  @environment = parser.environment
128
131
  @merchant_id = parser.merchant_id
@@ -145,6 +148,12 @@ module Braintree
145
148
  end
146
149
  end
147
150
 
151
+ def _check_for_mixed_environment(options_environment, token_environment)
152
+ if options_environment && options_environment.to_sym != token_environment.to_sym
153
+ warn "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used."
154
+ end
155
+ end
156
+
148
157
  def api_version # :nodoc:
149
158
  API_VERSION
150
159
  end
@@ -6,6 +6,8 @@ module Braintree
6
6
  attr_reader :merchant_public_id
7
7
  attr_reader :oauth_application_client_id
8
8
 
9
+ alias_method :merchant_id, :merchant_public_id
10
+
9
11
  def initialize(attributes)
10
12
  set_instance_variables_from_hash(attributes)
11
13
  end
@@ -6,6 +6,8 @@ module Braintree
6
6
  attr_reader :oauth_application_client_id
7
7
  attr_reader :status
8
8
 
9
+ alias_method :merchant_id, :merchant_public_id
10
+
9
11
  def initialize(attributes)
10
12
  set_instance_variables_from_hash(attributes)
11
13
  end
@@ -2,8 +2,14 @@ module Braintree
2
2
  class Disbursement
3
3
  include BaseModule
4
4
 
5
+ module Types
6
+ Credit = "credit"
7
+ Debit = "debit"
8
+ end
9
+
5
10
  attr_reader :amount
6
11
  attr_reader :disbursement_date
12
+ attr_reader :disbursement_type
7
13
  attr_reader :exception_message
8
14
  attr_reader :follow_up_action
9
15
  attr_reader :id
@@ -35,6 +41,14 @@ module Braintree
35
41
  "#<#{self.class} #{nice_attributes.join(', ')}>"
36
42
  end
37
43
 
44
+ def debit?
45
+ disbursement_type == Types::Debit
46
+ end
47
+
48
+ def credit?
49
+ disbursement_type == Types::Credit
50
+ end
51
+
38
52
  class << self
39
53
  protected :new
40
54
  def _new(*args) # :nodoc:
@@ -406,6 +406,7 @@ module Braintree
406
406
  TypeIsInvalid = "91523"
407
407
  TypeIsRequired = "91524"
408
408
  UnsupportedVoiceAuthorization = "91539"
409
+ TransactionSourceIsInvalid = "915133"
409
410
 
410
411
  module Options
411
412
  SubmitForSettlementIsRequiredForCloning = "91544"
@@ -9,6 +9,7 @@ module Braintree
9
9
  attr_reader :debug_id
10
10
  attr_reader :description
11
11
  attr_reader :image_url
12
+ attr_reader :payee_id
12
13
  attr_reader :payee_email
13
14
  attr_reader :payer_email
14
15
  attr_reader :payer_first_name
@@ -215,11 +215,12 @@ module Braintree
215
215
  :add_billing_address_to_payment_method,
216
216
  :store_shipping_address_in_vault,
217
217
  :venmo_sdk_session,
218
+ :payee_id,
218
219
  :payee_email,
219
220
  :skip_advanced_fraud_checking,
220
221
  :skip_avs,
221
222
  :skip_cvv,
222
- {:paypal => [:custom_field, :payee_email, :description, {:supplementary_data => :_any_key_}]},
223
+ {:paypal => [:custom_field, :payee_id, :payee_email, :description, {:supplementary_data => :_any_key_}]},
223
224
  {:three_d_secure => [:required]},
224
225
  {:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
225
226
  {:venmo => [:profile_id]}
@@ -227,7 +228,7 @@ module Braintree
227
228
  },
228
229
  {:custom_fields => :_any_key_},
229
230
  {:descriptor => [:name, :phone, :url]},
230
- {:paypal_account => [:email, :token, :paypal_data, :payee_email]},
231
+ {:paypal_account => [:email, :token, :paypal_data, :payee_id, :payee_email]},
231
232
  {:industry => [:industry_type, {:data => [:folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate]}]},
232
233
  {:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
233
234
  {:android_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]}
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 88
4
+ Minor = 89
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -30,13 +30,13 @@ module Braintree
30
30
  PartnerMerchantConnected = "partner_merchant_connected"
31
31
  PartnerMerchantDisconnected = "partner_merchant_disconnected"
32
32
  PartnerMerchantDeclined = "partner_merchant_declined"
33
- OAuthAccessRevoked = "oauth_access_revoked"
34
33
 
35
34
  AccountUpdaterDailyReport = "account_updater_daily_report"
36
35
 
37
36
  IdealPaymentComplete = "ideal_payment_complete"
38
37
  IdealPaymentFailed = "ideal_payment_failed"
39
38
 
39
+ OAuthAccessRevoked = "oauth_access_revoked"
40
40
  ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
41
41
  ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
42
42
 
@@ -153,14 +153,6 @@ module Braintree
153
153
  XML
154
154
  end
155
155
 
156
- def _oauth_access_revoked_sample_xml(id)
157
- <<-XML
158
- <oauth-application-revocation>
159
- <merchant-id>abc123</merchant-id>
160
- </oauth-application-revocation>
161
- XML
162
- end
163
-
164
156
  def _merchant_account_approved_sample_xml(id)
165
157
 
166
158
  <<-XML
@@ -587,6 +579,15 @@ module Braintree
587
579
  XML
588
580
  end
589
581
 
582
+ def _oauth_access_revoked_sample_xml(id)
583
+ <<-XML
584
+ <oauth-application-revocation>
585
+ <merchant-id>#{id}</merchant-id>
586
+ <oauth-application-client-id>oauth_application_client_id</oauth-application-client-id>
587
+ </oauth-application-revocation>
588
+ XML
589
+ end
590
+
590
591
  def _ideal_payment_complete_sample_xml(id)
591
592
 
592
593
  <<-XML
@@ -1046,6 +1046,20 @@ describe Braintree::Transaction do
1046
1046
  end
1047
1047
 
1048
1048
  context "transaction_source" do
1049
+ it "marks a transactions as recurring_first" do
1050
+ result = Braintree::Transaction.create(
1051
+ :type => "sale",
1052
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1053
+ :credit_card => {
1054
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1055
+ :expiration_date => "12/12",
1056
+ },
1057
+ :transaction_source => "recurring_first"
1058
+ )
1059
+ result.success?.should == true
1060
+ result.transaction.recurring.should == true
1061
+ end
1062
+
1049
1063
  it "marks a transactions as recurring" do
1050
1064
  result = Braintree::Transaction.create(
1051
1065
  :type => "sale",
@@ -1060,6 +1074,20 @@ describe Braintree::Transaction do
1060
1074
  result.transaction.recurring.should == true
1061
1075
  end
1062
1076
 
1077
+ it "marks a transactions as merchant" do
1078
+ result = Braintree::Transaction.create(
1079
+ :type => "sale",
1080
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1081
+ :credit_card => {
1082
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1083
+ :expiration_date => "12/12",
1084
+ },
1085
+ :transaction_source => "merchant"
1086
+ )
1087
+ result.success?.should == true
1088
+ result.transaction.recurring.should == false
1089
+ end
1090
+
1063
1091
  it "marks a transactions as moto" do
1064
1092
  result = Braintree::Transaction.create(
1065
1093
  :type => "sale",
@@ -1073,6 +1101,20 @@ describe Braintree::Transaction do
1073
1101
  result.success?.should == true
1074
1102
  result.transaction.recurring.should == false
1075
1103
  end
1104
+
1105
+ it "handles validation when transaction source invalid" do
1106
+ result = Braintree::Transaction.create(
1107
+ :type => "sale",
1108
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1109
+ :credit_card => {
1110
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1111
+ :expiration_date => "12/12",
1112
+ },
1113
+ :transaction_source => "invalid_value"
1114
+ )
1115
+ result.success?.should == false
1116
+ result.errors.for(:transaction).on(:transaction_source)[0].code.should == Braintree::ErrorCodes::Transaction::TransactionSourceIsInvalid
1117
+ end
1076
1118
  end
1077
1119
 
1078
1120
  context "store_in_vault_on_success" do
@@ -1544,6 +1586,81 @@ describe Braintree::Transaction do
1544
1586
  result.transaction.should_not be_nil
1545
1587
  end
1546
1588
 
1589
+ it "can create a transaction with a payee id" do
1590
+ customer = Braintree::Customer.create!
1591
+ nonce = nonce_for_new_payment_method(
1592
+ :paypal_account => {
1593
+ :consent_code => "PAYPAL_CONSENT_CODE",
1594
+ }
1595
+ )
1596
+ nonce.should_not be_nil
1597
+
1598
+ result = Braintree::Transaction.create(
1599
+ :type => "sale",
1600
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1601
+ :payment_method_nonce => nonce,
1602
+ :paypal_account => {
1603
+ :payee_id => "fake-payee-id"
1604
+ }
1605
+ )
1606
+
1607
+ result.success?.should == true
1608
+ result.transaction.paypal_details.should_not be_nil
1609
+ result.transaction.paypal_details.debug_id.should_not be_nil
1610
+ result.transaction.paypal_details.payee_id.should == "fake-payee-id"
1611
+ end
1612
+
1613
+ it "can create a transaction with a payee id in the options params" do
1614
+ customer = Braintree::Customer.create!
1615
+ nonce = nonce_for_new_payment_method(
1616
+ :paypal_account => {
1617
+ :consent_code => "PAYPAL_CONSENT_CODE",
1618
+ }
1619
+ )
1620
+ nonce.should_not be_nil
1621
+
1622
+ result = Braintree::Transaction.create(
1623
+ :type => "sale",
1624
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1625
+ :payment_method_nonce => nonce,
1626
+ :paypal_account => {},
1627
+ :options => {
1628
+ :payee_id => "fake-payee-id"
1629
+ }
1630
+ )
1631
+
1632
+ result.success?.should == true
1633
+ result.transaction.paypal_details.should_not be_nil
1634
+ result.transaction.paypal_details.debug_id.should_not be_nil
1635
+ result.transaction.paypal_details.payee_id.should == "fake-payee-id"
1636
+ end
1637
+
1638
+ it "can create a transaction with a payee id in options.paypal" do
1639
+ customer = Braintree::Customer.create!
1640
+ nonce = nonce_for_new_payment_method(
1641
+ :paypal_account => {
1642
+ :consent_code => "PAYPAL_CONSENT_CODE",
1643
+ }
1644
+ )
1645
+ nonce.should_not be_nil
1646
+
1647
+ result = Braintree::Transaction.create(
1648
+ :type => "sale",
1649
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1650
+ :payment_method_nonce => nonce,
1651
+ :options => {
1652
+ :paypal => {
1653
+ :payee_id => "fake-payee-id"
1654
+ }
1655
+ }
1656
+ )
1657
+
1658
+ result.success?.should == true
1659
+ result.transaction.paypal_details.should_not be_nil
1660
+ result.transaction.paypal_details.debug_id.should_not be_nil
1661
+ result.transaction.paypal_details.payee_id.should == "fake-payee-id"
1662
+ end
1663
+
1547
1664
  it "can create a transaction with a payee email" do
1548
1665
  customer = Braintree::Customer.create!
1549
1666
  nonce = nonce_for_new_payment_method(
@@ -1,3 +1,5 @@
1
+ require 'stringio'
2
+
1
3
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
4
 
3
5
  describe Braintree::Configuration do
@@ -65,6 +67,33 @@ describe Braintree::Configuration do
65
67
  end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
66
68
  end
67
69
 
70
+ context "mixed environments" do
71
+ before do
72
+ @original_stderr = $stderr
73
+ $stderr = StringIO.new
74
+ end
75
+
76
+ after do
77
+ $stderr = @original_stderr
78
+ end
79
+
80
+ it "warns if both environment and access_token are provided and their environments differ" do
81
+ Braintree::Configuration.new(
82
+ :access_token => "access_token$development$integration_merchant_id$fb27c79dd",
83
+ :environment => "sandbox",
84
+ )
85
+ $stderr.string.should == "Braintree::Gateway should not be initialized with mixed environments: environment parameter and access_token do not match, environment from access_token is used.\n"
86
+ end
87
+
88
+ it "does not warn if both environment and access_token are provided and their environments match" do
89
+ Braintree::Configuration.new(
90
+ :access_token => "access_token$development$integration_merchant_id$fb27c79dd",
91
+ :environment => "development",
92
+ )
93
+ $stderr.string.should == ""
94
+ end
95
+ end
96
+
68
97
  it "accepts proxy params" do
69
98
  config = Braintree::Configuration.new(
70
99
  :proxy_address => 'localhost',
@@ -76,4 +76,56 @@ describe Braintree::Disbursement do
76
76
  disbursement.success?.should == true
77
77
  end
78
78
  end
79
+
80
+ describe "credit?" do
81
+ subject do
82
+ described_class._new(
83
+ :gateway,
84
+ merchant_account: {
85
+ id: "sandbox_master_merchant_account",
86
+ status: "active",
87
+ },
88
+ success: true,
89
+ amount: "100.00",
90
+ disbursement_type: type,
91
+ disbursement_date: "2013-04-10",
92
+ )
93
+ end
94
+
95
+ context "when the disbursement type is credit" do
96
+ let(:type) { described_class::Types::Credit }
97
+ it { is_expected.to be_credit }
98
+ end
99
+
100
+ context "when the disbursement type is not credit" do
101
+ let(:type) { described_class::Types::Debit }
102
+ it { is_expected.not_to be_credit }
103
+ end
104
+ end
105
+
106
+ describe "debit?" do
107
+ subject do
108
+ described_class._new(
109
+ :gateway,
110
+ merchant_account: {
111
+ id: "sandbox_master_merchant_account",
112
+ status: "active",
113
+ },
114
+ success: true,
115
+ amount: "100.00",
116
+ disbursement_type: type,
117
+ disbursement_date: "2013-04-10",
118
+ )
119
+ end
120
+
121
+ context "when the disbursement type is debit" do
122
+ let(:type) { described_class::Types::Debit }
123
+ it { is_expected.to be_debit }
124
+ end
125
+
126
+ context "when the disbursement type is not debit" do
127
+ let(:type) { described_class::Types::Credit }
128
+ it { is_expected.not_to be_debit }
129
+ end
130
+ end
79
131
  end
@@ -58,19 +58,6 @@ describe Braintree::WebhookNotification do
58
58
  notification.timestamp.should be_within(10).of(Time.now.utc)
59
59
  end
60
60
 
61
- it 'builds a sample notification for OAuth application revocation' do
62
- sample_notification = Braintree::WebhookTesting.sample_notification(
63
- Braintree::WebhookNotification::Kind::OAuthAccessRevoked,
64
- 'my_id'
65
- )
66
-
67
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
68
-
69
- expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::OAuthAccessRevoked)
70
- expect(notification.oauth_access_revocation.merchant_id).to eq('abc123')
71
- expect(notification.timestamp).to be_within(10).of(Time.now.utc)
72
- end
73
-
74
61
  it "builds a sample notification with a source merchant ID" do
75
62
  sample_notification = Braintree::WebhookTesting.sample_notification(
76
63
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
@@ -107,6 +94,7 @@ describe Braintree::WebhookNotification do
107
94
 
108
95
  status_transitioned = notification.connected_merchant_status_transitioned
109
96
  status_transitioned.merchant_public_id.should == "my_id"
97
+ status_transitioned.merchant_id.should == "my_id"
110
98
  status_transitioned.oauth_application_client_id.should == "oauth_application_client_id"
111
99
  status_transitioned.status.should == "new_status"
112
100
  end
@@ -123,9 +111,25 @@ describe Braintree::WebhookNotification do
123
111
 
124
112
  paypal_status_changed = notification.connected_merchant_paypal_status_changed
125
113
  paypal_status_changed.merchant_public_id.should == "my_id"
114
+ paypal_status_changed.merchant_id.should == "my_id"
126
115
  paypal_status_changed.oauth_application_client_id.should == "oauth_application_client_id"
127
116
  paypal_status_changed.action.should == "link"
128
117
  end
118
+
119
+ it 'builds a sample notification for OAuth application revocation' do
120
+ sample_notification = Braintree::WebhookTesting.sample_notification(
121
+ Braintree::WebhookNotification::Kind::OAuthAccessRevoked,
122
+ 'my_id'
123
+ )
124
+
125
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
126
+
127
+ notification.kind.should == Braintree::WebhookNotification::Kind::OAuthAccessRevoked
128
+ notification.oauth_access_revocation.merchant_id.should == "my_id"
129
+ notification.oauth_access_revocation.oauth_application_client_id.should == "oauth_application_client_id"
130
+ notification.timestamp.should be_within(10).of(Time.now.utc)
131
+ end
132
+
129
133
  end
130
134
 
131
135
  context "disputes" do
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.88.0
4
+ version: 2.89.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-20 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.0.0
27
27
  description: Ruby library for integrating with the Braintree Gateway
@@ -295,17 +295,17 @@ require_paths:
295
295
  - lib
296
296
  required_ruby_version: !ruby/object:Gem::Requirement
297
297
  requirements:
298
- - - ">="
298
+ - - '>='
299
299
  - !ruby/object:Gem::Version
300
300
  version: '0'
301
301
  required_rubygems_version: !ruby/object:Gem::Requirement
302
302
  requirements:
303
- - - ">="
303
+ - - '>='
304
304
  - !ruby/object:Gem::Version
305
305
  version: '0'
306
306
  requirements: []
307
307
  rubyforge_project: braintree
308
- rubygems_version: 2.6.14
308
+ rubygems_version: 2.2.0
309
309
  signing_key:
310
310
  specification_version: 4
311
311
  summary: Braintree Gateway Ruby Client Library