braintree 4.5.0 → 4.8.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +1 -1
  3. data/lib/braintree/enriched_customer_data.rb +21 -0
  4. data/lib/braintree/exchange_rate.rb +13 -0
  5. data/lib/braintree/exchange_rate_quote.rb +24 -0
  6. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  7. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  8. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  9. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  10. data/lib/braintree/gateway.rb +4 -0
  11. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  12. data/lib/braintree/plan_gateway.rb +3 -3
  13. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  14. data/lib/braintree/risk_data.rb +3 -1
  15. data/lib/braintree/successful_result.rb +2 -1
  16. data/lib/braintree/transaction.rb +24 -19
  17. data/lib/braintree/transaction_search.rb +2 -1
  18. data/lib/braintree/venmo_profile_data.rb +23 -0
  19. data/lib/braintree/version.rb +1 -1
  20. data/lib/braintree/webhook_notification.rb +5 -0
  21. data/lib/braintree/webhook_testing_gateway.rb +45 -15
  22. data/lib/braintree.rb +18 -8
  23. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  24. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  25. data/spec/integration/braintree/payment_method_nonce_spec.rb +2 -1
  26. data/spec/integration/braintree/payment_method_spec.rb +2 -2
  27. data/spec/integration/braintree/transaction_search_spec.rb +79 -0
  28. data/spec/integration/braintree/transaction_spec.rb +59 -6
  29. data/spec/integration/spec_helper.rb +6 -0
  30. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  31. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  32. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  33. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  34. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  35. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  36. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  37. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  38. data/spec/unit/braintree/risk_data_spec.rb +33 -7
  39. data/spec/unit/braintree/transaction_spec.rb +8 -0
  40. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  41. data/spec/unit/braintree/webhook_notification_spec.rb +26 -0
  42. metadata +24 -4
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::PaymentMethodCustomerDataUpdatedMetadata.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
+
15
+ params = {
16
+ token: "a-token",
17
+ payment_method: {
18
+ venmo_account: {
19
+ venmo_user_id: "venmo-user-id",
20
+ },
21
+ },
22
+ datetime_updated: "2022-01-01T21:28:37Z",
23
+ enriched_customer_data: {
24
+ fields_updated: ["username"],
25
+ profile_data: {
26
+ username: "a-username",
27
+ first_name: "a-first-name",
28
+ last_name: "a-last-name",
29
+ phone_number: "a-phone-number",
30
+ email: "a-email",
31
+ },
32
+ },
33
+ }
34
+
35
+ payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)
36
+
37
+ payment_method_customer_data_updated.token.should eq("a-token")
38
+ payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
39
+ payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount)
40
+ payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name")
41
+ payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name")
42
+ payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"])
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+ describe Braintree::Transaction::LiabilityShift do
4
+ describe "#initialize" do
5
+ it "sets responsible party and conditions" do
6
+ liability_shift = Braintree::Transaction::LiabilityShift.new(
7
+ :responsible_party => "paypal",
8
+ :conditions => ["unauthorized","item_not_received"],
9
+ )
10
+
11
+ expect(liability_shift.responsible_party).to eql "paypal"
12
+ expect(liability_shift.conditions.first).to eql "unauthorized"
13
+ end
14
+ end
15
+
16
+ describe "inspect" do
17
+ it "prints the attributes" do
18
+ details = Braintree::Transaction::LiabilityShift.new(
19
+ :responsible_party => "paypal",
20
+ :conditions => ["unauthorized","item_not_received"],
21
+ )
22
+
23
+ expect(details.inspect).to eql %(#<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized", "item_not_received"]>)
24
+ end
25
+ end
26
+ end
@@ -4,12 +4,29 @@ describe Braintree::RiskData do
4
4
  describe "#initialize" do
5
5
  it "sets id, decision, device_data_captured, decision_reasons and transaction_risk_score" do
6
6
  risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "fraud_protection", :decision_reasons => ["reason"], :transaction_risk_score => "12")
7
- risk_data.id.should == "123"
8
- risk_data.decision.should == "YOU WON $1000 DOLLARS"
9
- risk_data.device_data_captured.should be_truthy
10
- risk_data.fraud_service_provider.should == "fraud_protection"
11
- risk_data.decision_reasons.should == ["reason"]
12
- risk_data.transaction_risk_score.should == "12"
7
+ expect(risk_data.id).to eql "123"
8
+ expect(risk_data.decision).to eql "YOU WON $1000 DOLLARS"
9
+ expect(risk_data.device_data_captured).to be_truthy
10
+ expect(risk_data.fraud_service_provider).to eql "fraud_protection"
11
+ expect(risk_data.decision_reasons).to eql ["reason"]
12
+ expect(risk_data.transaction_risk_score).to eql "12"
13
+ expect(risk_data.liability_shift).to be_nil
14
+ end
15
+
16
+ it "sets liability shift info" do
17
+ risk_data = Braintree::RiskData.new(
18
+ :id => "123",
19
+ :decision => "YOU WON $1000 DOLLARS",
20
+ :device_data_captured => true,
21
+ :fraud_service_provider => "fraud_protection",
22
+ :decision_reasons => ["reason"],
23
+ :transaction_risk_score => "12",
24
+ :liability_shift => {
25
+ :responsible_party => "paypal",
26
+ :conditions => ["unauthorized"]},
27
+ )
28
+ expect(risk_data.liability_shift.responsible_party).to eql "paypal"
29
+ expect(risk_data.liability_shift.conditions).to eql ["unauthorized"]
13
30
  end
14
31
  end
15
32
 
@@ -23,7 +40,16 @@ describe Braintree::RiskData do
23
40
  :fraud_service_provider => "fraud_protection",
24
41
  :transaction_risk_score => "12",
25
42
  )
26
- details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", transaction_risk_score: "12">)
43
+ expect(details.inspect).to eql %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", liability_shift: nil, transaction_risk_score: "12">)
44
+ end
45
+
46
+ it "prints liability shift attributes, too" do
47
+ details = Braintree::RiskData.new(
48
+ :liability_shift => {
49
+ :responsible_party => "paypal",
50
+ :conditions => ["unauthorized"]},
51
+ )
52
+ expect(details.inspect).to eql %(#<RiskData id: nil, decision: nil, decision_reasons: nil, device_data_captured: nil, fraud_service_provider: nil, liability_shift: #<LiabilityShift responsible_party: "paypal", conditions: ["unauthorized"]>, transaction_risk_score: nil>)
27
53
  end
28
54
  end
29
55
  end
@@ -238,6 +238,14 @@ describe Braintree::Transaction do
238
238
  transaction.network_transaction_id.should == "123456789012345"
239
239
  end
240
240
 
241
+ it "accepts ach_return_code" do
242
+ transaction = Braintree::Transaction._new(
243
+ :gateway,
244
+ :ach_return_code => "R01",
245
+ )
246
+ expect(transaction.ach_return_code).to eq("R01")
247
+ end
248
+
241
249
  it "accepts network_response code and network_response_text" do
242
250
  transaction = Braintree::Transaction._new(
243
251
  :gateway,
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::VenmoProfileData do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::VenmoProfileData.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
+
15
+ params = {
16
+ username: "a-username",
17
+ first_name: "a-first-name",
18
+ last_name: "a-last-name",
19
+ phone_number: "12312312343",
20
+ email: "a-email",
21
+ }
22
+
23
+ payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params)
24
+
25
+ payment_method_customer_data_updated.username.should eq("a-username")
26
+ payment_method_customer_data_updated.first_name.should eq("a-first-name")
27
+ payment_method_customer_data_updated.last_name.should eq("a-last-name")
28
+ payment_method_customer_data_updated.phone_number.should eq("12312312343")
29
+ payment_method_customer_data_updated.email.should eq("a-email")
30
+ end
31
+ end
32
+ end
@@ -735,6 +735,32 @@ describe Braintree::WebhookNotification do
735
735
  end
736
736
  end
737
737
 
738
+ context "payment_method_customer_data_updated" do
739
+ it "builds a sample notification for a payment_method_customer_data_updated webhook" do
740
+ sample_notification = Braintree::WebhookTesting.sample_notification(
741
+ Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated,
742
+ "my_id",
743
+ )
744
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
745
+ notification.kind.should == Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated
746
+
747
+ payment_method_customer_data_updated = notification.payment_method_customer_data_updated_metadata
748
+
749
+ payment_method_customer_data_updated.token.should eq("TOKEN-12345")
750
+ payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
751
+
752
+ enriched_customer_data = payment_method_customer_data_updated.enriched_customer_data
753
+ enriched_customer_data.fields_updated.should eq(["username"])
754
+
755
+ profile_data = enriched_customer_data.profile_data
756
+ profile_data.first_name.should eq("John")
757
+ profile_data.last_name.should eq("Doe")
758
+ profile_data.username.should eq("venmo_username")
759
+ profile_data.phone_number.should eq("1231231234")
760
+ profile_data.email.should eq("john.doe@paypal.com")
761
+ end
762
+ end
763
+
738
764
  describe "parse" do
739
765
  it "raises InvalidSignature error when the signature is nil" do
740
766
  expect do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.8.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-11-12 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -92,10 +92,17 @@ files:
92
92
  - lib/braintree/dispute_search.rb
93
93
  - lib/braintree/document_upload.rb
94
94
  - lib/braintree/document_upload_gateway.rb
95
+ - lib/braintree/enriched_customer_data.rb
95
96
  - lib/braintree/error_codes.rb
96
97
  - lib/braintree/error_result.rb
97
98
  - lib/braintree/errors.rb
98
99
  - lib/braintree/exceptions.rb
100
+ - lib/braintree/exchange_rate.rb
101
+ - lib/braintree/exchange_rate_quote.rb
102
+ - lib/braintree/exchange_rate_quote_gateway.rb
103
+ - lib/braintree/exchange_rate_quote_input.rb
104
+ - lib/braintree/exchange_rate_quote_request.rb
105
+ - lib/braintree/exchange_rate_quote_response.rb
99
106
  - lib/braintree/facilitated_details.rb
100
107
  - lib/braintree/facilitator_details.rb
101
108
  - lib/braintree/gateway.rb
@@ -122,6 +129,7 @@ files:
122
129
  - lib/braintree/paginated_result.rb
123
130
  - lib/braintree/payment_instrument_type.rb
124
131
  - lib/braintree/payment_method.rb
132
+ - lib/braintree/payment_method_customer_data_updated_metadata.rb
125
133
  - lib/braintree/payment_method_gateway.rb
126
134
  - lib/braintree/payment_method_nonce.rb
127
135
  - lib/braintree/payment_method_nonce_details.rb
@@ -136,6 +144,7 @@ files:
136
144
  - lib/braintree/resource_collection.rb
137
145
  - lib/braintree/revoked_payment_method_metadata.rb
138
146
  - lib/braintree/risk_data.rb
147
+ - lib/braintree/risk_data/liability_shift.rb
139
148
  - lib/braintree/samsung_pay_card.rb
140
149
  - lib/braintree/settlement_batch_summary.rb
141
150
  - lib/braintree/settlement_batch_summary_gateway.rb
@@ -188,6 +197,7 @@ files:
188
197
  - lib/braintree/validation_error.rb
189
198
  - lib/braintree/validation_error_collection.rb
190
199
  - lib/braintree/venmo_account.rb
200
+ - lib/braintree/venmo_profile_data.rb
191
201
  - lib/braintree/version.rb
192
202
  - lib/braintree/visa_checkout_card.rb
193
203
  - lib/braintree/webhook_notification.rb
@@ -223,6 +233,7 @@ files:
223
233
  - spec/integration/braintree/dispute_spec.rb
224
234
  - spec/integration/braintree/document_upload_spec.rb
225
235
  - spec/integration/braintree/error_codes_spec.rb
236
+ - spec/integration/braintree/exchange_rate_quote_spec.rb
226
237
  - spec/integration/braintree/graphql_client_spec.rb
227
238
  - spec/integration/braintree/http_spec.rb
228
239
  - spec/integration/braintree/merchant_account_spec.rb
@@ -269,20 +280,28 @@ files:
269
280
  - spec/unit/braintree/dispute_search_spec.rb
270
281
  - spec/unit/braintree/dispute_spec.rb
271
282
  - spec/unit/braintree/document_upload_spec.rb
283
+ - spec/unit/braintree/enriched_customer_data_spec.rb
272
284
  - spec/unit/braintree/error_result_spec.rb
273
285
  - spec/unit/braintree/errors_spec.rb
286
+ - spec/unit/braintree/exchange_rate_quote_input_spec.rb
287
+ - spec/unit/braintree/exchange_rate_quote_request_spec.rb
288
+ - spec/unit/braintree/exchange_rate_quote_response_spec.rb
289
+ - spec/unit/braintree/exchange_rate_quote_spec.rb
290
+ - spec/unit/braintree/exchange_rate_spec.rb
274
291
  - spec/unit/braintree/http_spec.rb
275
292
  - spec/unit/braintree/local_payment_completed_spec.rb
276
293
  - spec/unit/braintree/local_payment_expired_spec.rb
277
294
  - spec/unit/braintree/local_payment_funded_spec.rb
278
295
  - spec/unit/braintree/merchant_account_spec.rb
279
296
  - spec/unit/braintree/modification_spec.rb
297
+ - spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb
280
298
  - spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb
281
299
  - spec/unit/braintree/payment_method_nonce_details_spec.rb
282
300
  - spec/unit/braintree/payment_method_nonce_spec.rb
283
301
  - spec/unit/braintree/payment_method_spec.rb
284
302
  - spec/unit/braintree/paypal_account_spec.rb
285
303
  - spec/unit/braintree/resource_collection_spec.rb
304
+ - spec/unit/braintree/risk_data/liability_shift.rb
286
305
  - spec/unit/braintree/risk_data_spec.rb
287
306
  - spec/unit/braintree/sha256_digest_spec.rb
288
307
  - spec/unit/braintree/signature_service_spec.rb
@@ -304,6 +323,7 @@ files:
304
323
  - spec/unit/braintree/util_spec.rb
305
324
  - spec/unit/braintree/validation_error_collection_spec.rb
306
325
  - spec/unit/braintree/validation_error_spec.rb
326
+ - spec/unit/braintree/venmo_profile_data_spec.rb
307
327
  - spec/unit/braintree/webhook_notification_spec.rb
308
328
  - spec/unit/braintree/xml/libxml_spec.rb
309
329
  - spec/unit/braintree/xml/parser_spec.rb
@@ -318,7 +338,7 @@ metadata:
318
338
  bug_tracker_uri: https://github.com/braintree/braintree_ruby/issues
319
339
  changelog_uri: https://github.com/braintree/braintree_ruby/blob/master/CHANGELOG.md
320
340
  source_code_uri: https://github.com/braintree/braintree_ruby
321
- documentation_uri: https://developers.braintreepayments.com/
341
+ documentation_uri: https://developer.paypal.com/braintree/docs
322
342
  post_install_message:
323
343
  rdoc_options: []
324
344
  require_paths:
@@ -334,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
354
  - !ruby/object:Gem::Version
335
355
  version: '0'
336
356
  requirements: []
337
- rubygems_version: 3.2.31
357
+ rubygems_version: 3.3.18
338
358
  signing_key:
339
359
  specification_version: 4
340
360
  summary: Braintree Ruby Server SDK