braintree 4.33.0 → 4.33.2
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 +4 -4
- data/lib/braintree/credit_card_verification_gateway.rb +4 -2
- data/lib/braintree/transaction_gateway.rb +5 -2
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/xml/nokogiri.rb +5 -3
- data/spec/integration/braintree/apple_pay_spec.rb +6 -7
- data/spec/integration/braintree/merchant_account_spec.rb +19 -17
- data/spec/integration/braintree/merchant_spec.rb +4 -4
- data/spec/integration/braintree/payment_method_spec.rb +4 -4
- data/spec/integration/braintree/transaction_search_spec.rb +1 -1
- data/spec/integration/braintree/transaction_spec.rb +20 -13
- data/spec/integration/braintree/transaction_transfer_type_spec.rb +25 -1
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
- data/spec/spec_helper.rb +34 -6
- data/spec/unit/braintree/client_token_spec.rb +11 -0
- data/spec/unit/braintree/error_result_spec.rb +28 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +5 -2
- data/spec/unit/braintree/xml/parser_spec.rb +57 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f83c9224a357779af383288fed8888697132bacd35a7164a377d4106ba934970
|
|
4
|
+
data.tar.gz: 30ead2f12e74b45969a5f127e07e593e3fd00554536e3f94248743c58e2525cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c372e7ce5236f42f98cc96df8cde09be0835ff693dbf5c903c2ed7626fcb40f6cb46b053641e74cf0ed6e3e4cb8bbed9411ece9ba1b6010650155fc3c623b7bf
|
|
7
|
+
data.tar.gz: cf8c017c5ec14001a36658104fdbfe8b765a5978a3dce7949c440fd385188e417ba33a2b4f800ede9e872c01dae8da0e1407541eb9e7b2f4c788db44b5b9555d
|
|
@@ -18,7 +18,8 @@ module Braintree
|
|
|
18
18
|
search = CreditCardVerificationSearch.new
|
|
19
19
|
block.call(search) if block
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
search_params = search.to_hash.merge({:verification_type => ["credit_card"]})
|
|
22
|
+
response = @config.http.post("#{@config.base_merchant_path}/verifications/advanced_search_ids", {:search => search_params})
|
|
22
23
|
ResourceCollection.new(response) { |ids| _fetch_verifications(search, ids) }
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -39,7 +40,8 @@ module Braintree
|
|
|
39
40
|
|
|
40
41
|
def _fetch_verifications(search, ids)
|
|
41
42
|
search.ids.in ids
|
|
42
|
-
|
|
43
|
+
search_params = search.to_hash.merge({:verification_type => ["credit_card"]})
|
|
44
|
+
response = @config.http.post("#{@config.base_merchant_path}/verifications/advanced_search", {:search => search_params})
|
|
43
45
|
attributes = response[:credit_card_verifications]
|
|
44
46
|
Util.extract_attribute_as_array(attributes, :verification).map { |attrs| CreditCardVerification._new(attrs) }
|
|
45
47
|
end
|
|
@@ -285,18 +285,21 @@ module Braintree
|
|
|
285
285
|
:type,
|
|
286
286
|
{
|
|
287
287
|
:sender => [
|
|
288
|
+
:account_reference_number,
|
|
289
|
+
:date_of_birth,
|
|
288
290
|
:first_name,
|
|
289
291
|
:last_name,
|
|
290
|
-
:
|
|
292
|
+
:middle_name,
|
|
291
293
|
:tax_id,
|
|
292
294
|
{:address => AddressGateway._address_attributes}
|
|
293
295
|
]
|
|
294
296
|
},
|
|
295
297
|
{
|
|
296
298
|
:receiver => [
|
|
299
|
+
:account_reference_number,
|
|
297
300
|
:first_name,
|
|
298
301
|
:last_name,
|
|
299
|
-
:
|
|
302
|
+
:middle_name,
|
|
300
303
|
:tax_id,
|
|
301
304
|
{:address => AddressGateway._address_attributes}
|
|
302
305
|
]
|
data/lib/braintree/version.rb
CHANGED
|
@@ -12,12 +12,14 @@ module Braintree
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def self._node_to_hash(node, hash = {})
|
|
15
|
+
sub_hash = node.text? ? hash : _build_sub_hash(hash, node.name)
|
|
16
|
+
|
|
15
17
|
if node.text? || (node.children.size == 1 && node.children.first.text?)
|
|
16
18
|
content = node.text? ? node.content : node.children.first.content
|
|
17
19
|
raise "Content too large" if content.length >= NOKOGIRI_XML_LIMIT
|
|
18
|
-
|
|
20
|
+
sub_hash[CONTENT_ROOT] = content
|
|
21
|
+
_attributes_to_hash(node, sub_hash) unless node.text?
|
|
19
22
|
else
|
|
20
|
-
sub_hash = _build_sub_hash(hash, node.name)
|
|
21
23
|
_attributes_to_hash(node, sub_hash)
|
|
22
24
|
if _array?(node)
|
|
23
25
|
_children_array_to_hash(node, sub_hash)
|
|
@@ -66,4 +68,4 @@ module Braintree
|
|
|
66
68
|
end
|
|
67
69
|
end
|
|
68
70
|
end
|
|
69
|
-
end
|
|
71
|
+
end
|
|
@@ -2,20 +2,19 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
|
2
2
|
|
|
3
3
|
describe Braintree::ApplePayGateway do
|
|
4
4
|
before(:each) do
|
|
5
|
-
|
|
5
|
+
oauth_gateway = Braintree::Gateway.new(
|
|
6
6
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
7
7
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
8
8
|
:logger => Logger.new("/dev/null"),
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
|
|
15
|
-
)
|
|
11
|
+
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
|
|
12
|
+
:merchant_public_id => "integration_merchant_id",
|
|
13
|
+
:scope => "read_write"
|
|
14
|
+
}).credentials.access_token
|
|
16
15
|
|
|
17
16
|
@gateway = Braintree::Gateway.new(
|
|
18
|
-
:access_token =>
|
|
17
|
+
:access_token => access_token,
|
|
19
18
|
:logger => Logger.new("/dev/null"),
|
|
20
19
|
)
|
|
21
20
|
end
|
|
@@ -95,10 +95,14 @@ describe Braintree::MerchantAccount do
|
|
|
95
95
|
:logger => Logger.new("/dev/null"),
|
|
96
96
|
)
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
:
|
|
100
|
-
:
|
|
101
|
-
|
|
98
|
+
code = Braintree::OAuthTestHelper.create_grant(gateway, {
|
|
99
|
+
:merchant_public_id => "integration_merchant_id",
|
|
100
|
+
:scope => "read_write"
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
result = gateway.oauth.create_token_from_code(
|
|
104
|
+
:code => code,
|
|
105
|
+
:scope => "read_write",
|
|
102
106
|
)
|
|
103
107
|
|
|
104
108
|
gateway = Braintree::Gateway.new(
|
|
@@ -108,10 +112,8 @@ describe Braintree::MerchantAccount do
|
|
|
108
112
|
|
|
109
113
|
result = gateway.merchant_account.all
|
|
110
114
|
expect(result).to be_success
|
|
111
|
-
expect(result.merchant_accounts.count).to
|
|
112
|
-
expect(result.merchant_accounts.first.currency_iso_code).to eq("GBP")
|
|
115
|
+
expect(result.merchant_accounts.count).to be > 0
|
|
113
116
|
expect(result.merchant_accounts.first.status).to eq("active")
|
|
114
|
-
expect(result.merchant_accounts.first.default).to eq(true)
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
it "returns all merchant accounts for read_only scoped grants" do
|
|
@@ -144,7 +146,7 @@ describe Braintree::MerchantAccount do
|
|
|
144
146
|
|
|
145
147
|
describe "create_for_currency" do
|
|
146
148
|
it "creates a new merchant account for currency" do
|
|
147
|
-
result = SpecHelper::
|
|
149
|
+
result = SpecHelper::get_merchant
|
|
148
150
|
expect(result).to be_success
|
|
149
151
|
|
|
150
152
|
gateway = Braintree::Gateway.new(
|
|
@@ -153,14 +155,14 @@ describe Braintree::MerchantAccount do
|
|
|
153
155
|
)
|
|
154
156
|
|
|
155
157
|
result = gateway.merchant_account.create_for_currency(
|
|
156
|
-
:currency => "
|
|
158
|
+
:currency => "AUD",
|
|
157
159
|
)
|
|
158
160
|
expect(result).to be_success
|
|
159
|
-
expect(result.merchant_account.currency_iso_code).to eq("
|
|
161
|
+
expect(result.merchant_account.currency_iso_code).to eq("AUD")
|
|
160
162
|
end
|
|
161
163
|
|
|
162
164
|
it "returns error if a merchant account already exists for that currency" do
|
|
163
|
-
result = SpecHelper::
|
|
165
|
+
result = SpecHelper::get_merchant
|
|
164
166
|
expect(result).to be_success
|
|
165
167
|
|
|
166
168
|
gateway = Braintree::Gateway.new(
|
|
@@ -169,12 +171,12 @@ describe Braintree::MerchantAccount do
|
|
|
169
171
|
)
|
|
170
172
|
|
|
171
173
|
result = gateway.merchant_account.create_for_currency(
|
|
172
|
-
:currency => "
|
|
174
|
+
:currency => "CAD",
|
|
173
175
|
)
|
|
174
176
|
expect(result).to be_success
|
|
175
177
|
|
|
176
178
|
result = gateway.merchant_account.create_for_currency(
|
|
177
|
-
:currency => "
|
|
179
|
+
:currency => "CAD",
|
|
178
180
|
)
|
|
179
181
|
expect(result).not_to be_success
|
|
180
182
|
|
|
@@ -183,7 +185,7 @@ describe Braintree::MerchantAccount do
|
|
|
183
185
|
end
|
|
184
186
|
|
|
185
187
|
it "returns error if no currency is provided" do
|
|
186
|
-
result = SpecHelper::
|
|
188
|
+
result = SpecHelper::get_merchant
|
|
187
189
|
expect(result).to be_success
|
|
188
190
|
|
|
189
191
|
gateway = Braintree::Gateway.new(
|
|
@@ -207,7 +209,7 @@ describe Braintree::MerchantAccount do
|
|
|
207
209
|
end
|
|
208
210
|
|
|
209
211
|
it "returns error if a currency is not supported" do
|
|
210
|
-
result = SpecHelper::
|
|
212
|
+
result = SpecHelper::get_merchant
|
|
211
213
|
expect(result).to be_success
|
|
212
214
|
|
|
213
215
|
gateway = Braintree::Gateway.new(
|
|
@@ -225,7 +227,7 @@ describe Braintree::MerchantAccount do
|
|
|
225
227
|
end
|
|
226
228
|
|
|
227
229
|
it "returns error if id is passed and already taken" do
|
|
228
|
-
result = SpecHelper::
|
|
230
|
+
result = SpecHelper::get_merchant
|
|
229
231
|
expect(result).to be_success
|
|
230
232
|
|
|
231
233
|
gateway = Braintree::Gateway.new(
|
|
@@ -235,7 +237,7 @@ describe Braintree::MerchantAccount do
|
|
|
235
237
|
|
|
236
238
|
merchant = result.merchant
|
|
237
239
|
result = gateway.merchant_account.create_for_currency(
|
|
238
|
-
:currency => "
|
|
240
|
+
:currency => "GBP",
|
|
239
241
|
:id => merchant.merchant_accounts.first.id,
|
|
240
242
|
)
|
|
241
243
|
expect(result).not_to be_success
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
|
2
2
|
|
|
3
3
|
describe Braintree::MerchantGateway do
|
|
4
4
|
describe "create" do
|
|
5
|
-
|
|
5
|
+
xit "creates a merchant" do
|
|
6
6
|
gateway = Braintree::Gateway.new(
|
|
7
7
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
8
8
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
@@ -59,7 +59,7 @@ describe Braintree::MerchantGateway do
|
|
|
59
59
|
Braintree::Configuration.merchant_id = old_merchant_id_value
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
xit "allows using a merchant_id passed in through Gateway" do
|
|
63
63
|
Braintree::Configuration.merchant_id = nil
|
|
64
64
|
|
|
65
65
|
gateway = Braintree::Gateway.new(
|
|
@@ -87,7 +87,7 @@ describe Braintree::MerchantGateway do
|
|
|
87
87
|
)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
xit "creates an EU multi currency merchant for paypal and credit_card" do
|
|
91
91
|
result = @gateway.merchant.create(
|
|
92
92
|
:email => "name@email.com",
|
|
93
93
|
:country_code_alpha3 => "GBR",
|
|
@@ -123,7 +123,7 @@ describe Braintree::MerchantGateway do
|
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
xit "creates a paypal-only merchant that accepts multiple currencies" do
|
|
127
127
|
result = @gateway.merchant.create(
|
|
128
128
|
:email => "name@email.com",
|
|
129
129
|
:country_code_alpha3 => "GBR",
|
|
@@ -207,9 +207,9 @@ describe Braintree::PaymentMethod do
|
|
|
207
207
|
expect(google_pay_card.image_url).to match(/android_pay/)
|
|
208
208
|
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
|
209
209
|
expect(google_pay_card.source_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
210
|
-
expect(google_pay_card.source_card_last_4).to eq("
|
|
210
|
+
expect(google_pay_card.source_card_last_4).to eq("0005")
|
|
211
211
|
expect(google_pay_card.google_transaction_id).to eq("google_transaction_id")
|
|
212
|
-
expect(google_pay_card.source_description).to eq("MasterCard
|
|
212
|
+
expect(google_pay_card.source_description).to eq("MasterCard 0005")
|
|
213
213
|
expect(google_pay_card.customer_id).to eq(customer.id)
|
|
214
214
|
expect(google_pay_card.commercial).not_to be_nil
|
|
215
215
|
expect(google_pay_card.country_of_issuance).not_to be_nil
|
|
@@ -1337,9 +1337,9 @@ describe Braintree::PaymentMethod do
|
|
|
1337
1337
|
expect(google_pay_card.image_url).to match(/android_pay/)
|
|
1338
1338
|
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
|
1339
1339
|
expect(google_pay_card.source_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
1340
|
-
expect(google_pay_card.source_card_last_4).to eq("
|
|
1340
|
+
expect(google_pay_card.source_card_last_4).to eq("0005")
|
|
1341
1341
|
expect(google_pay_card.google_transaction_id).to eq("google_transaction_id")
|
|
1342
|
-
expect(google_pay_card.source_description).to eq("MasterCard
|
|
1342
|
+
expect(google_pay_card.source_description).to eq("MasterCard 0005")
|
|
1343
1343
|
expect(google_pay_card.customer_id).to eq(customer.id)
|
|
1344
1344
|
end
|
|
1345
1345
|
end
|
|
@@ -856,7 +856,7 @@ describe Braintree::Transaction, "search" do
|
|
|
856
856
|
search.ach_return_responses_created_at.between(DateTime.now - 1.0, DateTime.now + 1.0)
|
|
857
857
|
end
|
|
858
858
|
|
|
859
|
-
expect(date_search.maximum_size).to
|
|
859
|
+
expect(date_search.maximum_size).to be >= 1
|
|
860
860
|
end
|
|
861
861
|
|
|
862
862
|
it "it does not find records not within date range of the custom field" do
|
|
@@ -1216,27 +1216,32 @@ describe Braintree::Transaction do
|
|
|
1216
1216
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
1217
1217
|
:logger => Logger.new("/dev/null"),
|
|
1218
1218
|
)
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
:
|
|
1222
|
-
:
|
|
1219
|
+
|
|
1220
|
+
code = Braintree::OAuthTestHelper.create_grant(gateway, {
|
|
1221
|
+
:merchant_public_id => "partner_merchant_id",
|
|
1222
|
+
:scope => "read_write"
|
|
1223
|
+
})
|
|
1224
|
+
|
|
1225
|
+
result = gateway.oauth.create_token_from_code(
|
|
1226
|
+
:code => code,
|
|
1227
|
+
:scope => "read_write",
|
|
1223
1228
|
)
|
|
1224
1229
|
|
|
1225
|
-
|
|
1230
|
+
merchant_gateway = Braintree::Gateway.new(
|
|
1226
1231
|
:access_token => result.credentials.access_token,
|
|
1227
1232
|
:logger => Logger.new("/dev/null"),
|
|
1228
1233
|
)
|
|
1229
1234
|
|
|
1230
|
-
|
|
1235
|
+
transaction_result = merchant_gateway.transaction.create(
|
|
1231
1236
|
:type => "sale",
|
|
1232
|
-
:amount => "
|
|
1237
|
+
:amount => "5001.00",
|
|
1233
1238
|
:credit_card => {
|
|
1234
1239
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
1235
1240
|
:expiration_date => "05/2020"
|
|
1236
1241
|
},
|
|
1237
1242
|
)
|
|
1238
|
-
expect(
|
|
1239
|
-
expect(
|
|
1243
|
+
expect(transaction_result.success?).to eq(false)
|
|
1244
|
+
expect(transaction_result.transaction.gateway_rejection_reason).to eq(Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete)
|
|
1240
1245
|
end
|
|
1241
1246
|
|
|
1242
1247
|
it "exposes the avs gateway rejection reason" do
|
|
@@ -2335,8 +2340,9 @@ describe Braintree::Transaction do
|
|
|
2335
2340
|
expect(google_pay_details).not_to be_nil
|
|
2336
2341
|
expect(google_pay_details.card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
2337
2342
|
expect(google_pay_details.virtual_card_type).to eq(Braintree::CreditCard::CardType::MasterCard)
|
|
2338
|
-
expect(google_pay_details.last_4).to eq("
|
|
2339
|
-
expect(google_pay_details.virtual_card_last_4).to eq("
|
|
2343
|
+
expect(google_pay_details.last_4).to eq("4444")
|
|
2344
|
+
expect(google_pay_details.virtual_card_last_4).to eq("4444")
|
|
2345
|
+
expect(google_pay_details.source_card_last_4).to eq("0005")
|
|
2340
2346
|
expect(google_pay_details.source_description).to eq("MasterCard 0005")
|
|
2341
2347
|
expect(google_pay_details.expiration_month.to_i).to be > 0
|
|
2342
2348
|
expect(google_pay_details.expiration_year.to_i).to be > 0
|
|
@@ -3038,8 +3044,9 @@ describe Braintree::Transaction do
|
|
|
3038
3044
|
:ds_transaction_id => "some_ds_id",
|
|
3039
3045
|
},
|
|
3040
3046
|
)
|
|
3047
|
+
|
|
3041
3048
|
expect(result.success?).to eq(false)
|
|
3042
|
-
expect(result.errors.for(:transaction).for(:
|
|
3049
|
+
expect(result.errors.for(:transaction).for(:credit_card).on(:cvv)[0].code).to eq(Braintree::ErrorCodes::CreditCard::CvvIsRequired)
|
|
3043
3050
|
end
|
|
3044
3051
|
end
|
|
3045
3052
|
|
|
@@ -7768,7 +7775,7 @@ describe Braintree::Transaction do
|
|
|
7768
7775
|
|
|
7769
7776
|
expect(adjustment_transaction.success?).to eq(false)
|
|
7770
7777
|
expect(adjustment_transaction.transaction.amount).to eq(BigDecimal("75.50"))
|
|
7771
|
-
expect(adjustment_transaction.errors.for(:
|
|
7778
|
+
expect(adjustment_transaction.errors.for(:transaction).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AmountMustBeGreaterThanZero)
|
|
7772
7779
|
end
|
|
7773
7780
|
|
|
7774
7781
|
it "returns failure response, when adjusted amount submitted same as authorized amount" do
|
|
@@ -15,7 +15,31 @@ describe Braintree::Transaction do
|
|
|
15
15
|
},
|
|
16
16
|
:transfer => {
|
|
17
17
|
:type => "wallet_transfer",
|
|
18
|
-
|
|
18
|
+
:receiver => {
|
|
19
|
+
:first_name => "John",
|
|
20
|
+
:last_name => "Smith",
|
|
21
|
+
:middle_name => "D",
|
|
22
|
+
:address => {
|
|
23
|
+
:country_code_alpha2 => "US",
|
|
24
|
+
:locality => "LA",
|
|
25
|
+
:region => "CA",
|
|
26
|
+
:street_address => "1st Main"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
:sender => {
|
|
30
|
+
:account_reference_number => "123456789",
|
|
31
|
+
:date_of_birth => Date.new(2002, 1, 2),
|
|
32
|
+
:first_name => "Lisa",
|
|
33
|
+
:last_name => "Ray",
|
|
34
|
+
:middle_name => "D",
|
|
35
|
+
:address => {
|
|
36
|
+
:country_code_alpha2 => "US",
|
|
37
|
+
:locality => "LA",
|
|
38
|
+
:region => "CA",
|
|
39
|
+
:street_address => "12th Main"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
}
|
|
19
43
|
}
|
|
20
44
|
|
|
21
45
|
result = Braintree::Transaction.sale(transaction_params)
|
|
@@ -50,7 +50,7 @@ describe Braintree::UsBankAccountVerification do
|
|
|
50
50
|
expect(response).to be_success
|
|
51
51
|
expect(response.us_bank_account_verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
|
52
52
|
|
|
53
|
-
us_bank_account = Braintree::UsBankAccount.find(response.us_bank_account_verification.us_bank_account
|
|
53
|
+
us_bank_account = Braintree::UsBankAccount.find(response.us_bank_account_verification.us_bank_account.token)
|
|
54
54
|
|
|
55
55
|
expect(us_bank_account.verified).to be_truthy
|
|
56
56
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -4,6 +4,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
4
4
|
require "rubygems"
|
|
5
5
|
require "bundler/setup"
|
|
6
6
|
require "rspec"
|
|
7
|
+
require "rspec/retry"
|
|
7
8
|
require "pry"
|
|
8
9
|
|
|
9
10
|
braintree_lib = "#{project_root}/lib"
|
|
@@ -119,18 +120,40 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
119
120
|
response[:three_d_secure_verification][:three_d_secure_authentication_id]
|
|
120
121
|
end
|
|
121
122
|
|
|
122
|
-
def self.
|
|
123
|
+
def self.get_merchant(params={})
|
|
123
124
|
gateway = Braintree::Gateway.new(
|
|
124
125
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
125
126
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
126
127
|
:logger => Logger.new("/dev/null"),
|
|
127
128
|
)
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
:
|
|
131
|
-
:
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
code = Braintree::OAuthTestHelper.create_grant(gateway, {
|
|
131
|
+
:merchant_public_id => "partner_merchant_id",
|
|
132
|
+
:scope => "read_write"
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
result = gateway.oauth.create_token_from_code(
|
|
136
|
+
:code => code,
|
|
137
|
+
:scope => "read_write",
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
merchant_gateway = Braintree::Gateway.new(
|
|
141
|
+
:access_token => result.credentials.access_token,
|
|
142
|
+
:logger => Logger.new("/dev/null"),
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
ma_result = merchant_gateway.merchant_account.all
|
|
146
|
+
|
|
147
|
+
merchant_obj = OpenStruct.new(
|
|
148
|
+
:id => "partner_merchant_id",
|
|
149
|
+
:merchant_accounts => ma_result.merchant_accounts,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
OpenStruct.new(
|
|
153
|
+
:success? => true,
|
|
154
|
+
:credentials => result.credentials,
|
|
155
|
+
:merchant => merchant_obj,
|
|
156
|
+
)
|
|
134
157
|
end
|
|
135
158
|
|
|
136
159
|
def self.stub_time_dot_now(desired_time)
|
|
@@ -234,4 +257,9 @@ RSpec.configure do |config|
|
|
|
234
257
|
config.mock_with :rspec do |mock|
|
|
235
258
|
mock.syntax = [:should, :expect]
|
|
236
259
|
end
|
|
260
|
+
|
|
261
|
+
config.verbose_retry = true
|
|
262
|
+
config.display_try_failure_messages = true
|
|
263
|
+
config.default_retry_count = 3
|
|
264
|
+
config.default_sleep_interval = 1
|
|
237
265
|
end
|
|
@@ -33,5 +33,16 @@ module Braintree
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
describe "error response handling" do
|
|
38
|
+
it "correctly parses error response with nested structure" do
|
|
39
|
+
error_xml = "<api-error-response><message>Invalid request</message><errors><errors type=\"array\"></errors></errors></api-error-response>"
|
|
40
|
+
result = Braintree::Xml::Parser.hash_from_xml(error_xml)
|
|
41
|
+
|
|
42
|
+
expect(result[:api_error_response]).to be_a(Hash)
|
|
43
|
+
expect(result[:api_error_response][:message]).to eq("Invalid request")
|
|
44
|
+
expect(result[:api_error_response][:errors]).to be_a(Hash)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
36
47
|
end
|
|
37
48
|
end
|
|
@@ -14,6 +14,34 @@ describe Braintree::ErrorResult do
|
|
|
14
14
|
)
|
|
15
15
|
end.to_not raise_error
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
it "handles parsed XML error response structure correctly" do
|
|
19
|
+
data = {
|
|
20
|
+
:message => "Validation failed",
|
|
21
|
+
:errors => {
|
|
22
|
+
:errors => [{:code => "81234", :message => "Field is required"}]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
expect do
|
|
27
|
+
result = Braintree::ErrorResult.new(:gateway, data)
|
|
28
|
+
expect(result.message).to eq("Validation failed")
|
|
29
|
+
expect(result.errors.inspect).to eq("#<Braintree::Errors :[(81234) Field is required]>")
|
|
30
|
+
end.to_not raise_error
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "handles empty error array in parsed XML response" do
|
|
34
|
+
data = {
|
|
35
|
+
:message => "Invalid request",
|
|
36
|
+
:errors => {:errors => []}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
expect do
|
|
40
|
+
result = Braintree::ErrorResult.new(:gateway, data)
|
|
41
|
+
expect(result.message).to eq("Invalid request")
|
|
42
|
+
expect(result.errors).to be_a(Braintree::Errors)
|
|
43
|
+
end.to_not raise_error
|
|
44
|
+
end
|
|
17
45
|
end
|
|
18
46
|
|
|
19
47
|
describe "inspect" do
|
|
@@ -133,16 +133,19 @@ describe Braintree::TransactionGateway do
|
|
|
133
133
|
:transfer => [
|
|
134
134
|
:type,
|
|
135
135
|
{:sender => [
|
|
136
|
+
:account_reference_number,
|
|
137
|
+
:date_of_birth,
|
|
136
138
|
:first_name,
|
|
137
139
|
:last_name,
|
|
138
|
-
:
|
|
140
|
+
:middle_name,
|
|
139
141
|
:tax_id,
|
|
140
142
|
:address => Braintree::AddressGateway._address_attributes
|
|
141
143
|
]},
|
|
142
144
|
{:receiver => [
|
|
145
|
+
:account_reference_number,
|
|
143
146
|
:first_name,
|
|
144
147
|
:last_name,
|
|
145
|
-
:
|
|
148
|
+
:middle_name,
|
|
146
149
|
:tax_id,
|
|
147
150
|
:address => Braintree::AddressGateway._address_attributes
|
|
148
151
|
]},
|
|
@@ -81,5 +81,62 @@ describe Braintree::Xml::Parser do
|
|
|
81
81
|
END
|
|
82
82
|
expect(xml).to parse_to(:root => {:paypal_details => {:deets => [{:secret_code => "1234"}], :payer_email => "abc@test.com", :payment_id => "1234567890"}})
|
|
83
83
|
end
|
|
84
|
+
|
|
85
|
+
it "does not collapse nested structures with single-child elements" do
|
|
86
|
+
xml = "<api-error-response><message>Test</message><errors><errors type=\"array\"></errors></errors></api-error-response>"
|
|
87
|
+
expect(xml).to parse_to({:api_error_response=>{:message=>"Test", :errors=>{:errors=>[]}}})
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "preserves hash structure when one key has array value" do
|
|
91
|
+
xml = <<-END
|
|
92
|
+
<root>
|
|
93
|
+
<message>Error message</message>
|
|
94
|
+
<items type="array">
|
|
95
|
+
<item>Value1</item>
|
|
96
|
+
</items>
|
|
97
|
+
</root>
|
|
98
|
+
END
|
|
99
|
+
expect(xml).to parse_to({:root => {:message => "Error message", :items => ["Value1"]}})
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "handles error response with nested errors correctly" do
|
|
103
|
+
xml = <<-END
|
|
104
|
+
<api-error-response>
|
|
105
|
+
<message>Validation failed</message>
|
|
106
|
+
<errors>
|
|
107
|
+
<errors type="array">
|
|
108
|
+
<error>
|
|
109
|
+
<code>81234</code>
|
|
110
|
+
<message>Field is required</message>
|
|
111
|
+
</error>
|
|
112
|
+
</errors>
|
|
113
|
+
</errors>
|
|
114
|
+
</api-error-response>
|
|
115
|
+
END
|
|
116
|
+
expect(xml).to parse_to({
|
|
117
|
+
:api_error_response => {
|
|
118
|
+
:message => "Validation failed",
|
|
119
|
+
:errors => {
|
|
120
|
+
:errors => [{:code => "81234", :message => "Field is required"}]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "handles client token error response structure" do
|
|
127
|
+
xml = <<-END
|
|
128
|
+
<api-error-response>
|
|
129
|
+
<message>Invalid request</message>
|
|
130
|
+
<errors>
|
|
131
|
+
<errors type="array"></errors>
|
|
132
|
+
</errors>
|
|
133
|
+
</api-error-response>
|
|
134
|
+
END
|
|
135
|
+
result = Braintree::Xml::Parser.hash_from_xml(xml)
|
|
136
|
+
expect(result[:api_error_response]).to be_a(Hash)
|
|
137
|
+
expect(result[:api_error_response][:message]).to eq("Invalid request")
|
|
138
|
+
expect(result[:api_error_response][:errors]).to be_a(Hash)
|
|
139
|
+
expect(result[:api_error_response][:errors][:errors]).to eq([])
|
|
140
|
+
end
|
|
84
141
|
end
|
|
85
142
|
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: 4.33.
|
|
4
|
+
version: 4.33.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Braintree
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: builder
|