Sha256: 36b9f495131ba1077336d1bf4c51eddde679369b2fbdfa7385b59e4ef7585dd3

Contents?: true

Size: 1.23 KB

Versions: 141

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

141 entries across 141 versions & 1 rubygems

Version Path
bullet_train-integrations-stripe-1.6.26 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.25 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.24 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.23 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.22 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.21 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.20 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.19 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.18 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.17 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.16 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.15 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.14 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.13 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.12 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.11 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.10 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.9 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.8 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb
bullet_train-integrations-stripe-1.6.7 app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb