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
27
# File 'app/controllers/effective/providers/refund.rb', line 6

def refund
  raise('refund provider is not available') unless EffectiveOrders.refund?
  raise('refund provider is not configured for buyer purchase') unless EffectiveOrders.buyer_purchases_refund?

  @order ||= Order.deep.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



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

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