Skip to content

Commit

Permalink
4.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Feb 17, 2022
1 parent 4dca0d7 commit f521dd0
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- [ ] Added changelog entry (If there isn't an `#unreleased` section, add that and your changelog entry to the top of the changelog)
- [ ] Ran unit tests (`rake test:unit`)
- [ ] I understand that unless this is a Draft PR or has a DO NOT MERGE label, this PR is considered to be in a deploy ready state and can be deployed if merged to main

<!-- **For Braintree Developers only, don't forget:**
- [ ] [GraphQL PR](link-to-pr-here). If this PR changes or adds API input or response fields, it must be added to the GraphQL API before this PR to the server SDK can be merged in.
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 4.6.0

* Add `PaymentMethodCustomerDataUpdated` webhook notification support


## 4.5.0
* Add plan create/update/find API endpoint
* Add support for `TransactionReview` webhook notification
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _The Ruby core development community has released [End-of-Life branches](https:/

## Versions

Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our [developer docs](https://developers.braintreepayments.com/reference/general/server-sdk-deprecation-policy). [Minimum supported versions](https://developers.braintreepayments.com/reference/general/best-practices/ruby#server-sdk-versions) are also available in our developer docs.
Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our [developer docs](https://developer.paypal.com/braintree/docs/reference/general/server-sdk-deprecation-policy). [Minimum supported versions](https://developer.paypal.com/braintree/docs/reference/general/best-practices/ruby#server-sdk-versions) are also available in our developer docs.

| Major version number | Status | Released | Deprecated | Unsupported |
| -------------------- | ----------- | ------------- | ------------ | ------------ |
Expand All @@ -43,9 +43,9 @@ Braintree employs a deprecation policy for our SDKs. For more information on the

## Documentation

* [Official documentation](https://developers.braintreepayments.com/start/hello-server/ruby)
* [Official documentation](https://developer.paypal.com/braintree/docs/start/hello-server/ruby)

Updating from an Inactive, Deprecated, or Unsupported version of this SDK? Check our [Migration Guide](https://developers.braintreepayments.com/reference/general/server-sdk-migration-guide/ruby) for tips.
Updating from an Inactive, Deprecated, or Unsupported version of this SDK? Check our [Migration Guide](https://developer.paypal.com/braintree/docs/reference/general/server-sdk-migration-guide/ruby) for tips.

## Quick Start Example

Expand Down
2 changes: 1 addition & 1 deletion braintree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
"bug_tracker_uri" => "https://github.com/braintree/braintree_ruby/issues",
"changelog_uri" => "https://github.com/braintree/braintree_ruby/blob/master/CHANGELOG.md",
"source_code_uri" => "https://github.com/braintree/braintree_ruby",
"documentation_uri" => "https://developers.braintreepayments.com/"
"documentation_uri" => "https://developer.paypal.com/braintree/docs"
}
end

3 changes: 3 additions & 0 deletions lib/braintree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
require "braintree/dispute/transaction_details"
require "braintree/document_upload"
require "braintree/document_upload_gateway"
require "braintree/enriched_customer_data"
require "braintree/error_codes"
require "braintree/error_result"
require "braintree/errors"
Expand All @@ -88,6 +89,7 @@
require "braintree/oauth_credentials"
require "braintree/payment_instrument_type"
require "braintree/payment_method"
require "braintree/payment_method_customer_data_updated_metadata"
require "braintree/payment_method_gateway"
require "braintree/payment_method_nonce"
require "braintree/payment_method_nonce_details"
Expand Down Expand Up @@ -155,6 +157,7 @@
require "braintree/validation_error"
require "braintree/validation_error_collection"
require "braintree/venmo_account"
require "braintree/venmo_profile_data"
require "braintree/version"
require "braintree/visa_checkout_card"
require "braintree/samsung_pay_card"
Expand Down
21 changes: 21 additions & 0 deletions lib/braintree/enriched_customer_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Braintree
class EnrichedCustomerData
include BaseModule

attr_reader :fields_updated
attr_reader :profile_data

def initialize(attributes) # :nodoc:
set_instance_variables_from_hash(attributes)
@profile_data = VenmoProfileData._new(attributes[:profile_data])
end

class << self
protected :new
end

def self._new(*args) # :nodoc:
self.new(*args)
end
end
end
24 changes: 24 additions & 0 deletions lib/braintree/payment_method_customer_data_updated_metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Braintree
class PaymentMethodCustomerDataUpdatedMetadata
include BaseModule

attr_reader :token
attr_reader :payment_method
attr_reader :datetime_updated
attr_reader :enriched_customer_data

def initialize(gateway, attributes) # :nodoc:
set_instance_variables_from_hash(attributes)
@payment_method = PaymentMethodParser.parse_payment_method(gateway, attributes[:payment_method])
@enriched_customer_data = EnrichedCustomerData._new(enriched_customer_data) if enriched_customer_data
end

class << self
protected :new
end

def self._new(*args) # :nodoc:
self.new(*args)
end
end
end
23 changes: 23 additions & 0 deletions lib/braintree/venmo_profile_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Braintree
class VenmoProfileData
include BaseModule

attr_reader :username
attr_reader :first_name
attr_reader :last_name
attr_reader :phone_number
attr_reader :email

def initialize(attributes) # :nodoc:
set_instance_variables_from_hash(attributes)
end

class << self
protected :new
end

def self._new(*args) # :nodoc:
self.new(*args)
end
end
end
2 changes: 1 addition & 1 deletion lib/braintree/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 4
Minor = 5
Minor = 6
Tiny = 0

String = "#{Major}.#{Minor}.#{Tiny}"
Expand Down
5 changes: 5 additions & 0 deletions lib/braintree/webhook_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module Kind
PartnerMerchantDisconnected = "partner_merchant_disconnected"
PartnerMerchantDeclined = "partner_merchant_declined"

PaymentMethodCustomerDataUpdated = "payment_method_customer_data_updated"

PaymentMethodRevokedByCustomer = "payment_method_revoked_by_customer"

RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
Expand Down Expand Up @@ -73,6 +75,7 @@ module Kind
attr_reader :local_payment_reversed
attr_reader :oauth_access_revocation
attr_reader :partner_merchant
attr_reader :payment_method_customer_data_updated_metadata
attr_reader :source_merchant_id
attr_reader :subscription
attr_reader :timestamp
Expand Down Expand Up @@ -108,6 +111,8 @@ def initialize(gateway, attributes) # :nodoc:
@local_payment_expired = LocalPaymentExpired._new(@subject[:local_payment_expired]) if @subject.has_key?(:local_payment_expired) && Kind::LocalPaymentExpired == @kind
@local_payment_funded = LocalPaymentFunded._new(@subject[:local_payment_funded]) if @subject.has_key?(:local_payment_funded) && Kind::LocalPaymentFunded == @kind
@local_payment_reversed = LocalPaymentReversed._new(@subject[:local_payment_reversed]) if @subject.has_key?(:local_payment_reversed) && Kind::LocalPaymentReversed == @kind
@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

end

def merchant_account
Expand Down
60 changes: 45 additions & 15 deletions lib/braintree/webhook_testing_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def _subject_sample_xml(kind, id)
_local_payment_funded_sample_xml(id)
when Braintree::WebhookNotification::Kind::LocalPaymentReversed
_local_payment_reversed_sample_xml
when Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated
_payment_method_customer_data_updated_sample_xml(id)
else
_subscription_sample_xml(id)
end
Expand Down Expand Up @@ -899,21 +901,7 @@ def _granted_payment_instrument_update_sample_xml(id)
end

def _granted_payment_method_revoked_xml(id)
<<-XML
<venmo-account>
<created-at type='dateTime'>2018-10-11T21:28:37Z</created-at>
<updated-at type='dateTime'>2018-10-11T21:28:37Z</updated-at>
<default type='boolean'>true</default>
<image-url>https://assets.braintreegateway.com/payment_method_logo/venmo.png?environment=test</image-url>
<token>#{id}</token>
<source-description>Venmo Account: venmojoe</source-description>
<username>venmojoe</username>
<venmo-user-id>456</venmo-user-id>
<subscriptions type='array'/>
<customer-id>venmo_customer_id</customer-id>
<global-id>cGF5bWVudG1ldGhvZF92ZW5tb2FjY291bnQ</global-id>
</venmo-account>
XML
_venmo_account_xml(id)
end

def _payment_method_revoked_by_customer_sample_xml(id)
Expand Down Expand Up @@ -986,5 +974,47 @@ def _local_payment_reversed_sample_xml
</local-payment-reversed>
XML
end

def _payment_method_customer_data_updated_sample_xml(id)
<<-XML
<payment-method-customer-data-updated-metadata>
<token>TOKEN-12345</token>
<payment-method>
#{_venmo_account_xml(id)}
</payment-method>
<datetime-updated type='dateTime'>2022-01-01T21:28:37Z</datetime-updated>
<enriched-customer-data>
<fields-updated type='array'>
<item>username</item>
</fields-updated>
<profile-data>
<username>venmo_username</username>
<first-name>John</first-name>
<last-name>Doe</last-name>
<phone-number>1231231234</phone-number>
<email>john.doe@paypal.com</email>
</profile-data>
</enriched-customer-data>
</payment-method-customer-data-updated-metadata>
XML
end

def _venmo_account_xml(id)
<<-XML
<venmo-account>
<created-at type='dateTime'>2018-10-11T21:28:37Z</created-at>
<updated-at type='dateTime'>2018-10-11T21:28:37Z</updated-at>
<default type='boolean'>true</default>
<image-url>https://assets.braintreegateway.com/payment_method_logo/venmo.png?environment=test</image-url>
<token>#{id}</token>
<source-description>Venmo Account: venmojoe</source-description>
<username>venmojoe</username>
<venmo-user-id>456</venmo-user-id>
<subscriptions type='array'/>
<customer-id>venmo_customer_id</customer-id>
<global-id>cGF5bWVudG1ldGhvZF92ZW5tb2FjY291bnQ</global-id>
</venmo-account>
XML
end
end
end
3 changes: 2 additions & 1 deletion spec/integration/braintree/payment_method_nonce_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
require "date"

describe Braintree::PaymentMethodNonce do
let(:config) { Braintree::Configuration.instantiate }
Expand Down Expand Up @@ -84,7 +85,7 @@
nonce.details.bin.should == "401288"
nonce.details.card_type.should == "Visa"
nonce.details.expiration_month.should == "12"
nonce.details.expiration_year.should == "2022"
nonce.details.expiration_year.should == Date.today.next_year.year.to_s
nonce.details.is_network_tokenized?.should be_nil
nonce.details.last_two.should == "81"
nonce.details.payer_info.should be_nil
Expand Down
32 changes: 32 additions & 0 deletions spec/unit/braintree/enriched_customer_data_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::EnrichedCustomerData do
describe "self.new" do
it "is protected" do
expect do
Braintree::EnrichedCustomerData.new
end.to raise_error(NoMethodError, /protected method .new/)
end
end

describe "self._new" do
it "initializes the object with the appropriate attributes set" do

params = {
fields_updated: ["username"],
profile_data: {
username: "a-username",
first_name: "a-first-name",
last_name: "a-last-name",
phone_number: "a-phone-number",
email: "a-email",
},
}

payment_method_customer_data_updated = Braintree::EnrichedCustomerData._new(params)

payment_method_customer_data_updated.profile_data.should be_a(Braintree::VenmoProfileData)
payment_method_customer_data_updated.fields_updated.should eq(["username"])
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::PaymentMethodCustomerDataUpdatedMetadata do
describe "self.new" do
it "is protected" do
expect do
Braintree::PaymentMethodCustomerDataUpdatedMetadata.new
end.to raise_error(NoMethodError, /protected method .new/)
end
end

describe "self._new" do
it "initializes the object with the appropriate attributes set" do

params = {
token: "a-token",
payment_method: {
venmo_account: {
venmo_user_id: "venmo-user-id",
},
},
datetime_updated: "2022-01-01T21:28:37Z",
enriched_customer_data: {
fields_updated: ["username"],
profile_data: {
username: "a-username",
first_name: "a-first-name",
last_name: "a-last-name",
phone_number: "a-phone-number",
email: "a-email",
},
},
}

payment_method_customer_data_updated = Braintree::PaymentMethodCustomerDataUpdatedMetadata._new(:gateway, params)

payment_method_customer_data_updated.token.should eq("a-token")
payment_method_customer_data_updated.datetime_updated.should eq("2022-01-01T21:28:37Z")
payment_method_customer_data_updated.payment_method.should be_a(Braintree::VenmoAccount)
payment_method_customer_data_updated.enriched_customer_data.profile_data.first_name.should eq("a-first-name")
payment_method_customer_data_updated.enriched_customer_data.profile_data.last_name.should eq("a-last-name")
payment_method_customer_data_updated.enriched_customer_data.fields_updated.should eq(["username"])
end
end
end
32 changes: 32 additions & 0 deletions spec/unit/braintree/venmo_profile_data_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::VenmoProfileData do
describe "self.new" do
it "is protected" do
expect do
Braintree::VenmoProfileData.new
end.to raise_error(NoMethodError, /protected method .new/)
end
end

describe "self._new" do
it "initializes the object with the appropriate attributes set" do

params = {
username: "a-username",
first_name: "a-first-name",
last_name: "a-last-name",
phone_number: "12312312343",
email: "a-email",
}

payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params)

payment_method_customer_data_updated.username.should eq("a-username")
payment_method_customer_data_updated.first_name.should eq("a-first-name")
payment_method_customer_data_updated.last_name.should eq("a-last-name")
payment_method_customer_data_updated.phone_number.should eq("12312312343")
payment_method_customer_data_updated.email.should eq("a-email")
end
end
end
Loading

0 comments on commit f521dd0

Please sign in to comment.