Sha256: 58e4230a759500e9ca5f4786f222567c97c75504fe6f4f75c0f9913e9804bc9e
Contents?: true
Size: 722 Bytes
Versions: 21
Compression:
Stored size: 722 Bytes
Contents
module Pay module Stripe module Webhooks class CustomerDeleted def call(event) object = event.data.object pay_customer = Pay::Customer.find_by(processor: :stripe, processor_id: object.id) # Skip processing if this customer is not in the database return unless pay_customer # Mark all subscriptions as canceled pay_customer.subscriptions.active.update_all(ends_at: Time.current, status: "canceled") # Remove all payment methods pay_customer.payment_methods.destroy_all # Mark customer as deleted pay_customer.update!(default: false, deleted_at: Time.current) end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems