Add mandatory payment method provider to sample data payment methods

This commit is contained in:
luisramos0
2019-02-26 18:13:51 +00:00
parent 6790e8895d
commit d418ca1b1f

View File

@@ -24,6 +24,7 @@ class PaymentMethodFactory
def create_cash_method(enterprise)
create_payment_method(
"Spree::PaymentMethod::Check",
enterprise,
"Cash on collection",
"Pay on collection!",
@@ -33,6 +34,7 @@ class PaymentMethodFactory
def create_card_method(enterprise)
create_payment_method(
"Spree::Gateway::Bogus",
enterprise,
"Credit card (fake)",
"We charge 1%, but won't ask for your details. ;-)",
@@ -40,14 +42,14 @@ class PaymentMethodFactory
)
end
def create_payment_method(enterprise, name, description, calculator)
card = enterprise.payment_methods.new(
def create_payment_method(provider_class, enterprise, name, description, calculator)
payment_method = provider_class.constantize.new(
name: name,
description: description,
environment: Rails.env,
distributor_ids: [enterprise.id]
)
calculator.calculable = card
calculator.calculable = payment_method
calculator.save!
end
end