5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/pay/stripe/webhooks/customer_updated.rb', line 5
def call(event)
object = event.data.object
pay_customer = Pay::Customer.find_by(processor: :stripe, processor_id: object.id)
return unless pay_customer.present?
if (payment_method_id = pay_customer.customer.invoice_settings.default_payment_method)
Pay::Stripe::PaymentMethod.sync(payment_method_id, stripe_account: event.try(:account))
else
pay_customer.payment_methods.update_all(default: false)
end
end
|