feat: replace Stripe Global Payouts with manual bank transfer system for France compliance

- 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>
This commit is contained in:
kbe
2025-09-17 11:55:07 +02:00
parent 3c1e17c2af
commit 1889ee7fb2
20 changed files with 838 additions and 141 deletions

View File

@@ -1,32 +1,77 @@
class Admin::PayoutsController < ApplicationController
before_action :authenticate_user!
before_action :ensure_admin!
before_action :set_payout, only: [:show, :approve, :reject, :mark_processing, :mark_completed, :mark_failed]
def index
@payouts = Payout.pending.includes(:user, :event).order(created_at: :asc).page(params[:page])
@pending_payouts = Payout.pending.includes(:user, :event).order(created_at: :asc)
@approved_payouts = Payout.approved.includes(:user, :event).order(created_at: :asc)
@processing_payouts = Payout.processing.includes(:user, :event).order(created_at: :asc)
@completed_payouts = Payout.completed.includes(:user, :event).order(created_at: :desc).limit(10)
end
def show
@payout = Payout.find(params[:id])
@service = PayoutService.new(@payout)
@transfer_summary = @service.generate_transfer_summary
@banking_errors = @service.validate_banking_info
end
def process
@payout = Payout.find(params[:id])
if @payout.pending? && @payout.can_process?
begin
PayoutService.new(@payout).process!
redirect_to admin_payouts_path, notice: "Payout processed successfully."
rescue => e
redirect_to admin_payouts_path, alert: "Failed to process payout: #{e.message}"
end
def approve
if @payout.approve!(current_user)
redirect_to admin_payout_path(@payout), notice: "Payout approved successfully."
else
redirect_to admin_payouts_path, alert: "Cannot process this payout."
redirect_to admin_payout_path(@payout), alert: "Cannot approve this payout."
end
end
def reject
reason = params[:rejection_reason].presence || "No reason provided"
if @payout.reject!(current_user, reason)
redirect_to admin_payouts_path, notice: "Payout rejected."
else
redirect_to admin_payout_path(@payout), alert: "Cannot reject this payout."
end
end
def mark_processing
transfer_reference = params[:bank_transfer_reference]
if @payout.mark_processing!(current_user, transfer_reference)
redirect_to admin_payout_path(@payout), notice: "Payout marked as processing."
else
redirect_to admin_payout_path(@payout), alert: "Cannot mark payout as processing."
end
end
def mark_completed
transfer_reference = params[:bank_transfer_reference]
if @payout.mark_completed!(current_user, transfer_reference)
redirect_to admin_payouts_path, notice: "Payout completed successfully."
else
redirect_to admin_payout_path(@payout), alert: "Cannot mark payout as completed."
end
end
def mark_failed
reason = params[:failure_reason].presence || "Transfer failed"
if @payout.mark_failed!(current_user, reason)
redirect_to admin_payouts_path, notice: "Payout marked as failed."
else
redirect_to admin_payout_path(@payout), alert: "Cannot mark payout as failed."
end
end
# Legacy method - redirect to new workflow
def process
@payout = Payout.find(params[:id])
redirect_to admin_payout_path(@payout), alert: "Use the new manual payout workflow."
end
private
def set_payout
@payout = Payout.find(params[:id])
end
def ensure_admin!
# For now, we'll just check if the user has a stripe account
# In a real app, you'd have an admin role check