mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Add new payment method ApiCustomerCredit
It was previously modelled by a "Check" payment method
This commit is contained in:
30
app/models/spree/payment_method/api_customer_credit.rb
Normal file
30
app/models/spree/payment_method/api_customer_credit.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
15
spec/models/spree/payment_method/api_customer_credit_spec.rb
Normal file
15
spec/models/spree/payment_method/api_customer_credit_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user