Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
799 B
Ruby
37 lines
799 B
Ruby
module Billing
|
|
module Stripe
|
|
class SyncPayments
|
|
def self.call(club:)
|
|
new(club: club).call
|
|
end
|
|
|
|
def initialize(club:)
|
|
@club = club
|
|
end
|
|
|
|
def call
|
|
customer_id = @club.subscription&.stripe_customer_id
|
|
return 0 if customer_id.blank?
|
|
|
|
count = 0
|
|
starting_after = nil
|
|
|
|
loop do
|
|
list = ::Stripe::Invoice.list(customer: customer_id, limit: 25, starting_after: starting_after)
|
|
list.data.each do |invoice|
|
|
next unless invoice.status == "paid"
|
|
|
|
RecordPayment.call(stripe_invoice: invoice, club: @club)
|
|
count += 1
|
|
end
|
|
break unless list.has_more
|
|
|
|
starting_after = list.data.last.id
|
|
end
|
|
|
|
count
|
|
end
|
|
end
|
|
end
|
|
end
|