feat: Add manual payout system for countries without Stripe Global Payouts

This commit is contained in:
kbe
2025-09-17 08:35:20 +02:00
parent 3c1e17c2af
commit c74140c431
12 changed files with 375 additions and 28 deletions

View File

@@ -6,6 +6,39 @@ class PayoutService
def process!
return unless @payout.can_process?
# Check if user is in France or doesn't have a Stripe account (manual processing)
if should_process_manually?
process_manually!
else
process_with_stripe!
end
end
private
def should_process_manually?
# For now, we'll assume manual processing for all users
# In a real implementation, this could check the user's country
!@payout.user.has_stripe_account?
end
def process_manually!
@payout.update!(status: :processing)
begin
# For manual processing, we just mark it as completed
# In a real implementation, this would trigger notifications to admin
@payout.mark_as_manually_processed!
Rails.logger.info "Manual payout processed for payout #{@payout.id} for event #{@payout.event.name}"
rescue => e
@payout.update!(status: :failed)
Rails.logger.error "Manual payout failed for payout #{@payout.id}: #{e.message}"
raise e
end
end
def process_with_stripe!
@payout.update!(status: :processing)
begin
@@ -31,8 +64,6 @@ class PayoutService
end
end
private
def update_earnings_status
@payout.event.earnings.where(status: 0).update_all(status: 1) # pending to paid
end