Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Don't try and add billing address if there is no billing address attached to credit card #120

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions app/models/solidus_paypal_braintree/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ def transaction_options(source, options, submit_for_settlement = false)
params[:payment_method_nonce] = source.nonce
end

if source.paypal?
if source.paypal? && options[:billing_address].present?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be

options[:shipping_address].present?

params[:shipping] = braintree_shipping_address(options)
end

if source.credit_card?
if source.credit_card? && options[:billing_address].present?
params[:billing] = braintree_billing_address(options)
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/solidus_paypal_braintree/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Source < SolidusSupport.payment_source_parent_class
scope(:with_payment_profile, -> { joins(:customer) })
scope(:credit_card, -> { where(payment_type: CREDIT_CARD) })

delegate :last_4, :card_type, to: :braintree_payment_method, allow_nil: true
delegate :last_4, :card_type, :cardholder_name, :expiration_month, :expiration_year, :email, to: :braintree_payment_method, allow_nil: true
alias_method :last_digits, :last_4

# we are not currenctly supporting an "imported" flag
Expand Down Expand Up @@ -74,7 +74,7 @@ def display_number
private

def braintree_payment_method
return unless braintree_client && credit_card?
return unless braintree_client && (credit_card? || paypal?)
@braintree_payment_method ||= protected_request do
braintree_client.payment_method.find(token)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<tr id="<%= dom_id(wallet_payment_source, 'spree') %>" class="<%= cycle('even', 'odd') %>">
<td>
<%= radio_button_tag "order[wallet_payment_source_id]", wallet_payment_source.id, default, class: "existing-cc-radio" %>
</td>
<td>
<%- if wallet_payment_source.payment_source.credit_card? %>
<div><%= wallet_payment_source.payment_source.cardholder_name %></div>
<div><%= wallet_payment_source.payment_source.card_type %> - <%= wallet_payment_source.payment_source.display_number %></div>
<div><%= wallet_payment_source.payment_source.expiration_month %>/<%= wallet_payment_source.payment_source.expiration_year %></div>
<%- elsif wallet_payment_source.payment_source.paypal? %>
<div>Paypal</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be PayPal (Pal is also capitalized)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, Shoot. Didn't mean to include this here.

Will pull it out. See other pull request to see if we want to pull that in.

Thanks!

<div><%= wallet_payment_source.payment_source.email %></div>
<% end %>
</td>
</tr>