Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backend] Fix issue refunding uncompleted payments #6094

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/spec/features/return_reasons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
expect(page).to be_axe_clean
end

it "closing the modal keeps query params" do
it "closing the modal keeps query params", :flaky do
within("dialog") { click_on "Cancel" }
expect(page).not_to have_selector("dialog")
expect(page.current_url).to include(query)
Expand Down
16 changes: 10 additions & 6 deletions backend/app/views/spree/admin/payments/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@
</div>
<div class="editing-hide">
<% if payment.pending? %>
<%= link_to_with_icon 'edit', t('spree.actions.edit'), nil, no_text: true, class: "js-edit", data: {action: 'edit'} %>
<%= link_to_with_icon 'edit', t('spree.actions.edit'), nil, no_text: true, class: "js-edit", data: { action: 'edit' } %>
<% end %>
<% allowed_actions = payment.actions.select { |a| can?(a.to_sym, payment) } %>
<% allowed_actions.each do |action| %>
<% payment.actions.each do |action| %>
<% next unless can?(action.to_sym, payment) %>

<% if action == 'credit' %>
<%= link_to_with_icon 'mail-reply', t('spree.actions.refund'), new_admin_order_payment_refund_path(@order, payment), no_text: true %>
<% elsif action == 'capture' && [email protected]? %>
<%# no capture prior to completion. payments get captured when the order completes. %>
<% next if payment.invalid? || payment.failed? || payment.checkout? %>

<%= link_to_with_icon 'reply', t('spree.refund'), new_admin_order_payment_refund_path(@order, payment), no_text: true %>
<% else %>
<% next if action == 'capture' && [email protected]? %>
<% next if action == 'void' && (payment.invalid? || payment.failed?) %>

<%= link_to_with_icon action, t(action, scope: 'spree'), fire_admin_order_payment_path(@order, payment, e: action), method: :put, no_text: true, data: {action: action} %>
<% end %>
<% end %>
Expand Down
9 changes: 9 additions & 0 deletions backend/spec/features/admin/orders/payments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,21 @@
click_icon(:capture)
expect(page).not_to have_content('Cannot perform requested operation')
expect(page).to have_content('Payment Updated')
within_row(1) do
expect(page).to have_selector('.fa-reply')
end
end

it 'voids a check payment from a new order' do
click_icon(:void)
expect(page).to have_content('Payment Updated')
end

it 'voids refund option for incomplete payments' do
within_row(1) do
expect(page).not_to have_selector('.fa-reply')
end
end
end

it 'should list all captures for a payment' do
Expand Down