- Replace Stripe automatic payouts with manual admin-processed bank transfers - Add banking information fields (IBAN, bank name, account holder) to User model - Implement manual payout workflow: pending → approved → processing → completed - Add comprehensive admin interface for payout review and processing - Update Payout model with manual processing fields and workflow methods - Add transfer reference tracking and rejection/failure handling - Consolidate all migration fragments into clean "create" migrations - Add comprehensive documentation for manual payout workflow - Fix Event payout_status enum definition and database column issues This addresses France's lack of Stripe Global Payouts support by implementing a complete manual bank transfer workflow while maintaining audit trails and proper admin controls. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
class PayoutService
|
|
def initialize(payout)
|
|
@payout = payout
|
|
end
|
|
|
|
# Legacy method for backward compatibility - now redirects to manual workflow
|
|
def process!
|
|
Rails.logger.warn "PayoutService#process! called - manual processing required for payout #{@payout.id}"
|
|
raise "Automatic payout processing is disabled. Use manual workflow in admin interface."
|
|
end
|
|
|
|
# Generate payout summary for manual transfer
|
|
def generate_transfer_summary
|
|
return nil unless @payout.approved? || @payout.processing?
|
|
|
|
{
|
|
payout_id: @payout.id,
|
|
recipient: @payout.user.name,
|
|
account_holder: @payout.user.account_holder_name,
|
|
bank_name: @payout.user.bank_name,
|
|
iban: @payout.user.iban,
|
|
amount_euros: @payout.net_amount_euros,
|
|
description: "Payout for event: #{@payout.event.name}",
|
|
event_name: @payout.event.name,
|
|
event_date: @payout.event.date,
|
|
total_orders: @payout.total_orders_count,
|
|
refunded_orders: @payout.refunded_orders_count
|
|
}
|
|
end
|
|
|
|
# Validate banking information before processing
|
|
def validate_banking_info
|
|
errors = []
|
|
user = @payout.user
|
|
|
|
errors << "Missing IBAN" unless user.iban.present?
|
|
errors << "Missing bank name" unless user.bank_name.present?
|
|
errors << "Missing account holder name" unless user.account_holder_name.present?
|
|
errors << "Invalid IBAN format" if user.iban.present? && !valid_iban?(user.iban)
|
|
|
|
errors
|
|
end
|
|
|
|
private
|
|
|
|
def valid_iban?(iban)
|
|
# Basic IBAN validation (simplified)
|
|
iban.match?(/\A[A-Z]{2}[0-9]{2}[A-Z0-9]{4}[0-9]{7}([A-Z0-9]?){0,16}\z/)
|
|
end
|
|
|
|
def update_earnings_status
|
|
@payout.event.earnings.where(status: 0).update_all(status: 1) # pending to paid
|
|
end
|
|
end
|