Class: NimbleshopSplitable::SplitablesController

Inherits:
Admin::PaymentMethodsController
  • Object
show all
Defined in:
app/controllers/nimbleshop_splitable/splitables_controller.rb

Instance Method Summary collapse

Instance Method Details

#notifyObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/nimbleshop_splitable/splitables_controller.rb', line 8

def notify
  Rails.logger.info "splitable callback received: #{params.to_yaml}"

  processor = NimbleshopSplitable::Processor.new(invoice: params[:invoice])

  if processor.acknowledge(params)
    render nothing: true
  else
    Rails.logger.info "webhook with data #{params.to_yaml} was rejected. error: #{processor.errors.join(',')}"
    render "error: #{error}", status: 403
  end
end

#updateObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/nimbleshop_splitable/splitables_controller.rb', line 21

def update
  alert_msg = if @payment_method.update_attributes(post_params[:splitable])
                msg = "Record has been updated"
                %Q[alert("#{msg}")]
              else
                msg =  @payment_method.errors.full_messages.first
                %Q[alert("#{msg}")]
              end

  respond_to do |format|
    format.js { render js: alert_msg }
  end
end