mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7024 from Matt-Yorkley/dead-code-auto-capture
DCOTW: Spree::Config[:auto_capture]
This commit is contained in:
@@ -36,8 +36,6 @@ module Spree
|
||||
preference :allow_ssl_in_development_and_test, :boolean, default: false
|
||||
preference :allow_ssl_in_production, :boolean, default: true
|
||||
preference :allow_ssl_in_staging, :boolean, default: true
|
||||
# Automatically capture the credit card (as opposed to just authorize and capture later)
|
||||
preference :auto_capture, :boolean, default: false
|
||||
# Replace with the name of a zone if you would like to limit the countries
|
||||
preference :checkout_zone, :string, default: nil
|
||||
preference :currency, :string, default: "USD"
|
||||
|
||||
@@ -31,10 +31,6 @@ module Spree
|
||||
provider_class.new
|
||||
end
|
||||
|
||||
def auto_capture?
|
||||
true
|
||||
end
|
||||
|
||||
def method_type
|
||||
'paypal'
|
||||
end
|
||||
|
||||
@@ -6,22 +6,14 @@ module Spree
|
||||
def process!
|
||||
return unless validate!
|
||||
|
||||
if payment_method.auto_capture?
|
||||
purchase!
|
||||
else
|
||||
authorize!
|
||||
end
|
||||
purchase!
|
||||
end
|
||||
|
||||
def process_offline!
|
||||
return unless validate!
|
||||
return if authorization_action_required?
|
||||
|
||||
if payment_method.auto_capture?
|
||||
charge_offline!
|
||||
else
|
||||
authorize!
|
||||
end
|
||||
charge_offline!
|
||||
end
|
||||
|
||||
def authorize!(return_url = nil)
|
||||
|
||||
@@ -89,10 +89,6 @@ module Spree
|
||||
true
|
||||
end
|
||||
|
||||
def auto_capture?
|
||||
Spree::Config[:auto_capture]
|
||||
end
|
||||
|
||||
def supports?(_source)
|
||||
true
|
||||
end
|
||||
|
||||
@@ -22,10 +22,6 @@ Spree.config do |config|
|
||||
config.address_requires_state = true
|
||||
config.admin_interface_logo = '/default_images/ofn-logo.png'
|
||||
|
||||
# -- spree_paypal_express
|
||||
# Auto-capture payments. Without this option, payments must be manually captured in the paypal interface.
|
||||
config.auto_capture = true
|
||||
|
||||
# S3 settings
|
||||
config.s3_bucket = ENV['S3_BUCKET'] if ENV['S3_BUCKET']
|
||||
config.s3_access_key = ENV['S3_ACCESS_KEY'] if ENV['S3_ACCESS_KEY']
|
||||
|
||||
@@ -9,9 +9,6 @@ module Spree
|
||||
let(:bogus) { create(:bogus_payment_method, distributors: [create(:enterprise)]) }
|
||||
|
||||
before do
|
||||
# So that Payment#purchase! is called during processing
|
||||
Spree::Config[:auto_capture] = true
|
||||
|
||||
allow(order).to receive_message_chain(:line_items, :empty?).and_return(false)
|
||||
allow(order).to receive_messages total: 100
|
||||
end
|
||||
|
||||
@@ -81,20 +81,12 @@ describe Spree::Payment do
|
||||
end
|
||||
|
||||
context "#process!" do
|
||||
it "should purchase if with auto_capture" do
|
||||
it "should call purchase!" do
|
||||
payment = build_stubbed(:payment, payment_method: gateway)
|
||||
expect(payment.payment_method).to receive(:auto_capture?).and_return(true)
|
||||
expect(payment).to receive(:purchase!)
|
||||
payment.process!
|
||||
end
|
||||
|
||||
it "should authorize without auto_capture" do
|
||||
payment = build_stubbed(:payment, payment_method: gateway)
|
||||
expect(payment.payment_method).to receive(:auto_capture?).and_return(false)
|
||||
expect(payment).to receive(:authorize!)
|
||||
payment.process!
|
||||
end
|
||||
|
||||
it "should make the state 'processing'" do
|
||||
expect(payment).to receive(:started_processing!)
|
||||
payment.process!
|
||||
|
||||
@@ -178,7 +178,6 @@ RSpec.configure do |config|
|
||||
spree_config.checkout_zone = checkout_zone
|
||||
spree_config.currency = currency
|
||||
spree_config.shipping_instructions = true
|
||||
spree_config.auto_capture = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user