Class: SpreeStripe::WebhookHandlers::PaymentIntentSucceeded

Inherits:
Base
  • Object
show all
Defined in:
app/services/spree_stripe/webhook_handlers/payment_intent_succeeded.rb

Constant Summary

Constants inherited from Base

Base::ENQUEUE_DELAY

Instance Method Summary collapse

Instance Method Details

#call(event) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/services/spree_stripe/webhook_handlers/payment_intent_succeeded.rb', line 4

def call(event)
  stripe_id = event.data.object[:id]

  return if enqueue_complete_order_from_session(stripe_id)

  # Legacy system: PaymentIntent
  payment_intent = SpreeStripe::PaymentIntent.find_by(stripe_id: stripe_id)
  return if payment_intent.nil?

  SpreeStripe::CompleteOrderJob.set(wait: ENQUEUE_DELAY).perform_later(payment_intent.id)
end