braintree 4.5.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34698c59add2b3613d0c75e58d2d9d8ee5f3aecdd6ef85c79e303211199b4fa8
4
- data.tar.gz: 933cf9e7d93aec94ba227fef1f03e4f245b7e0e4512b57ebf96ddd9ffef89cab
3
+ metadata.gz: 4d5f90896056b6236f7150b16b09322c9f32822b23bd4367140418f9506c8767
4
+ data.tar.gz: 948821597de9332dccd0ee502f3828b6e6d14253681fe42a8c5950d15fb71882
5
5
  SHA512:
6
- metadata.gz: d44a8addd727ea6efe503a33c275956bf0a359abe402ee42fff43785b48e30a84a29ecf6e6cbf8aacb080e8562e553f6c9c2424878575815f08cd563647e6762
7
- data.tar.gz: 4b631596ff355ee26deceac5c37b61e66b0c5cf5336392120df61802be53b276cf2ebf9d93c6fb64dae3bea06d3dcb925644620aa829afaf7d2382328e7b2152
6
+ metadata.gz: 3f0d867f7795d6969fe315a78ee163f871d919fc611a9dcba22c259332fd2f1bb47c94676aad8f340ec4cb040ebe2d8f256d50704b9b586b5f4afb6cbf93199c
7
+ data.tar.gz: d2db07468b1b333986d61389cb60a16cde90db6168bd445a04a5f04621debdebd0cd334f9623ddc26ee85da546dc4efd1aea3751510d444c72c8e5a4b4771bf5
data/braintree.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  "bug_tracker_uri" => "https://github.com/braintree/braintree_ruby/issues",
19
19
  "changelog_uri" => "https://github.com/braintree/braintree_ruby/blob/master/CHANGELOG.md",
20
20
  "source_code_uri" => "https://github.com/braintree/braintree_ruby",
21
- "documentation_uri" => "https://developers.braintreepayments.com/"
21
+ "documentation_uri" => "https://developer.paypal.com/braintree/docs"
22
22
  }
23
23
  end
24
24
 
@@ -0,0 +1,21 @@
1
+ module Braintree
2
+ class EnrichedCustomerData
3
+ include BaseModule
4
+
5
+ attr_reader :fields_updated
6
+ attr_reader :profile_data
7
+
8
+ def initialize(attributes) # :nodoc:
9
+ set_instance_variables_from_hash(attributes)
10
+ @profile_data = VenmoProfileData._new(attributes[:profile_data])
11
+ end
12
+
13
+ class << self
14
+ protected :new
15
+ end
16
+
17
+ def self._new(*args) # :nodoc:
18
+ self.new(*args)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module Braintree
2
+ class PaymentMethodCustomerDataUpdatedMetadata
3
+ include BaseModule
4
+
5
+ attr_reader :token
6
+ attr_reader :payment_method
7
+ attr_reader :datetime_updated
8
+ attr_reader :enriched_customer_data
9
+
10
+ def initialize(gateway, attributes) # :nodoc:
11
+ set_instance_variables_from_hash(attributes)
12
+ @payment_method = PaymentMethodParser.parse_payment_method(gateway, attributes[:payment_method])
13
+ @enriched_customer_data = EnrichedCustomerData._new(enriched_customer_data) if enriched_customer_data
14
+ end
15
+
16
+ class << self
17
+ protected :new
18
+ end
19
+
20
+ def self._new(*args) # :nodoc:
21
+ self.new(*args)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ module Braintree
2
+ class VenmoProfileData
3
+ include BaseModule
4
+
5
+ attr_reader :username
6
+ attr_reader :first_name
7
+ attr_reader :last_name
8
+ attr_reader :phone_number
9
+ attr_reader :email
10
+
11
+ def initialize(attributes) # :nodoc:
12
+ set_instance_variables_from_hash(attributes)
13
+ end
14
+
15
+ class << self
16
+ protected :new
17
+ end
18
+
19
+ def self._new(*args) # :nodoc:
20
+ self.new(*args)
21
+ end
22
+ end
23
+ end
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 5
4
+ Minor = 6
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -38,6 +38,8 @@ module Braintree
38
38
  PartnerMerchantDisconnected = "partner_merchant_disconnected"
39
39
  PartnerMerchantDeclined = "partner_merchant_declined"
40
40
 
41
+ PaymentMethodCustomerDataUpdated = "payment_method_customer_data_updated"
42
+
41
43
  PaymentMethodRevokedByCustomer = "payment_method_revoked_by_customer"
42
44
 
43
45
  RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
@@ -73,6 +75,7 @@ module Braintree
73
75
  attr_reader :local_payment_reversed
74
76
  attr_reader :oauth_access_revocation
75
77
  attr_reader :partner_merchant
78
+ attr_reader :payment_method_customer_data_updated_metadata
76
79
  attr_reader :source_merchant_id
77
80
  attr_reader :subscription
78
81
  attr_reader :timestamp
@@ -108,6 +111,8 @@ module Braintree
108
111
  @local_payment_expired = LocalPaymentExpired._new(@subject[:local_payment_expired]) if @subject.has_key?(:local_payment_expired) && Kind::LocalPaymentExpired == @kind
109
112
  @local_payment_funded = LocalPaymentFunded._new(@subject[:local_payment_funded]) if @subject.has_key?(:local_payment_funded) && Kind::LocalPaymentFunded == @kind
110
113
  @local_payment_reversed = LocalPaymentReversed._new(@subject[:local_payment_reversed]) if @subject.has_key?(:local_payment_reversed) && Kind::LocalPaymentReversed == @kind
114
+ @payment_method_customer_data_updated_metadata = PaymentMethodCustomerDataUpdatedMetadata._new(gateway, @subject[:payment_method_customer_data_updated_metadata]) if @subject.has_key?(:payment_method_customer_data_updated_metadata) && Kind::PaymentMethodCustomerDataUpdated == @kind
115
+
111
116
  end
112
117
 
113
118
  def merchant_account
@@ -96,6 +96,8 @@ module Braintree
96
96
  _local_payment_funded_sample_xml(id)
97
97
  when Braintree::WebhookNotification::Kind::LocalPaymentReversed
98
98
  _local_payment_reversed_sample_xml
99
+ when Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated
100
+ _payment_method_customer_data_updated_sample_xml(id)
99
101
  else
100
102
  _subscription_sample_xml(id)
101
103
  end
@@ -899,21 +901,7 @@ module Braintree
899
901
  end
900
902
 
901
903
  def _granted_payment_method_revoked_xml(id)
902
- <<-XML
903
- <venmo-account>
904
- <created-at type='dateTime'>2018-10-11T21:28:37Z</created-at>
905
- <updated-at type='dateTime'>2018-10-11T21:28:37Z</updated-at>
906
- <default type='boolean'>true</default>
907
- <image-url>https://assets.braintreegateway.com/payment_method_logo/venmo.png?environment=test</image-url>
908
- <token>#{id}</token>
909
- <source-description>Venmo Account: venmojoe</source-description>
910
- <username>venmojoe</username>
911
- <venmo-user-id>456</venmo-user-id>
912
- <subscriptions type='array'/>
913
- <customer-id>venmo_customer_id</customer-id>
914
- <global-id>cGF5bWVudG1ldGhvZF92ZW5tb2FjY291bnQ</global-id>
915
- </venmo-account>
916
- XML
904
+ _venmo_account_xml(id)
917
905
  end
918
906
 
919
907
  def _payment_method_revoked_by_customer_sample_xml(id)
@@ -986,5 +974,47 @@ module Braintree
986
974
  </local-payment-reversed>
987
975
  XML
988
976
  end
977
+
978
+ def _payment_method_customer_data_updated_sample_xml(id)
979
+ <<-XML
980
+ <payment-method-customer-data-updated-metadata>
981
+ <token>TOKEN-12345</token>
982
+ <payment-method>
983
+ #{_venmo_account_xml(id)}
984
+ </payment-method>
985
+ <datetime-updated type='dateTime'>2022-01-01T21:28:37Z</datetime-updated>
986
+ <enriched-customer-data>
987
+ <fields-updated type='array'>
988
+ <item>username</item>
989
+ </fields-updated>
990
+ <profile-data>
991
+ <username>venmo_username</username>
992
+ <first-name>John</first-name>
993
+ <last-name>Doe</last-name>
994
+ <phone-number>1231231234</phone-number>
995
+ <email>john.doe@paypal.com</email>
996
+ </profile-data>
997
+ </enriched-customer-data>
998
+ </payment-method-customer-data-updated-metadata>
999
+ XML
1000
+ end
1001
+
1002
+ def _venmo_account_xml(id)
1003
+ <<-XML
1004
+ <venmo-account>
1005
+ <created-at type='dateTime'>2018-10-11T21:28:37Z</created-at>
1006
+ <updated-at type='dateTime'>2018-10-11T21:28:37Z</updated-at>
1007
+ <default type='boolean'>true</default>
1008
+ <image-url>https://assets.braintreegateway.com/payment_method_logo/venmo.png?environment=test</image-url>
1009
+ <token>#{id}</token>
1010
+ <source-description>Venmo Account: venmojoe</source-description>
1011
+ <username>venmojoe</username>
1012
+ <venmo-user-id>456</venmo-user-id>
1013
+ <subscriptions type='array'/>
1014
+ <customer-id>venmo_customer_id</customer-id>
1015
+ <global-id>cGF5bWVudG1ldGhvZF92ZW5tb2FjY291bnQ</global-id>
1016
+ </venmo-account>
1017
+ XML
1018
+ end
989
1019
  end
990
1020
  end
data/lib/braintree.rb CHANGED
@@ -65,6 +65,7 @@ require "braintree/dispute/transaction"
65
65
  require "braintree/dispute/transaction_details"
66
66
  require "braintree/document_upload"
67
67
  require "braintree/document_upload_gateway"
68
+ require "braintree/enriched_customer_data"
68
69
  require "braintree/error_codes"
69
70
  require "braintree/error_result"
70
71
  require "braintree/errors"
@@ -88,6 +89,7 @@ require "braintree/oauth_gateway"
88
89
  require "braintree/oauth_credentials"
89
90
  require "braintree/payment_instrument_type"
90
91
  require "braintree/payment_method"
92
+ require "braintree/payment_method_customer_data_updated_metadata"
91
93
  require "braintree/payment_method_gateway"
92
94
  require "braintree/payment_method_nonce"
93
95
  require "braintree/payment_method_nonce_details"
@@ -155,6 +157,7 @@ require "braintree/dispute_search"
155
157
  require "braintree/validation_error"
156
158
  require "braintree/validation_error_collection"
157
159
  require "braintree/venmo_account"
160
+ require "braintree/venmo_profile_data"
158
161
  require "braintree/version"
159
162
  require "braintree/visa_checkout_card"
160
163
  require "braintree/samsung_pay_card"
@@ -1,5 +1,6 @@
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
+ require "date"
3
4
 
4
5
  describe Braintree::PaymentMethodNonce do
5
6
  let(:config) { Braintree::Configuration.instantiate }
@@ -84,7 +85,7 @@ describe Braintree::PaymentMethodNonce do
84
85
  nonce.details.bin.should == "401288"
85
86
  nonce.details.card_type.should == "Visa"
86
87
  nonce.details.expiration_month.should == "12"
87
- nonce.details.expiration_year.should == "2022"
88
+ nonce.details.expiration_year.should == Date.today.next_year.year.to_s
88
89
  nonce.details.is_network_tokenized?.should be_nil
89
90
  nonce.details.last_two.should == "81"
90
91
  nonce.details.payer_info.should be_nil
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::EnrichedCustomerData do
4
+ describe "self.new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::EnrichedCustomerData.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
+ fields_updated: ["username"],
17
+ profile_data: {
18
+ username: "a-username",
19
+ first_name: "a-first-name",
20
+ last_name: "a-last-name",
21
+ phone_number: "a-phone-number",
22
+ email: "a-email",
23
+ },
24
+ }
25
+
26
+ payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params)
27
+
28
+ payment_method_customer_data_updated.profile_data.should be_a(Braintree::VenmoProfileData)
29
+ payment_method_customer_data_updated.fields_updated.should eq(["username"])
30
+ end
31
+ end
32
+ end
@@ -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,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.6.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-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -92,6 +92,7 @@ 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
@@ -122,6 +123,7 @@ files:
122
123
  - lib/braintree/paginated_result.rb
123
124
  - lib/braintree/payment_instrument_type.rb
124
125
  - lib/braintree/payment_method.rb
126
+ - lib/braintree/payment_method_customer_data_updated_metadata.rb
125
127
  - lib/braintree/payment_method_gateway.rb
126
128
  - lib/braintree/payment_method_nonce.rb
127
129
  - lib/braintree/payment_method_nonce_details.rb
@@ -188,6 +190,7 @@ files:
188
190
  - lib/braintree/validation_error.rb
189
191
  - lib/braintree/validation_error_collection.rb
190
192
  - lib/braintree/venmo_account.rb
193
+ - lib/braintree/venmo_profile_data.rb
191
194
  - lib/braintree/version.rb
192
195
  - lib/braintree/visa_checkout_card.rb
193
196
  - lib/braintree/webhook_notification.rb
@@ -269,6 +272,7 @@ files:
269
272
  - spec/unit/braintree/dispute_search_spec.rb
270
273
  - spec/unit/braintree/dispute_spec.rb
271
274
  - spec/unit/braintree/document_upload_spec.rb
275
+ - spec/unit/braintree/enriched_customer_data_spec.rb
272
276
  - spec/unit/braintree/error_result_spec.rb
273
277
  - spec/unit/braintree/errors_spec.rb
274
278
  - spec/unit/braintree/http_spec.rb
@@ -277,6 +281,7 @@ files:
277
281
  - spec/unit/braintree/local_payment_funded_spec.rb
278
282
  - spec/unit/braintree/merchant_account_spec.rb
279
283
  - spec/unit/braintree/modification_spec.rb
284
+ - spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb
280
285
  - spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb
281
286
  - spec/unit/braintree/payment_method_nonce_details_spec.rb
282
287
  - spec/unit/braintree/payment_method_nonce_spec.rb
@@ -304,6 +309,7 @@ files:
304
309
  - spec/unit/braintree/util_spec.rb
305
310
  - spec/unit/braintree/validation_error_collection_spec.rb
306
311
  - spec/unit/braintree/validation_error_spec.rb
312
+ - spec/unit/braintree/venmo_profile_data_spec.rb
307
313
  - spec/unit/braintree/webhook_notification_spec.rb
308
314
  - spec/unit/braintree/xml/libxml_spec.rb
309
315
  - spec/unit/braintree/xml/parser_spec.rb
@@ -318,7 +324,7 @@ metadata:
318
324
  bug_tracker_uri: https://github.com/braintree/braintree_ruby/issues
319
325
  changelog_uri: https://github.com/braintree/braintree_ruby/blob/master/CHANGELOG.md
320
326
  source_code_uri: https://github.com/braintree/braintree_ruby
321
- documentation_uri: https://developers.braintreepayments.com/
327
+ documentation_uri: https://developer.paypal.com/braintree/docs
322
328
  post_install_message:
323
329
  rdoc_options: []
324
330
  require_paths:
@@ -334,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
340
  - !ruby/object:Gem::Version
335
341
  version: '0'
336
342
  requirements: []
337
- rubygems_version: 3.2.31
343
+ rubygems_version: 3.3.7
338
344
  signing_key:
339
345
  specification_version: 4
340
346
  summary: Braintree Ruby Server SDK