braintree 2.87.0 → 2.88.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4213a3a4067576307a99ec5057963ae90eee83b7
4
- data.tar.gz: 716ecb6baa8f9a0134ac5d1baaa9123058c0aaf4
3
+ metadata.gz: c971a0bacc5df30ce7c762b37047e83bb86b6036
4
+ data.tar.gz: 8adfabbcb3d4855170eb3c2e66d6ecd5b8e48a7d
5
5
  SHA512:
6
- metadata.gz: e74de4236aa5bb09c33775c3a09c67df3714fa74252fa3e0c3e8587460d3a190a09b4e1ea8eb13b8c0de40c2bcf0ece3b2811c1099587c8ecc45dfd6f60ecc42
7
- data.tar.gz: 3f62aca3888a83732af83699158fdf5b02cd359e3989b8225f18b21f3255af7c51a51d28fba132452786431aeca1c2bf505714c80b63a0e735cbab977fd042ce
6
+ metadata.gz: 78286324c7e94afc9281390b7ae4f465a34e823d97e7bdb268ebd899becd492db89ba0695ccf99f07bdf3c3fb854dffb26a1e85ba8a314e1808ec3f1096ac378
7
+ data.tar.gz: ca5421117f2d7e2d324cf65651071ff1fb3e26eecfeb175a2d8a6efc08a8cb95188cfcdd3b6270a023bc76f76bd0588df2033ffa6051ba3264c48c36387f78d9
@@ -668,5 +668,14 @@ module Braintree
668
668
  MerchantAccountCannotBeSubMerchantAccount = "94208"
669
669
  end
670
670
  end
671
+
672
+ module UsBankAccountVerification
673
+ NotConfirmable = "96101"
674
+ MustBeMicroTransfersVerification = "96102"
675
+ AmountsDoNotMatch = "96103"
676
+ TooManyConfirmationAttempts = "96104"
677
+ UnableToConfirmDepositAmounts = "96105"
678
+ InvalidDepositAmounts = "96106"
679
+ end
671
680
  end
672
681
  end
@@ -21,6 +21,7 @@ module Braintree
21
21
  attr_reader :subscription
22
22
  attr_reader :supported_networks
23
23
  attr_reader :transaction
24
+ attr_reader :us_bank_account_verification
24
25
 
25
26
  def initialize(attributes = {}) # :nodoc:
26
27
  @attrs = attributes.keys
@@ -7,10 +7,12 @@ module Braintree
7
7
  attr_reader :expiration_month
8
8
  attr_reader :expiration_year
9
9
  attr_reader :google_transaction_id
10
+ attr_reader :image_url
10
11
  attr_reader :last_4
11
12
  attr_reader :source_card_last_4
12
13
  attr_reader :source_card_type
13
14
  attr_reader :source_description
15
+ attr_reader :token
14
16
  attr_reader :virtual_card_last_4
15
17
  attr_reader :virtual_card_type
16
18
 
@@ -7,9 +7,11 @@ module Braintree
7
7
  attr_reader :cardholder_name
8
8
  attr_reader :expiration_month
9
9
  attr_reader :expiration_year
10
+ attr_reader :image_url
10
11
  attr_reader :last_4
11
12
  attr_reader :payment_instrument_name
12
13
  attr_reader :source_description
14
+ attr_reader :token
13
15
 
14
16
  def initialize(attributes)
15
17
  set_instance_variables_from_hash attributes unless attributes.nil?
@@ -8,16 +8,18 @@ module Braintree
8
8
  GatewayRejected = "gateway_rejected"
9
9
  ProcessorDeclined = "processor_declined"
10
10
  Verified = "verified"
11
+ Pending = "pending"
11
12
 
12
- All = [Failed, GatewayRejected, ProcessorDeclined, Verified]
13
+ All = [Failed, GatewayRejected, ProcessorDeclined, Verified, Pending]
13
14
  end
14
15
 
15
16
  module VerificationMethod
16
17
  IndependentCheck = "independent_check"
17
18
  NetworkCheck = "network_check"
18
19
  TokenizedCheck = "tokenized_check"
20
+ MicroTransfers = "micro_transfers"
19
21
 
20
- All = [IndependentCheck, NetworkCheck, TokenizedCheck]
22
+ All = [IndependentCheck, NetworkCheck, TokenizedCheck, MicroTransfers]
21
23
  end
22
24
 
23
25
  attr_reader :id
@@ -64,6 +66,10 @@ module Braintree
64
66
  self.new *args
65
67
  end
66
68
 
69
+ def self.confirm_micro_transfer_amounts(*args)
70
+ Configuration.gateway.us_bank_account_verification.confirm_micro_transfer_amounts(*args)
71
+ end
72
+
67
73
  def self.find(*args)
68
74
  Configuration.gateway.us_bank_account_verification.find(*args)
69
75
  end
@@ -6,6 +6,25 @@ module Braintree
6
6
  @config.assert_has_access_token_or_keys
7
7
  end
8
8
 
9
+ def confirm_micro_transfer_amounts(id, deposit_amounts)
10
+ raise ArgumentError if id.nil? || id.to_s.strip == "" || !deposit_amounts.kind_of?(Array)
11
+ response = @config.http.put(
12
+ "#{@config.base_merchant_path}/us_bank_account_verifications/#{id}/confirm_micro_transfer_amounts",
13
+ :us_bank_account_verification => {
14
+ :deposit_amounts => deposit_amounts,
15
+ },
16
+ )
17
+ if response[:api_error_response]
18
+ ErrorResult.new(@gateway, response[:api_error_response])
19
+ else
20
+ SuccessfulResult.new(
21
+ :us_bank_account_verification => UsBankAccountVerification._new(response[:us_bank_account_verification])
22
+ )
23
+ end
24
+ rescue NotFoundError
25
+ raise NotFoundError, "verification with id #{id.inspect} not found"
26
+ end
27
+
9
28
  def find(id)
10
29
  raise ArgumentError if id.nil? || id.to_s.strip == ""
11
30
  response = @config.http.get("#{@config.base_merchant_path}/us_bank_account_verifications/#{id}")
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 87
4
+ Minor = 88
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -55,7 +55,7 @@ def nonce_for_paypal_account(paypal_account_details)
55
55
  body["paypalAccounts"][0]["nonce"]
56
56
  end
57
57
 
58
- def generate_non_plaid_us_bank_account_nonce
58
+ def generate_non_plaid_us_bank_account_nonce(account_number="1000000000")
59
59
  raw_client_token = Braintree::ClientToken.generate
60
60
  client_token = decode_client_token(raw_client_token)
61
61
 
@@ -71,7 +71,7 @@ def generate_non_plaid_us_bank_account_nonce
71
71
  },
72
72
  :account_type => "checking",
73
73
  :routing_number => "021000021",
74
- :account_number => "1000000000",
74
+ :account_number => account_number,
75
75
  :first_name => "John",
76
76
  :last_name => "Doe",
77
77
  :ownership_type => "personal",
@@ -1385,6 +1385,30 @@ describe Braintree::Transaction do
1385
1385
  apple_pay_details.expiration_month.to_i.should > 0
1386
1386
  apple_pay_details.expiration_year.to_i.should > 0
1387
1387
  apple_pay_details.cardholder_name.should_not be_nil
1388
+ apple_pay_details.image_url.should_not be_nil
1389
+ apple_pay_details.token.should be_nil
1390
+ end
1391
+
1392
+ it "can create a vaulted transaction with a fake apple pay nonce" do
1393
+ customer = Braintree::Customer.create!
1394
+ result = Braintree::Transaction.create(
1395
+ :type => "sale",
1396
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1397
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
1398
+ :options => { :store_in_vault_on_success => true }
1399
+ )
1400
+ result.success?.should == true
1401
+ result.transaction.should_not be_nil
1402
+ apple_pay_details = result.transaction.apple_pay_details
1403
+ apple_pay_details.should_not be_nil
1404
+ apple_pay_details.card_type.should == Braintree::ApplePayCard::CardType::Visa
1405
+ apple_pay_details.payment_instrument_name.should == "Visa 8886"
1406
+ apple_pay_details.source_description.should == "Visa 8886"
1407
+ apple_pay_details.expiration_month.to_i.should > 0
1408
+ apple_pay_details.expiration_year.to_i.should > 0
1409
+ apple_pay_details.cardholder_name.should_not be_nil
1410
+ apple_pay_details.image_url.should_not be_nil
1411
+ apple_pay_details.token.should_not be_nil
1388
1412
  end
1389
1413
 
1390
1414
  it "can create a transaction with a fake android pay proxy card nonce" do
@@ -1406,6 +1430,32 @@ describe Braintree::Transaction do
1406
1430
  android_pay_details.expiration_month.to_i.should > 0
1407
1431
  android_pay_details.expiration_year.to_i.should > 0
1408
1432
  android_pay_details.google_transaction_id.should == "google_transaction_id"
1433
+ android_pay_details.image_url.should_not be_nil
1434
+ android_pay_details.token.should be_nil
1435
+ end
1436
+
1437
+ it "can create a vaulted transaction with a fake android pay proxy card nonce" do
1438
+ customer = Braintree::Customer.create!
1439
+ result = Braintree::Transaction.create(
1440
+ :type => "sale",
1441
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
1442
+ :payment_method_nonce => Braintree::Test::Nonce::AndroidPayDiscover,
1443
+ :options => { :store_in_vault_on_success => true }
1444
+ )
1445
+ result.success?.should == true
1446
+ result.transaction.should_not be_nil
1447
+ android_pay_details = result.transaction.android_pay_details
1448
+ android_pay_details.should_not be_nil
1449
+ android_pay_details.card_type.should == Braintree::CreditCard::CardType::Discover
1450
+ android_pay_details.virtual_card_type.should == Braintree::CreditCard::CardType::Discover
1451
+ android_pay_details.last_4.should == "1117"
1452
+ android_pay_details.virtual_card_last_4.should == "1117"
1453
+ android_pay_details.source_description.should == "Discover 1111"
1454
+ android_pay_details.expiration_month.to_i.should > 0
1455
+ android_pay_details.expiration_year.to_i.should > 0
1456
+ android_pay_details.google_transaction_id.should == "google_transaction_id"
1457
+ android_pay_details.image_url.should_not be_nil
1458
+ android_pay_details.token.should_not be_nil
1409
1459
  end
1410
1460
 
1411
1461
  it "can create a transaction with a fake android pay network token nonce" do
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
  require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
3
3
 
4
- describe Braintree::UsBankAccountVerification, "search" do
4
+ describe Braintree::UsBankAccountVerification do
5
5
  let(:nonce) { generate_non_plaid_us_bank_account_nonce }
6
6
  let(:customer) do
7
7
  params = {
@@ -13,6 +13,167 @@ describe Braintree::UsBankAccountVerification, "search" do
13
13
  Braintree::Customer.create(params).customer
14
14
  end
15
15
 
16
+ describe "self.confirm_micro_transfer_amounts" do
17
+ before do
18
+ Braintree::Configuration.merchant_id = "integration2_merchant_id"
19
+ Braintree::Configuration.public_key = "integration2_public_key"
20
+ Braintree::Configuration.private_key = "integration2_private_key"
21
+ end
22
+
23
+ after(:all) do
24
+ Braintree::Configuration.merchant_id = "integration_merchant_id"
25
+ Braintree::Configuration.public_key = "integration_public_key"
26
+ Braintree::Configuration.private_key = "integration_private_key"
27
+ end
28
+
29
+ context "with a micro transfer verification" do
30
+ it "successfully confirms settled amounts" do
31
+ nonce = generate_non_plaid_us_bank_account_nonce("1000000000")
32
+
33
+ result = Braintree::PaymentMethod.create(
34
+ :payment_method_nonce => nonce,
35
+ :customer_id => customer.id,
36
+ :options => {
37
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
38
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
39
+ }
40
+ )
41
+
42
+ result.should be_success
43
+
44
+ verification = result.payment_method.verifications.first
45
+ verification.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers
46
+ verification.status.should == Braintree::UsBankAccountVerification::Status::Pending
47
+
48
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [17, 29])
49
+
50
+ response.should be_success
51
+ response.us_bank_account_verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
52
+
53
+ us_bank_account = Braintree::UsBankAccount.find(response.us_bank_account_verification.us_bank_account[:token])
54
+
55
+ us_bank_account.verified.should be_truthy
56
+ end
57
+
58
+ it "successfully confirms not-yet-settled amounts" do
59
+ nonce = generate_non_plaid_us_bank_account_nonce("1000000001")
60
+
61
+ result = Braintree::PaymentMethod.create(
62
+ :payment_method_nonce => nonce,
63
+ :customer_id => customer.id,
64
+ :options => {
65
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
66
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
67
+ }
68
+ )
69
+
70
+ result.should be_success
71
+
72
+ verification = result.payment_method.verifications.first
73
+ verification.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers
74
+ verification.status.should == Braintree::UsBankAccountVerification::Status::Pending
75
+
76
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [17, 29])
77
+
78
+ response.should be_success
79
+ response.us_bank_account_verification.status.should == Braintree::UsBankAccountVerification::Status::Pending
80
+ end
81
+
82
+ it "attempts to confirm" do
83
+ result = Braintree::PaymentMethod.create(
84
+ :payment_method_nonce => nonce,
85
+ :customer_id => customer.id,
86
+ :options => {
87
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
88
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
89
+ }
90
+ )
91
+
92
+ result.should be_success
93
+
94
+ verification = result.payment_method.verifications.first
95
+ verification.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers
96
+ verification.status.should == Braintree::UsBankAccountVerification::Status::Pending
97
+
98
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
99
+
100
+ response.should_not be_success
101
+ response.errors.for(:us_bank_account_verification)[0].code.should == Braintree::ErrorCodes::UsBankAccountVerification::AmountsDoNotMatch
102
+ end
103
+
104
+ it "exceeds the confirmation attempt threshold" do
105
+ result = Braintree::PaymentMethod.create(
106
+ :payment_method_nonce => nonce,
107
+ :customer_id => customer.id,
108
+ :options => {
109
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
110
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
111
+ }
112
+ )
113
+
114
+ result.should be_success
115
+
116
+ verification = result.payment_method.verifications.first
117
+
118
+ response = nil
119
+ 4.times do
120
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
121
+
122
+ response.should_not be_success
123
+ response.errors.for(:us_bank_account_verification)[0].code.should == Braintree::ErrorCodes::UsBankAccountVerification::AmountsDoNotMatch
124
+ end
125
+
126
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
127
+ response.should_not be_success
128
+ response.errors.for(:us_bank_account_verification)[0].code.should == Braintree::ErrorCodes::UsBankAccountVerification::TooManyConfirmationAttempts
129
+
130
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
131
+ response.should_not be_success
132
+ response.errors.for(:us_bank_account_verification)[0].code.should == Braintree::ErrorCodes::UsBankAccountVerification::TooManyConfirmationAttempts
133
+ end
134
+
135
+ it "returns an error for invalid deposit amounts" do
136
+ result = Braintree::PaymentMethod.create(
137
+ :payment_method_nonce => nonce,
138
+ :customer_id => customer.id,
139
+ :options => {
140
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
141
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
142
+ }
143
+ )
144
+
145
+ result.should be_success
146
+
147
+ verification = result.payment_method.verifications.first
148
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, ["abc"])
149
+
150
+ response.should_not be_success
151
+ response.errors.for(:us_bank_account_verification)[0].code.should == Braintree::ErrorCodes::UsBankAccountVerification::InvalidDepositAmounts
152
+ end
153
+ end
154
+
155
+ context "non-micro transfer" do
156
+ it "rejects for incorrect verification type" do
157
+ result = Braintree::PaymentMethod.create(
158
+ :payment_method_nonce => nonce,
159
+ :customer_id => customer.id,
160
+ :options => {
161
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
162
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
163
+ }
164
+ )
165
+
166
+ result.should be_success
167
+
168
+ verification = result.payment_method.verifications.first
169
+ response = Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(verification.id, [1, 1])
170
+
171
+ response.should_not be_success
172
+ response.errors.for(:us_bank_account_verification)[0].code.should == Braintree::ErrorCodes::UsBankAccountVerification::MustBeMicroTransfersVerification
173
+ end
174
+ end
175
+ end
176
+
16
177
  describe "self.find" do
17
178
  it "finds the verification with the given id" do
18
179
  result = Braintree::PaymentMethod.create(
@@ -16,6 +16,32 @@ describe Braintree::UsBankAccountVerification do
16
16
  end
17
17
  end
18
18
 
19
+ describe "self.confirm_micro_transfer_amounts" do
20
+ it "raises error if passed empty string" do
21
+ expect do
22
+ Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts("", [])
23
+ end.to raise_error(ArgumentError)
24
+ end
25
+
26
+ it "raises error if passed empty string wth space" do
27
+ expect do
28
+ Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(" ", [])
29
+ end.to raise_error(ArgumentError)
30
+ end
31
+
32
+ it "raises error if passed nil" do
33
+ expect do
34
+ Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(nil, [])
35
+ end.to raise_error(ArgumentError)
36
+ end
37
+
38
+ it "raises error if passed non-array" do
39
+ expect do
40
+ Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts(999, 123)
41
+ end.to raise_error(ArgumentError)
42
+ end
43
+ end
44
+
19
45
  describe "self.find" do
20
46
  it "raises error if passed empty string" do
21
47
  expect do
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.87.0
4
+ version: 2.88.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-12 00:00:00.000000000 Z
11
+ date: 2018-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -185,7 +185,6 @@ files:
185
185
  - spec/fixtures/files/gif_extension_bt_logo.gif
186
186
  - spec/fixtures/files/malformed_pdf.pdf
187
187
  - spec/hacks/tcp_socket.rb
188
- - spec/httpsd.pid
189
188
  - spec/integration/braintree/add_on_spec.rb
190
189
  - spec/integration/braintree/address_spec.rb
191
190
  - spec/integration/braintree/advanced_search_spec.rb
@@ -306,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
306
305
  version: '0'
307
306
  requirements: []
308
307
  rubyforge_project: braintree
309
- rubygems_version: 2.5.2
308
+ rubygems_version: 2.6.14
310
309
  signing_key:
311
310
  specification_version: 4
312
311
  summary: Braintree Gateway Ruby Client Library
@@ -1 +0,0 @@
1
- 8020