Add new payment method ApiCustomerCredit

It was previously modelled by a "Check" payment method
This commit is contained in:
Gaetan Craig-Riou
2026-03-04 13:07:06 +11:00
parent 2e7237197a
commit ec106a8f83
3 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
# 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

View File

@@ -34,4 +34,9 @@ FactoryBot.define do
environment { 'test' }
internal { true }
end
factory :api_customer_credit_payment_method, class: Spree::PaymentMethod::ApiCustomerCredit do
environment { 'test' }
internal { true }
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Spree::PaymentMethod::ApiCustomerCredit do
subject { build(:api_customer_credit_payment_method) }
describe "#name" do
it { expect(subject.name).to eq("api_payment_method.name") }
end
describe "#description" do
it { expect(subject.description).to eq("api_payment_method.description") }
end
end