mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Remove payment method ApiCustomerCredit
This commit is contained in:
@@ -123,8 +123,8 @@ module Spree
|
||||
|
||||
# Allows by passing the default scope on Spree::PaymentMethod. It's needed to link payment
|
||||
# to internal payment method.
|
||||
# Using ->{ unscope(where: :internal) } on the association doesn't work presumably because
|
||||
# the default scope is not a simple `where`.
|
||||
# Using ->{ unscoped } on the association doesn't work presumably because the default scope
|
||||
# is not a simple `where`.
|
||||
def payment_method
|
||||
Spree::PaymentMethod.unscoped { super }
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ module Spree
|
||||
acts_as_paranoid
|
||||
|
||||
DISPLAY = [:both, :back_end].freeze
|
||||
INTERNAL = %w{Spree::PaymentMethod::CustomerCredit Spree::PaymentMethod::ApiCustomerCredit}.freeze
|
||||
INTERNAL = Spree::PaymentMethod::CustomerCredit.to_s
|
||||
default_scope -> { where(deleted_at: nil).where.not(type: INTERNAL) }
|
||||
|
||||
has_many :credit_cards, class_name: "Spree::CreditCard", dependent: :destroy
|
||||
@@ -54,18 +54,12 @@ module Spree
|
||||
.where(environment: [Rails.env, "", nil])
|
||||
}
|
||||
|
||||
scope :internal, -> { unscoped.where(deleted_at: nil, type: INTERNAL) }
|
||||
|
||||
# These two method are used to get the two internal payment method. They are accessible to all
|
||||
# These method is used to get the internal payment method. It is accessible to all
|
||||
# enterprise, but the accessibility is managed by the code, as opposed to using the database.
|
||||
def self.customer_credit
|
||||
unscoped.find_by(type: "Spree::PaymentMethod::CustomerCredit", deleted_at: nil)
|
||||
end
|
||||
|
||||
def self.api_customer_credit
|
||||
unscoped.find_by(type: "Spree::PaymentMethod::ApiCustomerCredit", deleted_at: nil)
|
||||
end
|
||||
|
||||
def configured?
|
||||
!stripe? || stripe_configured?
|
||||
end
|
||||
@@ -132,13 +126,13 @@ module Spree
|
||||
end
|
||||
|
||||
def internal?
|
||||
type.in?(INTERNAL)
|
||||
type == INTERNAL
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def distributor_validation
|
||||
return true if type.in?(INTERNAL)
|
||||
return true if internal?
|
||||
|
||||
validates_with DistributorsValidator
|
||||
end
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# This payment method is not intended to be used with payment, it's used with customer account
|
||||
# transaction to indicate the transaction was created via API.
|
||||
module Spree
|
||||
class PaymentMethod
|
||||
class ApiCustomerCredit < Spree::PaymentMethod
|
||||
# Name and description are translatable string, to allow instances to customise them
|
||||
def name
|
||||
"api_payment_method.name"
|
||||
end
|
||||
|
||||
def description
|
||||
"api_payment_method.description"
|
||||
end
|
||||
|
||||
def payment_source_class
|
||||
nil
|
||||
end
|
||||
|
||||
def method_type
|
||||
"check" # empty view
|
||||
end
|
||||
|
||||
def source_required?
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user