Sha256: ead4729b47c51d17c6519375fc244249232d482f1fe6654899c3a6edd7ec5200

Contents?: true

Size: 916 Bytes

Versions: 16

Compression:

Stored size: 916 Bytes

Contents

module Pay
  module Webhooks
    class PaddleController < Pay::ApplicationController
      if Rails.application.config.action_controller.default_protect_from_forgery
        skip_before_action :verify_authenticity_token
      end

      def create
        delegate_event(verified_event)
        head :ok
      rescue Pay::Paddle::Error
        head :bad_request
      end

      private

      def delegate_event(event)
        Pay::Webhooks.instrument type: "paddle.#{type}", event: event
      end

      def type
        params[:alert_name]
      end

      def verified_event
        event = check_params.as_json
        verifier = Pay::Paddle::Webhooks::SignatureVerifier.new(event)
        return event if verifier.verify
        raise Pay::Paddle::Error, "Unable to verify Paddle webhook event"
      end

      def check_params
        params.except(:action, :controller).permit!
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pay-2.7.2 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.7.1 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.7.0 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.11 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.10 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.9 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.8 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.7 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.6 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.5 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.4 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.3 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.2 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.1 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.6.0 app/controllers/pay/webhooks/paddle_controller.rb
pay-2.5.0 app/controllers/pay/webhooks/paddle_controller.rb