Class: NimbleshopPaypalwp::PaypalwpsController

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/nimbleshop_paypalwp/paypalwps_controller.rb

Instance Method Summary collapse

Instance Method Details

#notifyObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/nimbleshop_paypalwp/paypalwps_controller.rb', line 12

def notify
  processor = NimbleshopPaypalwp::Processor.new(raw_post: request.raw_post)
  order = processor.order

  # order is already in purchased state. Seems like IPN is sending duplicate notification
  processor.purchase unless order.purchased?

  render nothing: true
end

#updateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/nimbleshop_paypalwp/paypalwps_controller.rb', line 22

def update
  alert_msg = if @payment_method.update_attributes(post_params[:paypalwp])
                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