Class: Spree::KomojuController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spree/komoju_controller.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/komoju_controller.rb', line 5

def callback
  return head :unauthorized unless callback_verified?

  case params[:type]
  when "ping"
    # do nothing
  when "payment.captured"
    order_number = extract_payment_number(params[:data][:external_order_num])
    payment = Spree::Payment.find_by_number!(order_number)
    payment.complete! unless payment.completed?
  else
    return head :unauthorized
  end

  head 200
end