Sha256: 2b12cd5c3c770236393178a52b7022de04bc592110910e89cf9c80de8cb39619

Contents?: true

Size: 542 Bytes

Versions: 17

Compression:

Stored size: 542 Bytes

Contents

module Pay
  module Stripe
    module Webhooks
      class ChargeSucceeded
        def call(event)
          pay_charge = Pay::Stripe::Charge.sync(event.data.object.id, stripe_account: event.try(:account))
          notify_user(pay_charge.customer.owner, pay_charge) if pay_charge
        end

        def notify_user(billable, charge)
          if Pay.send_emails && charge.respond_to?(:receipt)
            Pay::UserMailer.with(billable: billable, charge: charge).receipt.deliver_later
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pay-3.0.17 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.16 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.15 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.14 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.13 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.12 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.11 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.10 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.9 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.8 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.7 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.6 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.5 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.4 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.2 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.1 lib/pay/stripe/webhooks/charge_succeeded.rb
pay-3.0.0 lib/pay/stripe/webhooks/charge_succeeded.rb