braintree 4.21.0 → 4.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/client_token_gateway.rb +2 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification.rb +16 -12
- data/lib/braintree/customer.rb +2 -1
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/error_codes.rb +3 -0
- data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
- data/lib/braintree/local_payment_completed.rb +6 -1
- data/lib/braintree/payment_instrument_type.rb +1 -0
- data/lib/braintree/payment_method_gateway.rb +3 -0
- data/lib/braintree/payment_method_parser.rb +1 -0
- data/lib/braintree/paypal_account.rb +1 -0
- data/lib/braintree/samsung_pay_card.rb +2 -0
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/transaction/local_payment_details.rb +1 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +2 -0
- data/lib/braintree/transaction.rb +3 -1
- data/lib/braintree/transaction_gateway.rb +48 -46
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +36 -0
- data/lib/braintree.rb +1 -0
- data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
- data/spec/integration/braintree/apple_pay_spec.rb +1 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +229 -38
- data/spec/integration/braintree/credit_card_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +20 -1
- data/spec/integration/braintree/customer_spec.rb +23 -2
- data/spec/integration/braintree/merchant_account_spec.rb +2 -2
- data/spec/integration/braintree/merchant_spec.rb +17 -138
- data/spec/integration/braintree/payment_method_spec.rb +29 -2
- data/spec/integration/braintree/paypal_account_spec.rb +1 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +3 -1
- data/spec/integration/braintree/transaction_spec.rb +56 -22
- data/spec/unit/braintree/client_token_spec.rb +1 -1
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +2 -2
- data/spec/unit/braintree/credit_card_verification_spec.rb +13 -2
- data/spec/unit/braintree/customer_spec.rb +1 -0
- data/spec/unit/braintree/error_result_spec.rb +1 -1
- data/spec/unit/braintree/local_payment_completed_spec.rb +44 -4
- data/spec/unit/braintree/paypal_account_spec.rb +9 -0
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +6 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +50 -48
- data/spec/unit/braintree/webhook_notification_spec.rb +22 -1
- metadata +3 -2
@@ -140,51 +140,242 @@ describe Braintree::ClientToken do
|
|
140
140
|
expect(customer.credit_cards.select { |c| c.bin == "400551" }[0]).to be_default
|
141
141
|
end
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
143
|
+
context "fail on duplicate payment methods check" do
|
144
|
+
context "card exists for a different customer" do
|
145
|
+
before(:each) do
|
146
|
+
config = Braintree::Configuration.instantiate
|
147
|
+
result = Braintree::Customer.create
|
148
|
+
customer_id = result.customer.id
|
149
|
+
raw_client_token = Braintree::ClientToken.generate(
|
150
|
+
:customer_id => customer_id,
|
151
|
+
)
|
152
|
+
client_token = decode_client_token(raw_client_token)
|
151
153
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
154
|
+
http = ClientApiHttp.new(
|
155
|
+
config,
|
156
|
+
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
157
|
+
:shared_customer_identifier => "fake_identifier",
|
158
|
+
:shared_customer_identifier_type => "testing",
|
159
|
+
)
|
160
|
+
|
161
|
+
response = http.add_payment_method(
|
162
|
+
:credit_card => {
|
163
|
+
:number => "4111111111111111",
|
164
|
+
:expiration_month => "11",
|
165
|
+
:expiration_year => "2099"
|
166
|
+
},
|
167
|
+
)
|
168
|
+
expect(response.code).to eq("201")
|
169
|
+
end
|
158
170
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
171
|
+
it "does not create when fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = false" do
|
172
|
+
result = Braintree::Customer.create
|
173
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
174
|
+
:customer_id => result.customer_id,
|
175
|
+
:options => {
|
176
|
+
:fail_on_duplicate_payment_method => true,
|
177
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
178
|
+
},
|
179
|
+
)
|
180
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
181
|
+
|
182
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
183
|
+
|
184
|
+
response = http.add_payment_method(
|
185
|
+
:credit_card => {
|
186
|
+
:number => "4111111111111111",
|
187
|
+
:expiration_month => "11",
|
188
|
+
:expiration_year => "2099"
|
189
|
+
},
|
190
|
+
)
|
191
|
+
expect(response.code).to eq("201")
|
192
|
+
end
|
166
193
|
|
167
|
-
|
194
|
+
it "creates when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = true" do
|
195
|
+
result = Braintree::Customer.create
|
196
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
197
|
+
:customer_id => result.customer_id,
|
198
|
+
:options => {
|
199
|
+
:fail_on_duplicate_payment_method => true,
|
200
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
201
|
+
},
|
202
|
+
)
|
203
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
204
|
+
|
205
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
206
|
+
|
207
|
+
response = http.add_payment_method(
|
208
|
+
:credit_card => {
|
209
|
+
:number => "4111111111111111",
|
210
|
+
:expiration_month => "11",
|
211
|
+
:expiration_year => "2099"
|
212
|
+
},
|
213
|
+
)
|
214
|
+
expect(response.code).to eq("201")
|
215
|
+
end
|
168
216
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
217
|
+
it "does not create fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = true" do
|
218
|
+
result = Braintree::Customer.create
|
219
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
220
|
+
:customer_id => result.customer_id,
|
221
|
+
:options => {
|
222
|
+
:fail_on_duplicate_payment_method => true,
|
223
|
+
:fail_on_duplicate_payment_method_for_customer => true
|
224
|
+
},
|
225
|
+
)
|
226
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
227
|
+
|
228
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
229
|
+
|
230
|
+
response = http.add_payment_method(
|
231
|
+
:credit_card => {
|
232
|
+
:number => "4111111111111111",
|
233
|
+
:expiration_month => "11",
|
234
|
+
:expiration_year => "2099"
|
235
|
+
},
|
236
|
+
)
|
237
|
+
expect(response.code).to eq("422")
|
238
|
+
end
|
176
239
|
|
177
|
-
|
240
|
+
it "creates when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = false" do
|
241
|
+
result = Braintree::Customer.create
|
242
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
243
|
+
:customer_id => result.customer_id,
|
244
|
+
:options => {
|
245
|
+
:fail_on_duplicate_payment_method => false,
|
246
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
247
|
+
},
|
248
|
+
)
|
249
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
250
|
+
|
251
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
252
|
+
|
253
|
+
response = http.add_payment_method(
|
254
|
+
:credit_card => {
|
255
|
+
:number => "4111111111111111",
|
256
|
+
:expiration_month => "11",
|
257
|
+
:expiration_year => "2099"
|
258
|
+
},
|
259
|
+
)
|
260
|
+
expect(response.code).to eq("201")
|
261
|
+
end
|
262
|
+
end
|
178
263
|
|
179
|
-
|
180
|
-
:
|
181
|
-
|
182
|
-
|
183
|
-
:
|
184
|
-
|
185
|
-
|
264
|
+
context "card exists for a same customer" do
|
265
|
+
before(:each) do
|
266
|
+
config = Braintree::Configuration.instantiate
|
267
|
+
result = Braintree::Customer.create
|
268
|
+
let(:customer_id) { result.customer.id }
|
269
|
+
raw_client_token = Braintree::ClientToken.generate(
|
270
|
+
:customer_id => customer_id,
|
271
|
+
)
|
272
|
+
client_token = decode_client_token(raw_client_token)
|
186
273
|
|
187
|
-
|
274
|
+
http = ClientApiHttp.new(
|
275
|
+
config,
|
276
|
+
:authorization_fingerprint => client_token["authorizationFingerprint"],
|
277
|
+
:shared_customer_identifier => "fake_identifier",
|
278
|
+
:shared_customer_identifier_type => "testing",
|
279
|
+
)
|
280
|
+
|
281
|
+
response = http.add_payment_method(
|
282
|
+
:credit_card => {
|
283
|
+
:number => "4111111111111111",
|
284
|
+
:expiration_month => "11",
|
285
|
+
:expiration_year => "2099"
|
286
|
+
},
|
287
|
+
)
|
288
|
+
expect(response.code).to eq("201")
|
289
|
+
end
|
290
|
+
|
291
|
+
it "creates when fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = false for same customer" do
|
292
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
293
|
+
:customer_id => customer_id,
|
294
|
+
:options => {
|
295
|
+
:fail_on_duplicate_payment_method => true,
|
296
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
297
|
+
},
|
298
|
+
)
|
299
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
300
|
+
|
301
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
302
|
+
|
303
|
+
response = http.add_payment_method(
|
304
|
+
:credit_card => {
|
305
|
+
:number => "4111111111111111",
|
306
|
+
:expiration_month => "11",
|
307
|
+
:expiration_year => "2099"
|
308
|
+
},
|
309
|
+
)
|
310
|
+
expect(response.code).to eq("201")
|
311
|
+
end
|
312
|
+
|
313
|
+
it "does not create when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = true for same customer" do
|
314
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
315
|
+
:customer_id => customer_id,
|
316
|
+
:options => {
|
317
|
+
:fail_on_duplicate_payment_method => false,
|
318
|
+
:fail_on_duplicate_payment_method_for_customer => true
|
319
|
+
},
|
320
|
+
)
|
321
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
322
|
+
|
323
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
324
|
+
|
325
|
+
response = http.add_payment_method(
|
326
|
+
:credit_card => {
|
327
|
+
:number => "4111111111111111",
|
328
|
+
:expiration_month => "11",
|
329
|
+
:expiration_year => "2099"
|
330
|
+
},
|
331
|
+
)
|
332
|
+
expect(response.code).to eq("422")
|
333
|
+
end
|
334
|
+
|
335
|
+
it "does not create when fail_on_duplicate_payment_method = true and fail_on_duplicate_payment_method_for_customer = true for same customer" do
|
336
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
337
|
+
:customer_id => customer_id,
|
338
|
+
:options => {
|
339
|
+
:fail_on_duplicate_payment_method => true,
|
340
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
341
|
+
},
|
342
|
+
)
|
343
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
344
|
+
|
345
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
346
|
+
|
347
|
+
response = http.add_payment_method(
|
348
|
+
:credit_card => {
|
349
|
+
:number => "4111111111111111",
|
350
|
+
:expiration_month => "11",
|
351
|
+
:expiration_year => "2099"
|
352
|
+
},
|
353
|
+
)
|
354
|
+
expect(response.code).to eq("422")
|
355
|
+
end
|
356
|
+
|
357
|
+
it "creates when fail_on_duplicate_payment_method = false and fail_on_duplicate_payment_method_for_customer = false for same customer" do
|
358
|
+
second_raw_client_token = Braintree::ClientToken.generate(
|
359
|
+
:customer_id => customer_id,
|
360
|
+
:options => {
|
361
|
+
:fail_on_duplicate_payment_method => false,
|
362
|
+
:fail_on_duplicate_payment_method_for_customer => false
|
363
|
+
},
|
364
|
+
)
|
365
|
+
second_client_token = decode_client_token(second_raw_client_token)
|
366
|
+
|
367
|
+
http.fingerprint = second_client_token["authorizationFingerprint"]
|
368
|
+
|
369
|
+
response = http.add_payment_method(
|
370
|
+
:credit_card => {
|
371
|
+
:number => "4111111111111111",
|
372
|
+
:expiration_month => "11",
|
373
|
+
:expiration_year => "2099"
|
374
|
+
},
|
375
|
+
)
|
376
|
+
expect(response.code).to eq("201")
|
377
|
+
end
|
378
|
+
end
|
188
379
|
end
|
189
380
|
|
190
381
|
it "can pass merchant_account_id" do
|
@@ -622,7 +622,7 @@ describe Braintree::CreditCard do
|
|
622
622
|
:expiration_year => "2099",
|
623
623
|
:options => {
|
624
624
|
:verify_card => true,
|
625
|
-
:verification_merchant_account_id => SpecHelper::
|
625
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
626
626
|
:verification_account_type => "debit",
|
627
627
|
},
|
628
628
|
)
|
@@ -1113,7 +1113,7 @@ describe Braintree::CreditCard do
|
|
1113
1113
|
:options => {
|
1114
1114
|
:verify_card => true,
|
1115
1115
|
:verification_account_type => "debit",
|
1116
|
-
:verification_merchant_account_id => SpecHelper::
|
1116
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
1117
1117
|
},
|
1118
1118
|
)
|
1119
1119
|
expect(update_result).to be_success
|
@@ -48,6 +48,25 @@ describe Braintree::CreditCardVerification, "search" do
|
|
48
48
|
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
49
49
|
end
|
50
50
|
|
51
|
+
it "creates a new verification for Visa ANI" do
|
52
|
+
verification_params = {
|
53
|
+
:credit_card => {
|
54
|
+
:expiration_date => "05/2012",
|
55
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
56
|
+
},
|
57
|
+
}
|
58
|
+
|
59
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
60
|
+
|
61
|
+
expect(result).to be_success
|
62
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
63
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
64
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
65
|
+
expect(result.credit_card_verification.ani_first_name_response_code).to eq("I")
|
66
|
+
expect(result.credit_card_verification.ani_last_name_response_code).to eq("I")
|
67
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
68
|
+
end
|
69
|
+
|
51
70
|
it "creates a new verification from external vault param" do
|
52
71
|
verification_params = {
|
53
72
|
:credit_card => {
|
@@ -138,7 +157,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
138
157
|
:number => Braintree::Test::CreditCardNumbers::Hiper
|
139
158
|
},
|
140
159
|
:options => {
|
141
|
-
:merchant_account_id => SpecHelper::
|
160
|
+
:merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
142
161
|
:account_type => "debit",
|
143
162
|
},
|
144
163
|
)
|
@@ -620,7 +620,7 @@ describe Braintree::Customer do
|
|
620
620
|
:credit_card => {
|
621
621
|
:options => {
|
622
622
|
:verify_card => true,
|
623
|
-
:verification_merchant_account_id => SpecHelper::
|
623
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
624
624
|
:verification_account_type => "debit",
|
625
625
|
}
|
626
626
|
},
|
@@ -1231,6 +1231,27 @@ describe Braintree::Customer do
|
|
1231
1231
|
expect(result.errors.for(:customer).for(:credit_card).on(:number)[0].message).to eq("Duplicate card exists in the vault.")
|
1232
1232
|
end
|
1233
1233
|
|
1234
|
+
it "does not update customer with duplicate payment method if fail_on_payment_method_for_customer option set" do
|
1235
|
+
customer = Braintree::Customer.create!(
|
1236
|
+
:credit_card => {
|
1237
|
+
:number => 4111111111111111,
|
1238
|
+
:expiration_date => "05/2010",
|
1239
|
+
},
|
1240
|
+
)
|
1241
|
+
result = Braintree::Customer.update(
|
1242
|
+
customer.id,
|
1243
|
+
:credit_card => {
|
1244
|
+
:number => 4111111111111111,
|
1245
|
+
:expiration_date => "05/2010",
|
1246
|
+
:options=> {
|
1247
|
+
:fail_on_duplicate_payment_method_for_customer => true
|
1248
|
+
}
|
1249
|
+
},
|
1250
|
+
)
|
1251
|
+
expect(result.success?).to eq(false)
|
1252
|
+
expect(result.errors.for(:customer).for(:credit_card).on(:number)[0].message).to eq("Duplicate card exists in the vault for the customer.")
|
1253
|
+
end
|
1254
|
+
|
1234
1255
|
it "updates the default payment method" do
|
1235
1256
|
customer = Braintree::Customer.create!(
|
1236
1257
|
:first_name => "Joe",
|
@@ -1664,7 +1685,7 @@ describe Braintree::Customer do
|
|
1664
1685
|
:expiration_date => "06/2013",
|
1665
1686
|
:options => {
|
1666
1687
|
:verify_card => true,
|
1667
|
-
:verification_merchant_account_id => SpecHelper::
|
1688
|
+
:verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
|
1668
1689
|
:verification_account_type => "debit",
|
1669
1690
|
},
|
1670
1691
|
},
|
@@ -97,7 +97,7 @@ describe Braintree::MerchantAccount do
|
|
97
97
|
|
98
98
|
result = gateway.merchant.create(
|
99
99
|
:email => "name@email.com",
|
100
|
-
:country_code_alpha3 => "
|
100
|
+
:country_code_alpha3 => "GBR",
|
101
101
|
:payment_methods => ["credit_card", "paypal"],
|
102
102
|
)
|
103
103
|
|
@@ -109,7 +109,7 @@ describe Braintree::MerchantAccount do
|
|
109
109
|
result = gateway.merchant_account.all
|
110
110
|
expect(result).to be_success
|
111
111
|
expect(result.merchant_accounts.count).to eq(1)
|
112
|
-
expect(result.merchant_accounts.first.currency_iso_code).to eq("
|
112
|
+
expect(result.merchant_accounts.first.currency_iso_code).to eq("GBP")
|
113
113
|
expect(result.merchant_accounts.first.status).to eq("active")
|
114
114
|
expect(result.merchant_accounts.first.default).to eq(true)
|
115
115
|
end
|
@@ -11,7 +11,7 @@ describe Braintree::MerchantGateway do
|
|
11
11
|
|
12
12
|
result = gateway.merchant.create(
|
13
13
|
:email => "name@email.com",
|
14
|
-
:country_code_alpha3 => "
|
14
|
+
:country_code_alpha3 => "GBR",
|
15
15
|
:payment_methods => ["credit_card", "paypal"],
|
16
16
|
)
|
17
17
|
|
@@ -21,10 +21,10 @@ describe Braintree::MerchantGateway do
|
|
21
21
|
expect(merchant.id).not_to be_nil
|
22
22
|
expect(merchant.email).to eq("name@email.com")
|
23
23
|
expect(merchant.company_name).to eq("name@email.com")
|
24
|
-
expect(merchant.country_code_alpha3).to eq("
|
25
|
-
expect(merchant.country_code_alpha2).to eq("
|
26
|
-
expect(merchant.country_code_numeric).to eq("
|
27
|
-
expect(merchant.country_name).to eq("United
|
24
|
+
expect(merchant.country_code_alpha3).to eq("GBR")
|
25
|
+
expect(merchant.country_code_alpha2).to eq("GB")
|
26
|
+
expect(merchant.country_code_numeric).to eq("826")
|
27
|
+
expect(merchant.country_name).to eq("United Kingdom")
|
28
28
|
|
29
29
|
credentials = result.credentials
|
30
30
|
expect(credentials.access_token).not_to be_nil
|
@@ -42,7 +42,7 @@ describe Braintree::MerchantGateway do
|
|
42
42
|
|
43
43
|
result = gateway.merchant.create(
|
44
44
|
:email => "name@email.com",
|
45
|
-
:country_code_alpha3 => "
|
45
|
+
:country_code_alpha3 => "GBR",
|
46
46
|
:payment_methods => ["fake_money"],
|
47
47
|
)
|
48
48
|
|
@@ -70,7 +70,7 @@ describe Braintree::MerchantGateway do
|
|
70
70
|
)
|
71
71
|
result = gateway.merchant.create(
|
72
72
|
:email => "name@email.com",
|
73
|
-
:country_code_alpha3 => "
|
73
|
+
:country_code_alpha3 => "GBR",
|
74
74
|
:payment_methods => ["credit_card", "paypal"],
|
75
75
|
)
|
76
76
|
|
@@ -81,47 +81,12 @@ describe Braintree::MerchantGateway do
|
|
81
81
|
context "multiple currencies" do
|
82
82
|
before(:each) do
|
83
83
|
@gateway = Braintree::Gateway.new(
|
84
|
-
:client_id => "client_id$
|
85
|
-
:client_secret => "client_secret$
|
84
|
+
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
85
|
+
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
86
86
|
:logger => Logger.new("/dev/null"),
|
87
87
|
)
|
88
88
|
end
|
89
89
|
|
90
|
-
it "creates a US multi currency merchant for paypal and credit_card" do
|
91
|
-
result = @gateway.merchant.create(
|
92
|
-
:email => "name@email.com",
|
93
|
-
:country_code_alpha3 => "USA",
|
94
|
-
:payment_methods => ["credit_card", "paypal"],
|
95
|
-
:currencies => ["GBP", "USD"],
|
96
|
-
)
|
97
|
-
|
98
|
-
merchant = result.merchant
|
99
|
-
expect(merchant.id).not_to be_nil
|
100
|
-
expect(merchant.email).to eq("name@email.com")
|
101
|
-
expect(merchant.company_name).to eq("name@email.com")
|
102
|
-
expect(merchant.country_code_alpha3).to eq("USA")
|
103
|
-
expect(merchant.country_code_alpha2).to eq("US")
|
104
|
-
expect(merchant.country_code_numeric).to eq("840")
|
105
|
-
expect(merchant.country_name).to eq("United States of America")
|
106
|
-
|
107
|
-
credentials = result.credentials
|
108
|
-
expect(credentials.access_token).not_to be_nil
|
109
|
-
expect(credentials.refresh_token).not_to be_nil
|
110
|
-
expect(credentials.expires_at).not_to be_nil
|
111
|
-
expect(credentials.token_type).to eq("bearer")
|
112
|
-
|
113
|
-
merchant_accounts = merchant.merchant_accounts
|
114
|
-
expect(merchant_accounts.count).to eq(2)
|
115
|
-
|
116
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
117
|
-
expect(merchant_account.default).to eq(true)
|
118
|
-
expect(merchant_account.currency_iso_code).to eq("USD")
|
119
|
-
|
120
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
|
121
|
-
expect(merchant_account.default).to eq(false)
|
122
|
-
expect(merchant_account.currency_iso_code).to eq("GBP")
|
123
|
-
end
|
124
|
-
|
125
90
|
it "creates an EU multi currency merchant for paypal and credit_card" do
|
126
91
|
result = @gateway.merchant.create(
|
127
92
|
:email => "name@email.com",
|
@@ -161,7 +126,7 @@ describe Braintree::MerchantGateway do
|
|
161
126
|
it "creates a paypal-only merchant that accepts multiple currencies" do
|
162
127
|
result = @gateway.merchant.create(
|
163
128
|
:email => "name@email.com",
|
164
|
-
:country_code_alpha3 => "
|
129
|
+
:country_code_alpha3 => "GBR",
|
165
130
|
:payment_methods => ["paypal"],
|
166
131
|
:currencies => ["GBP", "USD"],
|
167
132
|
:paypal_account => {
|
@@ -176,10 +141,10 @@ describe Braintree::MerchantGateway do
|
|
176
141
|
expect(merchant.id).not_to be_nil
|
177
142
|
expect(merchant.email).to eq("name@email.com")
|
178
143
|
expect(merchant.company_name).to eq("name@email.com")
|
179
|
-
expect(merchant.country_code_alpha3).to eq("
|
180
|
-
expect(merchant.country_code_alpha2).to eq("
|
181
|
-
expect(merchant.country_code_numeric).to eq("
|
182
|
-
expect(merchant.country_name).to eq("United
|
144
|
+
expect(merchant.country_code_alpha3).to eq("GBR")
|
145
|
+
expect(merchant.country_code_alpha2).to eq("GB")
|
146
|
+
expect(merchant.country_code_numeric).to eq("826")
|
147
|
+
expect(merchant.country_name).to eq("United Kingdom")
|
183
148
|
|
184
149
|
credentials = result.credentials
|
185
150
|
expect(credentials.access_token).not_to be_nil
|
@@ -191,90 +156,18 @@ describe Braintree::MerchantGateway do
|
|
191
156
|
expect(merchant_accounts.count).to eq(2)
|
192
157
|
|
193
158
|
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
194
|
-
expect(merchant_account.default).to eq(
|
159
|
+
expect(merchant_account.default).to eq(false)
|
195
160
|
expect(merchant_account.currency_iso_code).to eq("USD")
|
196
161
|
|
197
162
|
merchant_account = merchant_accounts.detect { |ma| ma.id == "GBP" }
|
198
|
-
expect(merchant_account.default).to eq(false)
|
199
|
-
expect(merchant_account.currency_iso_code).to eq("GBP")
|
200
|
-
end
|
201
|
-
|
202
|
-
it "allows creation of non-US merchant if onboarding application is internal" do
|
203
|
-
result = @gateway.merchant.create(
|
204
|
-
:email => "name@email.com",
|
205
|
-
:country_code_alpha3 => "JPN",
|
206
|
-
:payment_methods => ["paypal"],
|
207
|
-
:paypal_account => {
|
208
|
-
:client_id => "paypal_client_id",
|
209
|
-
:client_secret => "paypal_client_secret",
|
210
|
-
},
|
211
|
-
)
|
212
|
-
|
213
|
-
expect(result).to be_success
|
214
|
-
|
215
|
-
merchant = result.merchant
|
216
|
-
expect(merchant.id).not_to be_nil
|
217
|
-
expect(merchant.email).to eq("name@email.com")
|
218
|
-
expect(merchant.company_name).to eq("name@email.com")
|
219
|
-
expect(merchant.country_code_alpha3).to eq("JPN")
|
220
|
-
expect(merchant.country_code_alpha2).to eq("JP")
|
221
|
-
expect(merchant.country_code_numeric).to eq("392")
|
222
|
-
expect(merchant.country_name).to eq("Japan")
|
223
|
-
|
224
|
-
credentials = result.credentials
|
225
|
-
expect(credentials.access_token).not_to be_nil
|
226
|
-
expect(credentials.refresh_token).not_to be_nil
|
227
|
-
expect(credentials.expires_at).not_to be_nil
|
228
|
-
expect(credentials.token_type).to eq("bearer")
|
229
|
-
|
230
|
-
merchant_accounts = merchant.merchant_accounts
|
231
|
-
expect(merchant_accounts.count).to eq(1)
|
232
|
-
|
233
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "JPY" }
|
234
163
|
expect(merchant_account.default).to eq(true)
|
235
|
-
expect(merchant_account.currency_iso_code).to eq("
|
236
|
-
end
|
237
|
-
|
238
|
-
it "defaults to USD for non-US merchant if onboarding application is internal and country currency not supported" do
|
239
|
-
result = @gateway.merchant.create(
|
240
|
-
:email => "name@email.com",
|
241
|
-
:country_code_alpha3 => "YEM",
|
242
|
-
:payment_methods => ["paypal"],
|
243
|
-
:paypal_account => {
|
244
|
-
:client_id => "paypal_client_id",
|
245
|
-
:client_secret => "paypal_client_secret",
|
246
|
-
},
|
247
|
-
)
|
248
|
-
|
249
|
-
expect(result).to be_success
|
250
|
-
|
251
|
-
merchant = result.merchant
|
252
|
-
expect(merchant.id).not_to be_nil
|
253
|
-
expect(merchant.email).to eq("name@email.com")
|
254
|
-
expect(merchant.company_name).to eq("name@email.com")
|
255
|
-
expect(merchant.country_code_alpha3).to eq("YEM")
|
256
|
-
expect(merchant.country_code_alpha2).to eq("YE")
|
257
|
-
expect(merchant.country_code_numeric).to eq("887")
|
258
|
-
expect(merchant.country_name).to eq("Yemen")
|
259
|
-
|
260
|
-
credentials = result.credentials
|
261
|
-
expect(credentials.access_token).not_to be_nil
|
262
|
-
expect(credentials.refresh_token).not_to be_nil
|
263
|
-
expect(credentials.expires_at).not_to be_nil
|
264
|
-
expect(credentials.token_type).to eq("bearer")
|
265
|
-
|
266
|
-
merchant_accounts = merchant.merchant_accounts
|
267
|
-
expect(merchant_accounts.count).to eq(1)
|
268
|
-
|
269
|
-
merchant_account = merchant_accounts.detect { |ma| ma.id == "USD" }
|
270
|
-
expect(merchant_account.default).to eq(true)
|
271
|
-
expect(merchant_account.currency_iso_code).to eq("USD")
|
164
|
+
expect(merchant_account.currency_iso_code).to eq("GBP")
|
272
165
|
end
|
273
166
|
|
274
167
|
it "returns error if invalid currency is passed" do
|
275
168
|
result = @gateway.merchant.create(
|
276
169
|
:email => "name@email.com",
|
277
|
-
:country_code_alpha3 => "
|
170
|
+
:country_code_alpha3 => "GBR",
|
278
171
|
:payment_methods => ["paypal"],
|
279
172
|
:currencies => ["FAKE", "GBP"],
|
280
173
|
:paypal_account => {
|
@@ -317,20 +210,6 @@ describe Braintree::MerchantGateway do
|
|
317
210
|
end
|
318
211
|
end
|
319
212
|
|
320
|
-
context "merchant has no processor connection supporting apple pay" do
|
321
|
-
before do
|
322
|
-
Braintree::Configuration.merchant_id = "forward_payment_method_merchant_id"
|
323
|
-
Braintree::Configuration.public_key = "forward_payment_method_public_key"
|
324
|
-
Braintree::Configuration.private_key = "forward_payment_method_private_key"
|
325
|
-
end
|
326
|
-
|
327
|
-
it "returns a validation error" do
|
328
|
-
result = Braintree::Merchant.provision_raw_apple_pay
|
329
|
-
expect(result).not_to be_success
|
330
|
-
expect(result.errors.for(:apple_pay).first.code).to eq(Braintree::ErrorCodes::ApplePay::ApplePayCardsAreNotAccepted)
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
213
|
def _save_config
|
335
214
|
@original_config = {
|
336
215
|
:merchant_id => Braintree::Configuration.merchant_id,
|