Remove payment method ApiCustomerCredit

This commit is contained in:
Gaetan Craig-Riou
2026-03-06 14:03:09 +11:00
parent 7790259c27
commit d5dec05ab1
8 changed files with 6 additions and 102 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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