diff --git a/core/app/models/spree/payment/cancellation.rb b/core/app/models/spree/payment/cancellation.rb index ec70281dcf3..2fd7aa429b1 100644 --- a/core/app/models/spree/payment/cancellation.rb +++ b/core/app/models/spree/payment/cancellation.rb @@ -31,7 +31,7 @@ def cancel(payment) if response = payment.payment_method.try_void(payment) payment.send(:handle_void_response, response) else - payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason) + payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason).perform! end else # For payment methods not yet implemeting `try_void` diff --git a/core/spec/models/spree/order_spec.rb b/core/spec/models/spree/order_spec.rb index 3987c489cc4..794d2f1d53c 100644 --- a/core/spec/models/spree/order_spec.rb +++ b/core/spec/models/spree/order_spec.rb @@ -127,7 +127,7 @@ let(:payment) { create(:payment, order: order, amount: payment_amount, state: 'completed') } before do - create(:refund, payment: payment, amount: payment_amount) + create(:refund, payment: payment, amount: payment_amount).perform! end it "cancels the order" do @@ -281,7 +281,7 @@ order.cancellations.short_ship([order.inventory_units.first]) expect(order.outstanding_balance).to be_negative expect(order.payment_state).to eq('credit_owed') - create(:refund, amount: order.outstanding_balance.abs, payment: payment, transaction_id: nil) + create(:refund, amount: order.outstanding_balance.abs, payment: payment, transaction_id: nil).perform! order.reload expect(order.outstanding_balance).to eq(0) expect(order.payment_state).to eq('paid') diff --git a/core/spec/models/spree/payment/cancellation_spec.rb b/core/spec/models/spree/payment/cancellation_spec.rb index 05be547eb84..386749aa31a 100644 --- a/core/spec/models/spree/payment/cancellation_spec.rb +++ b/core/spec/models/spree/payment/cancellation_spec.rb @@ -51,7 +51,7 @@ payment.refunds.create!( amount: credit_amount, reason: Spree::RefundReason.where(name: 'test').first_or_create - ) + ).perform! end it 'only refunds the allowed credit amount' do