Fix PCI Stripe e anteprima regia; checkout sempre hosted.
Blocca l'invio di numeri carta dall'API server, usa Checkout anche per i cambi piano e nasconde correttamente il placeholder video in regia. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
41
backend/app/services/billing/stripe/customer_sync.rb
Normal file
41
backend/app/services/billing/stripe/customer_sync.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
module Billing
|
||||
module Stripe
|
||||
# Sincronizza solo dati di fatturazione (mai dati carta) sul Customer Stripe.
|
||||
class CustomerSync
|
||||
def self.call(club:, customer_id:)
|
||||
new(club: club, customer_id: customer_id).call
|
||||
end
|
||||
|
||||
def initialize(club:, customer_id:)
|
||||
@club = club
|
||||
@customer_id = customer_id
|
||||
end
|
||||
|
||||
def call
|
||||
return @customer_id if @customer_id.blank?
|
||||
|
||||
::Stripe::Customer.update(@customer_id, customer_attributes)
|
||||
@customer_id
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def customer_attributes
|
||||
attrs = {
|
||||
name: @club.billing_legal_name.presence || @club.name,
|
||||
email: @club.billing_email.presence,
|
||||
metadata: { club_id: @club.id },
|
||||
address: {
|
||||
line1: @club.billing_address_line,
|
||||
city: @club.billing_city,
|
||||
state: @club.billing_province,
|
||||
postal_code: @club.billing_postal_code,
|
||||
country: @club.billing_country.presence || "IT"
|
||||
}
|
||||
}
|
||||
attrs[:address] = nil if attrs[:address].values.all?(&:blank?)
|
||||
attrs.compact
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user