Class: SpreeStripe::WebhookHandlers::PaymentIntentPaymentFailed

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

Instance Method Summary collapse

Instance Method Details

#call(event) ⇒ Object



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

def call(event)
  payment_intent = SpreeStripe::PaymentIntent.find_by(stripe_id: event.data.object.id)
  return if payment_intent.nil?

  order = payment_intent.order
  return if order.canceled?

  order.cancel! if order.can_cancel?
end