mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove Pin Payments
This commit is contained in:
@@ -396,7 +396,6 @@ Style/CaseEquality:
|
||||
Style/ClassAndModuleChildren:
|
||||
Exclude:
|
||||
- 'app/models/calculator/flat_percent_per_item.rb'
|
||||
- 'app/models/spree/gateway/pin.rb'
|
||||
- 'app/models/tag_rule/discount_order.rb'
|
||||
- 'app/models/tag_rule/filter_order_cycles.rb'
|
||||
- 'app/models/tag_rule/filter_payment_methods.rb'
|
||||
@@ -612,7 +611,6 @@ Style/FrozenStringLiteralComment:
|
||||
- 'app/models/product_import/unit_converter.rb'
|
||||
- 'app/models/proxy_order.rb'
|
||||
- 'app/models/schedule.rb'
|
||||
- 'app/models/spree/gateway/pin.rb'
|
||||
- 'app/models/spree/gateway/stripe_connect.rb'
|
||||
- 'app/models/spree/preferences/file_configuration.rb'
|
||||
- 'app/models/spree/property.rb'
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
module Spree
|
||||
class Gateway::Pin < Gateway
|
||||
preference :api_key, :string
|
||||
|
||||
def provider_class
|
||||
ActiveMerchant::Billing::PinGateway
|
||||
end
|
||||
|
||||
def options_with_test_preference
|
||||
options_without_test_preference.merge(test: preferred_test_mode)
|
||||
end
|
||||
|
||||
alias_method_chain :options, :test_preference
|
||||
end
|
||||
end
|
||||
@@ -103,8 +103,6 @@ module Spree
|
||||
source.user_id = order.user_id if order
|
||||
end
|
||||
|
||||
# Pin payments lacks void and credit methods, but it does have refund
|
||||
# Here we swap credit out for refund and remove void as a possible action
|
||||
def actions
|
||||
return [] unless payment_source&.respond_to?(:actions)
|
||||
|
||||
@@ -113,11 +111,6 @@ module Spree
|
||||
payment_source.__send__("can_#{action}?", self)
|
||||
end
|
||||
|
||||
if payment_method.is_a? Gateway::Pin
|
||||
actions << 'refund' if actions.include? 'credit'
|
||||
actions.reject! { |a| ['credit', 'void'].include? a }
|
||||
end
|
||||
|
||||
actions
|
||||
end
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@ module Checkout
|
||||
end
|
||||
|
||||
# Ensures cc_type is always passed to the model by inferring the type when
|
||||
# the frontend didn't provide it. This fixes Pin Payments specifically
|
||||
# although it might be useful for future payment gateways.
|
||||
#
|
||||
# More details: app/assets/javascripts/darkswarm/services/checkout.js.coffee#L70-L98
|
||||
# the frontend didn't provide it.
|
||||
def fill_in_card_type
|
||||
return unless payment_source_attributes
|
||||
|
||||
|
||||
@@ -125,7 +125,6 @@ module Openfoodnetwork
|
||||
|
||||
# Register Spree payment methods
|
||||
initializer "spree.gateway.payment_methods", :after => "spree.register.payment_methods" do |app|
|
||||
app.config.spree.payment_methods << Spree::Gateway::Pin
|
||||
app.config.spree.payment_methods << Spree::Gateway::StripeConnect
|
||||
app.config.spree.payment_methods << Spree::Gateway::StripeSCA
|
||||
app.config.spree.payment_methods << Spree::Gateway::PayPalExpress
|
||||
|
||||
@@ -41,20 +41,6 @@ module Spree
|
||||
expect(response).to redirect_to spree.edit_admin_payment_method_path(assigns(:payment_method))
|
||||
end
|
||||
|
||||
it "can save Pin Payment payment method details" do
|
||||
expect {
|
||||
spree_post :create, payment_method: {
|
||||
name: "Test Method", type: "Spree::Gateway::Pin", distributor_ids: [enterprise.id],
|
||||
preferred_server: "test", preferred_api_key: "apikey123", preferred_test_mode: "1"
|
||||
}
|
||||
}.to change(Spree::PaymentMethod, :count).by(1)
|
||||
|
||||
payment_method = Spree::PaymentMethod.last
|
||||
expect(payment_method.preferences[:server]).to eq "test"
|
||||
expect(payment_method.preferences[:api_key]).to eq "apikey123"
|
||||
expect(payment_method.preferences[:test_mode]).to eq true
|
||||
end
|
||||
|
||||
it "can not create a payment method of an invalid type" do
|
||||
expect {
|
||||
spree_post :create, payment_method: { name: "Invalid Payment Method", type: "Spree::InvalidType", distributor_ids: [enterprise.id] }
|
||||
|
||||
@@ -59,7 +59,6 @@ module Spree
|
||||
|
||||
it "generates a clean name for known Payment Method types" do
|
||||
expect(Spree::PaymentMethod::Check.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.check"))
|
||||
expect(Spree::Gateway::Pin.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.pin"))
|
||||
expect(Spree::Gateway::PayPalExpress.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.paypalexpress"))
|
||||
expect(Spree::Gateway::StripeConnect.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripeconnect"))
|
||||
expect(Spree::Gateway::StripeSCA.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripesca"))
|
||||
|
||||
@@ -711,28 +711,6 @@ describe Spree::Payment do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "for Pin Payments" do
|
||||
let(:d) { create(:distributor_enterprise) }
|
||||
let(:pin) { Spree::Gateway::Pin.create! name: 'pin', distributor_ids: [d.id] }
|
||||
let(:payment) { create(:payment, source: create(:credit_card), payment_method: pin) }
|
||||
|
||||
it "does not void" do
|
||||
expect(payment.actions).not_to include 'void'
|
||||
end
|
||||
|
||||
describe "when a payment has been taken" do
|
||||
before do
|
||||
allow(payment).to receive(:state) { 'completed' }
|
||||
allow(payment).to receive(:order) { double(:order, payment_state: 'credit_owed') }
|
||||
end
|
||||
|
||||
it "can refund instead of crediting" do
|
||||
expect(payment.actions).not_to include 'credit'
|
||||
expect(payment.actions).to include 'refund'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "refund!" do
|
||||
|
||||
Reference in New Issue
Block a user