mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-01 06:41:41 +00:00
Only show credit cards if previously saved, split credit card db migrations and tidy up serializer
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
class Api::CreditCardSerializer < ActiveModel::Serializer
|
||||
attributes :id, :month, :year, :cc_type, :last_digits, :first_name, :last_name, :formatted
|
||||
attributes :id, :formatted
|
||||
|
||||
def formatted
|
||||
elements = []
|
||||
elements << cc_type.capitalize if cc_type
|
||||
if last_digits
|
||||
elements << object.cc_type.capitalize if object.cc_type
|
||||
if object.last_digits
|
||||
3.times { elements << I18n.t(:card_masked_digit) * 4 }
|
||||
elements << object.last_digits
|
||||
end
|
||||
elements << last_digits if last_digits
|
||||
elements << I18n.t(:card_expiry_abbreviation)
|
||||
elements << month.to_s + "/" + year.to_s if month # TODO: I18n
|
||||
elements << object.month.to_s + "/" + object.year.to_s if object.month # TODO: I18n
|
||||
elements.join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
.row
|
||||
.small-12.columns
|
||||
%label
|
||||
= t :previously_used_credit_cards
|
||||
%select{"ng-model" => "selected_card", "ng-options" => "card.id as card.formatted for card in savedCreditCards", name: "secrets.card_year", required: true}
|
||||
|
||||
|
||||
.row
|
||||
.small-6.columns
|
||||
%label
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
.row{ "ng-show" => "savedCreditCards != null && savedCreditCards.length > 0" }
|
||||
.small-12.columns
|
||||
%label
|
||||
= t :previously_used_credit_cards
|
||||
%select{"ng-model" => "selected_card", "ng-options" => "card.id as card.formatted for card in savedCreditCards", name: "secrets.card_year", required: true}
|
||||
|
||||
= render "spree/checkout/payment/gateway", payment_method: payment_method
|
||||
|
||||
:javascript
|
||||
|
||||
@@ -4,10 +4,5 @@ class AddUserIdToSpreeCreditCards < ActiveRecord::Migration
|
||||
add_column :spree_credit_cards, :user_id, :integer
|
||||
add_index :spree_credit_cards, :user_id
|
||||
end
|
||||
|
||||
unless Spree::CreditCard.column_names.include? "payment_method_id"
|
||||
add_column :spree_credit_cards, :payment_method_id, :integer
|
||||
add_index :spree_credit_cards, :payment_method_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class AddPaymentMethodToSpreeCreditCards < ActiveRecord::Migration
|
||||
def change
|
||||
unless Spree::CreditCard.column_names.include? "payment_method_id"
|
||||
add_column :spree_credit_cards, :payment_method_id, :integer
|
||||
add_index :spree_credit_cards, :payment_method_id
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user