|
56 | 56 | </div> |
57 | 57 | <div class="editing-hide"> |
58 | 58 | <% if payment.pending? %> |
59 | | - <%= link_to_with_icon 'edit', t('spree.actions.edit'), nil, no_text: true, class: "js-edit", data: {action: 'edit'} %> |
| 59 | + <%= link_to_with_icon 'edit', t('spree.actions.edit'), nil, no_text: true, class: "js-edit", data: { action: 'edit' } %> |
60 | 60 | <% end %> |
61 | | - <% allowed_actions = payment.actions.select { |a| can?(a.to_sym, payment) } %> |
62 | | - <% allowed_actions.each do |action| %> |
| 61 | + <% payment.actions.each do |action| %> |
| 62 | + <% next unless can?(action.to_sym, payment) %> |
| 63 | + |
63 | 64 | <% if action == 'credit' %> |
64 | | - <%= link_to_with_icon 'mail-reply', t('spree.actions.refund'), new_admin_order_payment_refund_path(@order, payment), no_text: true %> |
65 | | - <% elsif action == 'capture' && !@order.completed? %> |
66 | | - <%# no capture prior to completion. payments get captured when the order completes. %> |
| 65 | + <% next if payment.invalid? || payment.failed? || payment.checkout? %> |
| 66 | + |
| 67 | + <%= link_to_with_icon 'reply', t('spree.refund'), new_admin_order_payment_refund_path(@order, payment), no_text: true %> |
67 | 68 | <% else %> |
| 69 | + <% next if action == 'capture' && !@order.completed? %> |
| 70 | + <% next if action == 'void' && (payment.invalid? || payment.failed?) %> |
| 71 | + |
68 | 72 | <%= 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} %> |
69 | 73 | <% end %> |
70 | 74 | <% end %> |
|
0 commit comments