Class: SpreeStripe::CreateGatewayWebhooks

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_stripe/create_gateway_webhooks.rb

Instance Method Summary collapse

Instance Method Details

#call(payment_method:, events: SpreeStripe::Config[:supported_webhook_events], connect: false) ⇒ Object



3
4
5
6
7
8
# File 'app/services/spree_stripe/create_gateway_webhooks.rb', line 3

def call(payment_method:, events: SpreeStripe::Config[:supported_webhook_events], connect: false)
  webhook_list = Stripe::WebhookEndpoint.list({}, { api_key: payment_method.preferred_secret_key })
  webhook = find_webhook(payment_method, webhook_list[:data], events)

  ensure_webhook(payment_method, webhook, connect, events)
end