braintree 4.22.0 → 4.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/client_token_gateway.rb +2 -2
  3. data/lib/braintree/credit_card_gateway.rb +1 -0
  4. data/lib/braintree/customer.rb +2 -1
  5. data/lib/braintree/customer_gateway.rb +2 -0
  6. data/lib/braintree/error_codes.rb +3 -0
  7. data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
  8. data/lib/braintree/local_payment_completed.rb +2 -0
  9. data/lib/braintree/payment_instrument_type.rb +1 -0
  10. data/lib/braintree/payment_method_gateway.rb +3 -0
  11. data/lib/braintree/payment_method_parser.rb +1 -0
  12. data/lib/braintree/samsung_pay_card.rb +2 -0
  13. data/lib/braintree/test/nonce.rb +1 -0
  14. data/lib/braintree/transaction/local_payment_details.rb +1 -0
  15. data/lib/braintree/transaction/samsung_pay_card_details.rb +2 -0
  16. data/lib/braintree/transaction.rb +2 -1
  17. data/lib/braintree/version.rb +1 -1
  18. data/lib/braintree/webhook_testing_gateway.rb +33 -0
  19. data/lib/braintree.rb +1 -0
  20. data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
  21. data/spec/integration/braintree/client_api/client_token_spec.rb +229 -38
  22. data/spec/integration/braintree/credit_card_spec.rb +2 -2
  23. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  24. data/spec/integration/braintree/customer_spec.rb +23 -2
  25. data/spec/integration/braintree/payment_method_spec.rb +29 -2
  26. data/spec/integration/braintree/samsung_pay_card_spec.rb +3 -1
  27. data/spec/integration/braintree/transaction_spec.rb +0 -21
  28. data/spec/unit/braintree/client_token_spec.rb +1 -1
  29. data/spec/unit/braintree/credit_card_spec.rb +2 -2
  30. data/spec/unit/braintree/customer_spec.rb +1 -0
  31. data/spec/unit/braintree/local_payment_completed_spec.rb +28 -0
  32. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +6 -0
  33. data/spec/unit/braintree/webhook_notification_spec.rb +22 -1
  34. 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
- it "can pass fail_on_duplicate_payment_method" do
144
- config = Braintree::Configuration.instantiate
145
- result = Braintree::Customer.create
146
- customer_id = result.customer.id
147
- raw_client_token = Braintree::ClientToken.generate(
148
- :customer_id => customer_id,
149
- )
150
- client_token = decode_client_token(raw_client_token)
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
- http = ClientApiHttp.new(
153
- config,
154
- :authorization_fingerprint => client_token["authorizationFingerprint"],
155
- :shared_customer_identifier => "fake_identifier",
156
- :shared_customer_identifier_type => "testing",
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
- response = http.add_payment_method(
160
- :credit_card => {
161
- :number => "4111111111111111",
162
- :expiration_month => "11",
163
- :expiration_year => "2099"
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
- expect(response.code).to eq("201")
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
- second_raw_client_token = Braintree::ClientToken.generate(
170
- :customer_id => customer_id,
171
- :options => {
172
- :fail_on_duplicate_payment_method => true
173
- },
174
- )
175
- second_client_token = decode_client_token(second_raw_client_token)
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
- http.fingerprint = second_client_token["authorizationFingerprint"]
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
- response = http.add_payment_method(
180
- :credit_card => {
181
- :number => "4111111111111111",
182
- :expiration_month => "11",
183
- :expiration_year => "2099"
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
- expect(response.code).to eq("422")
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::HiperBRLMerchantAccountId,
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::HiperBRLMerchantAccountId,
1116
+ :verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
1117
1117
  },
1118
1118
  )
1119
1119
  expect(update_result).to be_success
@@ -157,7 +157,7 @@ describe Braintree::CreditCardVerification, "search" do
157
157
  :number => Braintree::Test::CreditCardNumbers::Hiper
158
158
  },
159
159
  :options => {
160
- :merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
160
+ :merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
161
161
  :account_type => "debit",
162
162
  },
163
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::HiperBRLMerchantAccountId,
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::HiperBRLMerchantAccountId,
1688
+ :verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
1668
1689
  :verification_account_type => "debit",
1669
1690
  },
1670
1691
  },
@@ -427,6 +427,33 @@ describe Braintree::PaymentMethod do
427
427
  expect(result.errors.first.code).to eq("81724")
428
428
  end
429
429
 
430
+ it "respects fail_on_duplicate_payment_method_for_customer when included outside of the nonce" do
431
+ customer = Braintree::Customer.create!
432
+ result = Braintree::CreditCard.create(
433
+ :customer_id => customer.id,
434
+ :number => 4111111111111111,
435
+ :expiration_date => "05/2012",
436
+ )
437
+ expect(result).to be_success
438
+
439
+ nonce = nonce_for_new_payment_method(
440
+ :credit_card => {
441
+ :number => 4111111111111111,
442
+ :expiration_date => "05/2012"
443
+ },
444
+ )
445
+ result = Braintree::PaymentMethod.create(
446
+ :payment_method_nonce => nonce,
447
+ :customer_id => customer.id,
448
+ :options => {
449
+ :fail_on_duplicate_payment_method_for_customer => true
450
+ },
451
+ )
452
+
453
+ expect(result).not_to be_success
454
+ expect(result.errors.first.code).to eq("81763")
455
+ end
456
+
430
457
  it "allows passing the billing address outside of the nonce" do
431
458
  config = Braintree::Configuration.instantiate
432
459
  customer = Braintree::Customer.create.customer
@@ -659,7 +686,7 @@ describe Braintree::PaymentMethod do
659
686
  :customer_id => customer.id,
660
687
  :options => {
661
688
  :verify_card => true,
662
- :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
689
+ :verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
663
690
  :verification_account_type => "debit",
664
691
  },
665
692
  )
@@ -776,7 +803,7 @@ describe Braintree::PaymentMethod do
776
803
  :expiration_date => "06/2013",
777
804
  :options => {
778
805
  :verify_card => true,
779
- :verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
806
+ :verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
780
807
  :verification_account_type => "debit",
781
808
  },
782
809
  )
@@ -1,7 +1,9 @@
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::SamsungPayCard do
4
+ # NEXT_MAJOR_VERSION remove these tests
5
+ # SamsungPayCard has been deprecated
6
+ xdescribe Braintree::SamsungPayCard do
5
7
  it "can create from payment method nonce" do
6
8
  customer = Braintree::Customer.create!
7
9
 
@@ -4860,27 +4860,6 @@ describe Braintree::Transaction do
4860
4860
  end
4861
4861
 
4862
4862
  context "external vault" do
4863
- it "returns a validation error if used with an unsupported instrument type" do
4864
- customer = Braintree::Customer.create!
4865
- result = Braintree::PaymentMethod.create(
4866
- :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
4867
- :customer_id => customer.id,
4868
- )
4869
- payment_method_token = result.payment_method.token
4870
-
4871
- result = Braintree::Transaction.create(
4872
- :type => "sale",
4873
- :customer_id => customer.id,
4874
- :payment_method_token => payment_method_token,
4875
- :external_vault => {
4876
- :status => Braintree::Transaction::ExternalVault::Status::WillVault,
4877
- },
4878
- :amount => "10.00",
4879
- )
4880
- expect(result.success?).to eq(false)
4881
- expect(result.errors.for(:transaction)[0].code).to eq(Braintree::ErrorCodes::Transaction::PaymentInstrumentWithExternalVaultIsInvalid)
4882
- end
4883
-
4884
4863
  it "reject invalid status" do
4885
4864
  result = Braintree::Transaction.create(
4886
4865
  :type => "sale",
@@ -23,7 +23,7 @@ module Braintree
23
23
  end
24
24
 
25
25
  context "adding credit_card options with no customer ID" do
26
- %w(verify_card fail_on_duplicate_payment_method make_default).each do |option_name|
26
+ %w(verify_card fail_on_duplicate_payment_method make_default fail_on_duplicate_payment_method_for_customer).each do |option_name|
27
27
  it "raises an ArgumentError if #{option_name} is present" do
28
28
  expect do
29
29
  Braintree::ClientToken.generate(
@@ -25,7 +25,7 @@ describe Braintree::CreditCard do
25
25
  :payment_method_nonce,
26
26
  {:external_vault=>[:network_transaction_id]},
27
27
  {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
28
- :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
28
+ :fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
29
29
  {:billing_address => [
30
30
  :company,
31
31
  :country_code_alpha2,
@@ -73,7 +73,7 @@ describe Braintree::CreditCard do
73
73
  :payment_method_nonce,
74
74
  {:external_vault=>[:network_transaction_id]},
75
75
  {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
76
- :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
76
+ :fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :verification_account_type, :verification_currency_iso_code])},
77
77
  {:billing_address => [
78
78
  :company,
79
79
  :country_code_alpha2,
@@ -209,6 +209,7 @@ describe Braintree::Customer do
209
209
  :verification_amount,
210
210
  :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
211
211
  :fail_on_duplicate_payment_method,
212
+ :fail_on_duplicate_payment_method_for_customer,
212
213
  :verification_account_type,
213
214
  :verification_currency_iso_code,
214
215
  :update_existing_token
@@ -51,6 +51,34 @@ describe Braintree::LocalPaymentCompleted do
51
51
  local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
52
52
 
53
53
  expect(local_payment_completed.bic).to eq("a-bic")
54
+ expect(local_payment_completed.blik_aliases).to be_nil
55
+ expect(local_payment_completed.iban_last_chars).to eq("1234")
56
+ expect(local_payment_completed.payer_id).to eq("a-payer-id")
57
+ expect(local_payment_completed.payer_name).to eq("John Doe")
58
+ expect(local_payment_completed.payment_id).to eq("a-payment-id")
59
+ expect(local_payment_completed.payment_method_nonce).to eq("a-nonce")
60
+ expect(local_payment_completed.transaction).to be_nil
61
+ end
62
+
63
+ it "initializes the object with the appropriate attributes when blik_aliases is provided" do
64
+ params = {
65
+ bic: "a-bic",
66
+ blik_aliases: [
67
+ {
68
+ key: "an-alias-key",
69
+ label: "an-alias-label"
70
+ }
71
+ ],
72
+ iban_last_chars: "1234",
73
+ payer_id: "a-payer-id",
74
+ payer_name: "John Doe",
75
+ payment_id: "a-payment-id",
76
+ payment_method_nonce: "a-nonce",
77
+ }
78
+ local_payment_completed = Braintree::LocalPaymentCompleted._new(params)
79
+
80
+ expect(local_payment_completed.bic).to eq("a-bic")
81
+ expect(local_payment_completed.blik_aliases).to match_array([{key: "an-alias-key", label: "an-alias-label"}])
54
82
  expect(local_payment_completed.iban_last_chars).to eq("1234")
55
83
  expect(local_payment_completed.payer_id).to eq("a-payer-id")
56
84
  expect(local_payment_completed.payer_name).to eq("John Doe")
@@ -4,6 +4,12 @@ describe Braintree::Transaction::LocalPaymentDetails do
4
4
  describe "initialize" do
5
5
  let(:params) do
6
6
  {
7
+ blik_aliases: [
8
+ {
9
+ key: "a-key",
10
+ label: "a-label"
11
+ }
12
+ ],
7
13
  capture_id: "a-capture-id",
8
14
  custom_field: "custom-field",
9
15
  debug_id: "debug-id",
@@ -723,14 +723,35 @@ describe Braintree::WebhookNotification do
723
723
  expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::LocalPaymentCompleted)
724
724
 
725
725
  local_payment_completed = notification.local_payment_completed
726
- expect(local_payment_completed.payment_id).to eq("PAY-XYZ123")
726
+ expect(local_payment_completed.blik_aliases).to be_nil
727
727
  expect(local_payment_completed.payer_id).to eq("ABCPAYER")
728
+ expect(local_payment_completed.payment_id).to eq("PAY-XYZ123")
728
729
  expect(local_payment_completed.payment_method_nonce).to eq("ee257d98-de40-47e8-96b3-a6954ea7a9a4")
729
730
  expect(local_payment_completed.transaction.id).to eq("my_id")
730
731
  expect(local_payment_completed.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
731
732
  expect(local_payment_completed.transaction.amount).to eq(49.99)
732
733
  expect(local_payment_completed.transaction.order_id).to eq("order4567")
733
734
  end
735
+
736
+ it "builds a sample notification for a local_payment webhook when funding source is blik one click" do
737
+ sample_notification = Braintree::WebhookTesting.sample_notification(
738
+ Braintree::WebhookNotification::Kind::LocalPaymentCompleted,
739
+ "blik_one_click_id",
740
+ )
741
+
742
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
743
+ expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::LocalPaymentCompleted)
744
+
745
+ local_payment_completed = notification.local_payment_completed
746
+ expect(local_payment_completed.blik_aliases).to match_array([{:key => "alias-key-1", :label => "alias-label-1"}])
747
+ expect(local_payment_completed.payer_id).to eq("ABCPAYER")
748
+ expect(local_payment_completed.payment_id).to eq("PAY-XYZ123")
749
+ expect(local_payment_completed.payment_method_nonce).to eq("ee257d98-de40-47e8-96b3-a6954ea7a9a4")
750
+ expect(local_payment_completed.transaction.id).to eq("blik_one_click_id")
751
+ expect(local_payment_completed.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
752
+ expect(local_payment_completed.transaction.amount).to eq(49.99)
753
+ expect(local_payment_completed.transaction.order_id).to eq("order4567")
754
+ end
734
755
  end
735
756
 
736
757
  context "local_payment_expired" 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: 4.22.0
4
+ version: 4.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-20 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -111,6 +111,7 @@ files:
111
111
  - lib/braintree/graphql_client.rb
112
112
  - lib/braintree/http.rb
113
113
  - lib/braintree/local_payment_completed.rb
114
+ - lib/braintree/local_payment_completed/blik_alias.rb
114
115
  - lib/braintree/local_payment_expired.rb
115
116
  - lib/braintree/local_payment_funded.rb
116
117
  - lib/braintree/local_payment_reversed.rb