Skip to content

Commit

Permalink
Make sure Braintree::PaymentMethod.find returns a Braintree::VenmoAcc…
Browse files Browse the repository at this point in the history
…ount

If a payment token response returns a venmo_account the result of 'Braintree::PaymentMethod.find(token)' should be a Braintree::VenmoAccount instance
  • Loading branch information
NickMele committed Nov 15, 2017
1 parent 85dfe15 commit 394da6e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/braintree/payment_method_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def find(token)
ApplePayCard._new(@gateway, response[:apple_pay_card])
elsif response.has_key?(:android_pay_card)
AndroidPayCard._new(@gateway, response[:android_pay_card])
elsif response.has_key?(:venmo_account)
VenmoAccount._new(@gateway, response[:venmo_account])
else
UnknownPaymentMethod._new(@gateway, response)
end
Expand Down
24 changes: 24 additions & 0 deletions spec/integration/braintree/payment_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,30 @@
end
end

context "venmo accounts" do
it "finds the payment method with the given token" do
customer = Braintree::Customer.create!
payment_method_token = "PAYMENT_METHOD_TOKEN_#{rand(36**3).to_s(36)}"
result = Braintree::PaymentMethod.create(
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
:customer_id => customer.id,
:token => payment_method_token
)
result.should be_success

venmo_account = Braintree::PaymentMethod.find(payment_method_token)
venmo_account.should be_a(Braintree::VenmoAccount)
venmo_account.should_not be_nil
venmo_account.token.should == payment_method_token
venmo_account.default.should == true
venmo_account.image_url.should =~ /venmo/
venmo_account.username.should == 'venmojoe'
venmo_account.venmo_user_id.should == 'Venmo-Joe-1'
venmo_account.source_description.should == "Venmo Account: venmojoe"
venmo_account.customer_id.should == customer.id
end
end

context "android pay cards" do
it "finds the proxy card payment method with the given token" do
customer = Braintree::Customer.create!
Expand Down

0 comments on commit 394da6e

Please sign in to comment.