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

@@ -65,6 +65,19 @@ class User < ApplicationRecord
end
def can_receive_payouts?
has_stripe_account? && promoter?
stripe_connected_account_id.present? && stripe_connect_verified?
end
private
def stripe_connect_verified?
return false unless stripe_connected_account_id.present?
begin
account = Stripe::Account.retrieve(stripe_connected_account_id)
account.charges_enabled
rescue Stripe::StripeError => e
Rails.logger.error "Failed to verify Stripe account #{stripe_connected_account_id}: #{e.message}"
false
end
end
end