Class: Spree::Api::Returnly::RefundsController

Inherits:
ApiController
  • Object
show all
Includes:
Returnly::RefundsConfiguration
Defined in:
app/controllers/spree/api/returnly/refunds_controller.rb

Instance Method Summary collapse

Methods included from Returnly::RefundsConfiguration

#gift_card_class, #gift_card_estimate_class, #refund_calculator_class, #refund_presenter_class, #refunder_class, #return_item_amount_calculator_class, #return_item_builder_class, #return_item_restock_policy_class

Methods inherited from ApiController

#set_headers

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/api/returnly/refunds_controller.rb', line 12

def create
  authorize! :create, Order

  refunds = refunder_class.new order: order,
                               line_items: line_items_params,
                               product_refund_amount: product_refund_amount_param,
                               shipping_refund_amount: shipping_refund_amount_param
  render json: refunds.proceed!
end

#estimateObject



7
8
9
10
# File 'app/controllers/spree/api/returnly/refunds_controller.rb', line 7

def estimate
  authorize! :create, Order
  render json: refund_calculator_class.process(order, line_items_params)
end