Module: Webhooks::Incoming::Oauth::StripeAccountWebhooks::Base

Extended by:
ActiveSupport::Concern
Included in:
Webhooks::Incoming::Oauth::StripeAccountWebhook
Defined in:
app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb

Instance Method Summary collapse

Instance Method Details

#processObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/concerns/webhooks/incoming/oauth/stripe_account_webhooks/base.rb', line 10

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::StripeAccount.find_by(uid: data["account"]))

      # save the reference to the account.
      save

      # delegate processing to that 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