Billing Stripe, link regia mobile e staff solo trasmissione.
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>
This commit is contained in:
36
backend/app/services/billing/stripe/sync_payments.rb
Normal file
36
backend/app/services/billing/stripe/sync_payments.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
Reference in New Issue
Block a user