mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Add mandatory payment method provider to sample data payment methods
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user