Sha256: 36b9f495131ba1077336d1bf4c51eddde679369b2fbdfa7385b59e4ef7585dd3

Contents?: true

Size: 1.23 KB

Versions: 140

Compression:

Stored size: 1.23 KB

Contents

module Webhooks::Incoming::Oauth::StripeAccountWebhooks::Base
  extend ActiveSupport::Concern

  included do
    include Webhooks::Incoming::Webhook

    belongs_to :oauth_stripe_account, class_name: "Oauth::StripeAccount", optional: true
  end

  def process
    # if this is a stripe connect webhook ..
    if data["account"]

      # if we're able to find an account in our system that this webhook should be routed to ..
      if (self.oauth_stripe_account = Oauth::StripeAccount.find_by(uid: data["account"]))

        # save the reference to the account.
        save

        # delegate processing to that account.
        oauth_stripe_account.process_webhook(self)

      end

      # if we didn't find an account for the webhook, they've probably deleted their account. we'll just ignore it for
      # now, but it's still in our database for debugging purposes. we'll probably want to send a request to stripe
      # in order to disconnect their account from our application so we stop receiving webhooks.

    else

      # it's possible we're receiving a general webhook that isn't specific to an account.
      # however, we want to know about these, so raise an error.
      raise "received a webhook we weren't expecting"

    end
  end
end

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
bullet_train-integrations-stripe-1.10.0 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.9.0 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.8.5 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.8.4 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.8.3 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.8.2 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.8.1 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.8.0 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.23 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.22 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.21 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.20 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.19 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.18 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.17 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.16 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.15 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.14 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.13 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.7.12 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb