Ensure valid payment method is selected

This commit is contained in:
David Cook
2013-08-19 12:51:49 +10:00
parent 2d305b59d9
commit 3ffe732b30
2 changed files with 4 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ Spree::Admin::PaymentsController.class_eval do
# Only show payments for the order's distributor
def filter_payment_methods
@payment_methods = @payment_methods.select{ |pm| pm.has_distributor? @order.distributor}
@payment_method ||= @payment_methods.first
end
end

View File

@@ -15,10 +15,10 @@ Spree::PaymentMethod.class_eval do
where('distributor_id IN (?)', user.enterprises.map {|enterprise| enterprise.id })
end
}
end
def has_distributor?(distributor)
self.distributor == distributor
def has_distributor?(distributor)
self.distributor == distributor
end
end
# Ensure that all derived classes also allow distributor_id