Skip to content

Commit

Permalink
Fix issue refunding uncompleted payments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Tapia committed Jan 31, 2025
1 parent ca1ae4d commit bd65229
Showing 1 changed file with 10 additions and 6 deletions.
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' && !@order.completed? %>
<%# 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' && !@order.completed? %>
<% 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

0 comments on commit bd65229

Please sign in to comment.