braintree 4.0.0 → 4.4.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/braintree.gemspec +1 -0
  3. data/lib/braintree.rb +2 -0
  4. data/lib/braintree/apple_pay_card.rb +9 -0
  5. data/lib/braintree/credit_card_gateway.rb +11 -1
  6. data/lib/braintree/error_codes.rb +4 -2
  7. data/lib/braintree/google_pay_card.rb +9 -0
  8. data/lib/braintree/http.rb +1 -0
  9. data/lib/braintree/local_payment_expired.rb +21 -0
  10. data/lib/braintree/local_payment_funded.rb +22 -0
  11. data/lib/braintree/payment_method_gateway.rb +7 -2
  12. data/lib/braintree/payment_method_nonce.rb +6 -3
  13. data/lib/braintree/transaction/paypal_details.rb +2 -0
  14. data/lib/braintree/transaction_gateway.rb +3 -3
  15. data/lib/braintree/version.rb +1 -1
  16. data/lib/braintree/webhook_notification.rb +8 -1
  17. data/lib/braintree/webhook_testing_gateway.rb +51 -2
  18. data/spec/integration/braintree/credit_card_spec.rb +89 -0
  19. data/spec/integration/braintree/customer_spec.rb +117 -0
  20. data/spec/integration/braintree/merchant_account_spec.rb +3 -3
  21. data/spec/integration/braintree/payment_method_nonce_spec.rb +2 -0
  22. data/spec/integration/braintree/payment_method_spec.rb +131 -0
  23. data/spec/integration/braintree/transaction_spec.rb +82 -2
  24. data/spec/spec_helper.rb +1 -0
  25. data/spec/unit/braintree/credit_card_spec.rb +6 -6
  26. data/spec/unit/braintree/customer_spec.rb +8 -7
  27. data/spec/unit/braintree/http_spec.rb +2 -0
  28. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  29. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  30. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  31. data/spec/unit/braintree/transaction/paypal_details_spec.rb +4 -0
  32. data/spec/unit/braintree/transaction_spec.rb +3 -3
  33. data/spec/unit/braintree/webhook_notification_spec.rb +50 -1
  34. metadata +22 -3
data/spec/spec_helper.rb CHANGED
@@ -42,6 +42,7 @@ unless defined?(SPEC_HELPER_LOADED)
42
42
  HiperBRLMerchantAccountId = "hiper_brl"
43
43
  CardProcessorBRLMerchantAccountId = "card_processor_brl"
44
44
  FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
45
+ AibSwedenMaMerchantAccountId = "aib_swe_ma"
45
46
 
46
47
  TrialPlan = {
47
48
  :description => "Plan for integration tests -- with trial",
@@ -11,7 +11,7 @@ describe Braintree::CreditCard do
11
11
 
12
12
  describe "self.create_signature" do
13
13
  it "should be what we expect" do
14
- Braintree::CreditCardGateway._create_signature.should == [
14
+ expect(Braintree::CreditCardGateway._create_signature).to match([
15
15
  :billing_address_id,
16
16
  :cardholder_name,
17
17
  :cvv,
@@ -24,7 +24,7 @@ describe Braintree::CreditCard do
24
24
  :device_data,
25
25
  :payment_method_nonce,
26
26
  {:external_vault=>[:network_transaction_id]},
27
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code]},
27
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
28
28
  {:billing_address => [
29
29
  :company,
30
30
  :country_code_alpha2,
@@ -51,13 +51,13 @@ describe Braintree::CreditCard do
51
51
  :ds_transaction_id,
52
52
  ]},
53
53
  :customer_id,
54
- ]
54
+ ])
55
55
  end
56
56
  end
57
57
 
58
58
  describe "self.update_signature" do
59
59
  it "should be what we expect" do
60
- Braintree::CreditCardGateway._update_signature.should == [
60
+ expect(Braintree::CreditCardGateway._update_signature).to match([
61
61
  :billing_address_id,
62
62
  :cardholder_name,
63
63
  :cvv,
@@ -70,7 +70,7 @@ describe Braintree::CreditCard do
70
70
  :device_data,
71
71
  :payment_method_nonce,
72
72
  {:external_vault=>[:network_transaction_id]},
73
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code]},
73
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
74
74
  {:billing_address => [
75
75
  :company,
76
76
  :country_code_alpha2,
@@ -97,7 +97,7 @@ describe Braintree::CreditCard do
97
97
  :cavv_algorithm,
98
98
  :ds_transaction_id,
99
99
  ]},
100
- ]
100
+ ])
101
101
  end
102
102
  end
103
103
 
@@ -76,7 +76,7 @@ describe Braintree::Customer do
76
76
 
77
77
  describe "self.create_signature" do
78
78
  it "should be what we expect" do
79
- Braintree::CustomerGateway._create_signature.should == [
79
+ expect(Braintree::CustomerGateway._create_signature).to match([
80
80
  :company,
81
81
  :email,
82
82
  :fax,
@@ -101,7 +101,7 @@ describe Braintree::Customer do
101
101
  :device_data,
102
102
  :payment_method_nonce,
103
103
  {:external_vault=>[:network_transaction_id]},
104
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code]},
104
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
105
105
  {:billing_address => [
106
106
  :company,
107
107
  :country_code_alpha2,
@@ -163,13 +163,13 @@ describe Braintree::Customer do
163
163
  ]]
164
164
  },
165
165
  {:custom_fields => :_any_key_}
166
- ]
166
+ ])
167
167
  end
168
168
  end
169
169
 
170
170
  describe "self.update_signature" do
171
171
  it "should be what we expect" do
172
- Braintree::CustomerGateway._update_signature.should == [
172
+ expect(Braintree::CustomerGateway._update_signature).to match([
173
173
  :company,
174
174
  :email,
175
175
  :fax,
@@ -194,8 +194,9 @@ describe Braintree::Customer do
194
194
  :device_data,
195
195
  :payment_method_nonce,
196
196
  {:external_vault=>[:network_transaction_id]},
197
- {:options => [
197
+ {:options => match_array([
198
198
  :make_default,
199
+ :skip_advanced_fraud_checking,
199
200
  :verification_merchant_account_id,
200
201
  :verify_card,
201
202
  :verification_amount,
@@ -204,7 +205,7 @@ describe Braintree::Customer do
204
205
  :verification_account_type,
205
206
  :verification_currency_iso_code,
206
207
  :update_existing_token
207
- ]},
208
+ ])},
208
209
  {:billing_address => [
209
210
  :company,
210
211
  :country_code_alpha2,
@@ -261,7 +262,7 @@ describe Braintree::Customer do
261
262
  ]]
262
263
  },
263
264
  {:custom_fields => :_any_key_}
264
- ]
265
+ ])
265
266
  end
266
267
  end
267
268
 
@@ -25,6 +25,7 @@ END
25
25
  <last-name>Doe</last-name>
26
26
  <number>1234560000001234</number>
27
27
  <cvv>123</cvv>
28
+ <encrypted-card-data>8F34DFB312DC79C24FD5320622F3E11682D79E6B0C0FD881</encrypted-card-data>
28
29
  </customer>
29
30
  END
30
31
 
@@ -34,6 +35,7 @@ END
34
35
  [Braintree] <last-name>Doe</last-name>
35
36
  [Braintree] <number>123456******1234</number>
36
37
  [Braintree] <cvv>***</cvv>
38
+ [Braintree] <encrypted-card-data>***</encrypted-card-data>
37
39
  [Braintree] </customer>
38
40
  END
39
41
  Braintree::Http.new(:config)._format_and_sanitize_body_for_log(input_xml).should == expected_xml
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::LocalPaymentExpired do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::LocalPaymentExpired.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
14
+ params = {
15
+ payment_id: "a-payment-id",
16
+ payment_context_id: "a-payment-context-id",
17
+ }
18
+ local_payment_expired = Braintree::LocalPaymentExpired._new(params)
19
+
20
+ local_payment_expired.payment_id.should eq("a-payment-id")
21
+ local_payment_expired.payment_context_id.should eq("a-payment-context-id")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::LocalPaymentFunded do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::LocalPaymentFunded.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "self._new" do
13
+ it "initializes the object with the appropriate attributes set" do
14
+ params = {
15
+ payment_id: "a-payment-id",
16
+ payment_context_id: "a-payment-context-id",
17
+ transaction: {
18
+ id: "a-transaction-id",
19
+ amount: "31.00",
20
+ order_id: "an-order-id",
21
+ status: Braintree::Transaction::Status::Settled,
22
+ },
23
+ }
24
+ local_payment_funded = Braintree::LocalPaymentFunded._new(params)
25
+
26
+ local_payment_funded.payment_id.should eq("a-payment-id")
27
+ local_payment_funded.payment_context_id.should eq("a-payment-context-id")
28
+ local_payment_funded.transaction.id.should eq("a-transaction-id")
29
+ local_payment_funded.transaction.amount.should eq(31.0)
30
+ local_payment_funded.transaction.order_id.should eq("an-order-id")
31
+ local_payment_funded.transaction.status.should eq(Braintree::Transaction::Status::Settled)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::PaymentMethodNonce do
4
+ let(:payment_method_nonce) {
5
+ Braintree::PaymentMethodNonce._new(
6
+ :gateway,
7
+ :nonce => "some-nonce",
8
+ :type => "CreditCard",
9
+ :default => true,
10
+ :details => {
11
+ :bin => "some-bin"
12
+ },
13
+ :three_d_secure_info => {
14
+ :liability_shift_possible => false,
15
+ :liability_shifted => false
16
+ },
17
+ :bin_data => {
18
+ :country_of_issuance => "USA"
19
+ },
20
+ )
21
+ }
22
+
23
+ describe "#initialize" do
24
+ it "sets attributes" do
25
+ expect(payment_method_nonce.nonce).to eq("some-nonce")
26
+ expect(payment_method_nonce.type).to eq("CreditCard")
27
+ expect(payment_method_nonce.default).to be true
28
+ expect(payment_method_nonce.details.bin).to eq("some-bin")
29
+ expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
30
+ expect(payment_method_nonce.three_d_secure_info.liability_shifted).to be false
31
+ expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
32
+ end
33
+ end
34
+
35
+ describe "default" do
36
+ it "is aliased to default?" do
37
+ expect(payment_method_nonce.default?).to be true
38
+ end
39
+ end
40
+ end
@@ -25,6 +25,8 @@ describe Braintree::Transaction::PayPalDetails do
25
25
  :refund_from_transaction_fee_currency_iso_code => "123",
26
26
  :refund_id => "refund-id",
27
27
  :seller_protection_status => "seller-protection-status",
28
+ :tax_id => "tax-id",
29
+ :tax_id_type => "tax-id-type",
28
30
  :token => "token",
29
31
  :transaction_fee_amount => "2.00",
30
32
  :transaction_fee_currency_iso_code => "123",
@@ -51,6 +53,8 @@ describe Braintree::Transaction::PayPalDetails do
51
53
  expect(details.refund_from_transaction_fee_currency_iso_code).to eq("123")
52
54
  expect(details.refund_id).to eq("refund-id")
53
55
  expect(details.seller_protection_status).to eq("seller-protection-status")
56
+ expect(details.tax_id).to eq("tax-id")
57
+ expect(details.tax_id_type).to eq("tax-id-type")
54
58
  expect(details.token).to eq("token")
55
59
  expect(details.transaction_fee_amount).to eq("2.00")
56
60
  expect(details.transaction_fee_currency_iso_code).to eq("123")
@@ -21,19 +21,19 @@ describe Braintree::Transaction do
21
21
  it "raises error if passed empty string" do
22
22
  expect do
23
23
  Braintree::Transaction.find("")
24
- end.to raise_error(ArgumentError)
24
+ end.to raise_error(ArgumentError, "id can not be empty")
25
25
  end
26
26
 
27
27
  it "raises error if passed empty string wth space" do
28
28
  expect do
29
29
  Braintree::Transaction.find(" ")
30
- end.to raise_error(ArgumentError)
30
+ end.to raise_error(ArgumentError, "id can not be empty")
31
31
  end
32
32
 
33
33
  it "raises error if passed nil" do
34
34
  expect do
35
35
  Braintree::Transaction.find(nil)
36
- end.to raise_error(ArgumentError)
36
+ end.to raise_error(ArgumentError, "id can not be empty")
37
37
  end
38
38
  end
39
39
 
@@ -611,6 +611,22 @@ describe Braintree::WebhookNotification do
611
611
  metadata.token.should == "venmo_token"
612
612
  metadata.revoked_payment_method.class.should == Braintree::VenmoAccount
613
613
  end
614
+
615
+ it "builds a sample notification for a GrantedPaymentMethodRevoked webhook" do
616
+ sample_notification = Braintree::WebhookTesting.sample_notification(
617
+ Braintree::WebhookNotification::Kind::GrantedPaymentMethodRevoked,
618
+ "my_id",
619
+ )
620
+
621
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
622
+ expect(notification.kind).to eq Braintree::WebhookNotification::Kind::GrantedPaymentMethodRevoked
623
+
624
+ metadata = notification.revoked_payment_method_metadata
625
+
626
+ expect(metadata.customer_id).to eq "venmo_customer_id"
627
+ expect(metadata.token).to eq "my_id"
628
+ expect(metadata.revoked_payment_method.class).to eq Braintree::VenmoAccount
629
+ end
614
630
  end
615
631
  end
616
632
 
@@ -652,6 +668,40 @@ describe Braintree::WebhookNotification do
652
668
  end
653
669
  end
654
670
 
671
+ context "local_payment_expired" do
672
+ it "builds a sample notification for a local_payment_expired webhook" do
673
+ sample_notification = Braintree::WebhookTesting.sample_notification(
674
+ Braintree::WebhookNotification::Kind::LocalPaymentExpired,
675
+ "my_id",
676
+ )
677
+
678
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
679
+ notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentExpired
680
+
681
+ local_payment_expired = notification.local_payment_expired
682
+ local_payment_expired.payment_id.should == "PAY-XYZ123"
683
+ local_payment_expired.payment_context_id.should == "cG5b="
684
+ end
685
+ end
686
+
687
+ context "local_payment_funded" do
688
+ it "builds a sample notification for a local_payment_funded webhook" do
689
+ sample_notification = Braintree::WebhookTesting.sample_notification(
690
+ Braintree::WebhookNotification::Kind::LocalPaymentFunded,
691
+ "my_id",
692
+ )
693
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
694
+ notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentFunded
695
+
696
+ local_payment_funded = notification.local_payment_funded
697
+ local_payment_funded.payment_id.should == "PAY-XYZ123"
698
+ local_payment_funded.payment_context_id.should == "cG5b="
699
+ local_payment_funded.transaction.id.should == "my_id"
700
+ local_payment_funded.transaction.status.should == Braintree::Transaction::Status::Settled
701
+ local_payment_funded.transaction.amount.should == 49.99
702
+ local_payment_funded.transaction.order_id.should == "order4567"
703
+ end
704
+ end
655
705
 
656
706
  context "local_payment_reversed" do
657
707
  it "builds a sample notification for a local_payment webhook" do
@@ -659,7 +709,6 @@ describe Braintree::WebhookNotification do
659
709
  Braintree::WebhookNotification::Kind::LocalPaymentReversed,
660
710
  "my_id",
661
711
  )
662
-
663
712
  notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
664
713
  notification.kind.should == Braintree::WebhookNotification::Kind::LocalPaymentReversed
665
714
 
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.0.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: rexml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.9
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.9
27
41
  description: Resources and tools for developers to integrate Braintree's global payments
28
42
  platform.
29
43
  email: code@getbraintree.com
@@ -90,6 +104,8 @@ files:
90
104
  - lib/braintree/graphql_client.rb
91
105
  - lib/braintree/http.rb
92
106
  - lib/braintree/local_payment_completed.rb
107
+ - lib/braintree/local_payment_expired.rb
108
+ - lib/braintree/local_payment_funded.rb
93
109
  - lib/braintree/local_payment_reversed.rb
94
110
  - lib/braintree/merchant.rb
95
111
  - lib/braintree/merchant_account.rb
@@ -256,10 +272,13 @@ files:
256
272
  - spec/unit/braintree/errors_spec.rb
257
273
  - spec/unit/braintree/http_spec.rb
258
274
  - spec/unit/braintree/local_payment_completed_spec.rb
275
+ - spec/unit/braintree/local_payment_expired_spec.rb
276
+ - spec/unit/braintree/local_payment_funded_spec.rb
259
277
  - spec/unit/braintree/merchant_account_spec.rb
260
278
  - spec/unit/braintree/modification_spec.rb
261
279
  - spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb
262
280
  - spec/unit/braintree/payment_method_nonce_details_spec.rb
281
+ - spec/unit/braintree/payment_method_nonce_spec.rb
263
282
  - spec/unit/braintree/payment_method_spec.rb
264
283
  - spec/unit/braintree/paypal_account_spec.rb
265
284
  - spec/unit/braintree/resource_collection_spec.rb
@@ -314,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
333
  - !ruby/object:Gem::Version
315
334
  version: '0'
316
335
  requirements: []
317
- rubygems_version: 3.2.17
336
+ rubygems_version: 3.2.25
318
337
  signing_key:
319
338
  specification_version: 4
320
339
  summary: Braintree Ruby Server SDK