diff --git a/app/models/solidus_paypal_braintree/gateway.rb b/app/models/solidus_paypal_braintree/gateway.rb index 347737b7..35fad113 100644 --- a/app/models/solidus_paypal_braintree/gateway.rb +++ b/app/models/solidus_paypal_braintree/gateway.rb @@ -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? 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 diff --git a/app/models/solidus_paypal_braintree/source.rb b/app/models/solidus_paypal_braintree/source.rb index ec486435..a8be9ce6 100644 --- a/app/models/solidus_paypal_braintree/source.rb +++ b/app/models/solidus_paypal_braintree/source.rb @@ -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 @@ -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 diff --git a/lib/views/frontend/spree/checkout/existing_payment/_paypal_braintree.html.erb b/lib/views/frontend/spree/checkout/existing_payment/_paypal_braintree.html.erb new file mode 100644 index 00000000..43f39dee --- /dev/null +++ b/lib/views/frontend/spree/checkout/existing_payment/_paypal_braintree.html.erb @@ -0,0 +1,15 @@ +