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,6 +3,16 @@ class Order < ApplicationRecord
DRAFT_EXPIRY_TIME = 15.minutes
MAX_PAYMENT_ATTEMPTS = 3
# === Enums ===
enum :status, {
draft: 0,
pending_payment: 1,
paid: 2,
completed: 3,
cancelled: 4,
expired: 5
}, default: :draft
# === Associations ===
belongs_to :user
belongs_to :event
@@ -23,8 +33,9 @@ class Order < ApplicationRecord
attr_accessor :stripe_invoice_id
# === Scopes ===
scope :draft, -> { where(status: "draft") }
scope :active, -> { where(status: %w[paid completed]) }
scope :draft, -> { where(status: :draft) }
scope :active, -> { where(status: [ :paid, :completed ]) }
scope :paid, -> { where(status: :paid) }
scope :expired_drafts, -> { draft.where("expires_at < ?", Time.current) }
scope :can_retry_payment, -> {
draft.where("payment_attempts < ? AND expires_at > ?",