Module: Effective::Providers::Refund

Extended by:
ActiveSupport::Concern
Included in:
OrdersController
Defined in:
app/controllers/effective/providers/refund.rb

Instance Method Summary collapse

Instance Method Details

#refundObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/effective/providers/refund.rb', line 6

def refund
  raise('refund provider is not available') unless EffectiveOrders.refund?

  @order ||= Order.find(params[:id])

  EffectiveResources.authorize!(self, :update, @order)

  unless @order.refund?
    flash[:danger] = 'Unable to process refund order with a positive total'
    redirect_to effective_orders.order_path(@order)
    return
  end

  flash[:success] = EffectiveOrders.refund[:success].presence

  order_purchased(
    payment: 'refund. no payment required.',
    provider: 'refund',
    purchased_url: refund_params[:purchased_url]
  )
end

#refund_paramsObject



28
29
30
# File 'app/controllers/effective/providers/refund.rb', line 28

def refund_params
  params.require(:refund).permit(:purchased_url, :declined_url)
end