Sha256: 838b0c989d140b1475222da6b118da53762fb8b48a42487cb5fab4a4b4b34982
Contents?: true
Size: 745 Bytes
Versions: 3
Compression:
Stored size: 745 Bytes
Contents
module Spree class KomojuController < ApplicationController protect_from_forgery except: :callback def callback return head :unauthorized unless callback_verified? case params[:type] when "payment.captured" SpreeKomoju::Callbacks::Captured.new(params).process! when "payment.refunded" SpreeKomoju::Callbacks::Refunded.new(params).process! end head 200 end private def callback_verified? request_body = request.body.read signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), SpreeKomoju.komoju_webhook_secret_token.to_s, request_body) Rack::Utils.secure_compare(signature, request.env["HTTP_X_KOMOJU_SIGNATURE"].to_s) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spree_komoju-0.1.4 | app/controllers/spree/komoju_controller.rb |
spree_komoju-0.1.3 | app/controllers/spree/komoju_controller.rb |
spree_komoju-0.1.2 | app/controllers/spree/komoju_controller.rb |