feat(payouts): implement promoter earnings viewing, request flow, and admin Stripe processing with webhooks

Add model methods for accurate net calculations (€0.50 + 1.5% fees), eligibility, refund handling
Update promoter/payouts controller for index (pending events), create (eligibility checks)
Integrate admin processing via Stripe::Transfer, webhook for status sync
Enhance views: index pending cards, events/show preview/form
Add comprehensive tests (models, controllers, service, integration); run migrations
This commit is contained in:
kbe
2025-09-17 02:07:52 +02:00
parent 47f4f50e5b
commit 3c1e17c2af
31 changed files with 1096 additions and 148 deletions

View File

@@ -3,19 +3,25 @@ class Admin::PayoutsController < ApplicationController
before_action :ensure_admin!
def index
@payouts = Payout.includes(:event, :user)
.order(created_at: :desc)
.page(params[:page])
@payouts = Payout.pending.includes(:user, :event).order(created_at: :asc).page(params[:page])
end
def create
def show
@payout = Payout.find(params[:id])
begin
@payout.process_payout!
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 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
else
redirect_to admin_payouts_path, alert: "Cannot process this payout."
end
end
@@ -28,4 +34,4 @@ class Admin::PayoutsController < ApplicationController
redirect_to dashboard_path, alert: "Access denied."
end
end
end
end