Method: Spree::Admin::GiftCardsController#deactivate

Defined in:
app/controllers/spree/admin/gift_cards_controller.rb

#deactivateObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/spree/admin/gift_cards_controller.rb', line 38

def deactivate
  if @gift_card.deactivate
    flash[:success] = I18n.t('spree.admin.gift_cards.deactivated_gift_card')
    redirect_to edit_admin_order_path(@order)
  else
    flash[:error] = @gift_card.errors.full_messages.join(', ').presence || I18n.t('spree.admin.gift_cards.errors.unable_to_reimburse_gift_card')
    redirect_to edit_admin_order_gift_card_path(@order, @gift_card)
  end
rescue Spree::Reimbursement::IncompleteReimbursementError
  flash[:error] = I18n.t('spree.admin.gift_cards.errors.unable_to_reimburse_gift_card')
  redirect_to edit_admin_order_gift_card_path(@order, @gift_card)
end