Class: Pay::Lago::Webhooks::InvoiceCreated

Inherits:
Object
  • Object
show all
Defined in:
lib/pay/lago/webhooks/invoice_created.rb

Instance Method Summary collapse

Instance Method Details

#call(event) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/pay/lago/webhooks/invoice_created.rb', line 5

def call(event)
  pay_charge = Pay::Lago::Charge.sync(event.invoice.lago_id, object: event.invoice)

  if pay_charge && Pay.send_email?(:receipt, pay_charge)
    Pay.mailer.with(pay_customer: pay_charge.customer, pay_charge: pay_charge).receipt.deliver_later
  end
end