From 1385e20a87e5252a257ebb78cda1fc7ee140d5e2 Mon Sep 17 00:00:00 2001 From: Alessandro Lepore Date: Fri, 6 Jul 2018 18:03:45 +0200 Subject: [PATCH] Add missing partial for existing braintree sources --- app/models/solidus_paypal_braintree/source.rb | 9 +++++++-- .../existing_payment/_paypal_braintree.html.erb | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 app/views/spree/checkout/existing_payment/_paypal_braintree.html.erb diff --git a/app/models/solidus_paypal_braintree/source.rb b/app/models/solidus_paypal_braintree/source.rb index 3407eca2..421018fc 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, :email, to: :braintree_payment_method, allow_nil: true alias_method :last_digits, :last_4 # we are not currenctly supporting an "imported" flag @@ -68,7 +68,12 @@ def credit_card? end def display_number - "XXXX-XXXX-XXXX-#{last_digits.to_s.rjust(4, 'X')}" + case payment_type + when CREDIT_CARD, APPLE_PAY + "XXXX-XXXX-XXXX-#{last_digits.to_s.rjust(4, 'X')}" + when PAYPAL + email + end end private diff --git a/app/views/spree/checkout/existing_payment/_paypal_braintree.html.erb b/app/views/spree/checkout/existing_payment/_paypal_braintree.html.erb new file mode 100644 index 00000000..f9de0114 --- /dev/null +++ b/app/views/spree/checkout/existing_payment/_paypal_braintree.html.erb @@ -0,0 +1,10 @@ + + + <%= radio_button_tag "order[wallet_payment_source_id]", + wallet_payment_source.id, + default, + class: "existing-cc-radio" %> + + <%= wallet_payment_source.payment_source.friendly_payment_type %> + <%= wallet_payment_source.payment_source.display_number %> +