mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
void payments requiring auth upon marking order paid
This commit is contained in:
@@ -344,6 +344,7 @@ module Spree
|
||||
|
||||
# update payment and shipment(s) states, and save
|
||||
updater.update_payment_state
|
||||
cancel_payments_requiring_auth
|
||||
shipments.each do |shipment|
|
||||
shipment.update!(self)
|
||||
shipment.finalize!
|
||||
@@ -611,6 +612,12 @@ module Spree
|
||||
|
||||
private
|
||||
|
||||
def cancel_payments_requiring_auth
|
||||
return unless payment_state == "paid"
|
||||
|
||||
payments.requires_authorization.each(&:void_transaction!)
|
||||
end
|
||||
|
||||
def fee_handler
|
||||
@fee_handler ||= OrderFeesHandler.new(self)
|
||||
end
|
||||
|
||||
@@ -195,6 +195,21 @@ describe Spree::Order do
|
||||
expect(order.updater).to receive(:before_save_hook)
|
||||
order.finalize!
|
||||
end
|
||||
|
||||
context "extra payments exist that require authorization" do
|
||||
let!(:cash_payment) { build(:payment, state: "completed", amount: order.new_outstanding_balance) }
|
||||
let!(:stripe_payment) { build(:payment, state: "requires_authorization") }
|
||||
before do
|
||||
order.payments << cash_payment
|
||||
order.payments << stripe_payment
|
||||
allow_any_instance_of(Spree::Payment).to receive(:void_transaction!) {}
|
||||
end
|
||||
|
||||
it "cancels payments requiring authorization" do
|
||||
expect_any_instance_of(Spree::Payment).to receive(:void_transaction!)
|
||||
order.finalize!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#process_payments!" do
|
||||
|
||||
Reference in New Issue
Block a user