Sha256: 4bfdc91447184958e216f9e761af8cd50737c51d36de10d8c2a29561fbbc3f31

Contents?: true

Size: 938 Bytes

Versions: 53

Compression:

Stored size: 938 Bytes

Contents

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

      def create
        queue_event(verified_event)
        head :ok
      rescue ::Braintree::InvalidSignature
        head :bad_request
      end

      private

      def queue_event(event)
        return unless Pay::Webhooks.delegator.listening?("braintree.#{event.kind}")

        record = Pay::Webhook.create!(
          processor: :braintree,
          event_type: event.kind,
          event: {bt_signature: params[:bt_signature], bt_payload: params[:bt_payload]}
        )
        Pay::Webhooks::ProcessJob.perform_later(record)
      end

      def verified_event
        Pay.braintree_gateway.webhook_notification.parse(params[:bt_signature], params[:bt_payload])
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
pay-8.3.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.2.2 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.2.1 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.2.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.1.3 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.1.2 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.1.1 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.1.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-8.0.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-7.3.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-7.2.1 app/controllers/pay/webhooks/braintree_controller.rb
pay-7.1.1 app/controllers/pay/webhooks/braintree_controller.rb
pay-7.1.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-7.0.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-6.8.1 app/controllers/pay/webhooks/braintree_controller.rb
pay-6.8.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-6.7.2 app/controllers/pay/webhooks/braintree_controller.rb
pay-6.7.1 app/controllers/pay/webhooks/braintree_controller.rb
pay-6.7.0 app/controllers/pay/webhooks/braintree_controller.rb
pay-6.6.1 app/controllers/pay/webhooks/braintree_controller.rb