feat: Add manual payout system for countries without Stripe Global Payouts

This commit is contained in:
kbe
2025-09-17 08:35:20 +02:00
parent 3c1e17c2af
commit c74140c431
12 changed files with 375 additions and 28 deletions

View File

@@ -69,4 +69,40 @@ class PayoutServiceTest < ActiveSupport::TestCase
assert_equal :paid, earning1.reload.status
assert_equal :paid, earning2.reload.status
end
test "process! handles manual processing when user has no stripe account" do
# Create a user without a stripe account
user_without_stripe = User.create!(
email: "test@example.com",
password: "password123",
is_professionnal: true
)
event = Event.create!(
user: user_without_stripe,
name: "Test Event",
slug: "test-event",
description: "Test event description",
venue_name: "Test Venue",
venue_address: "Test Address",
latitude: 48.8566,
longitude: 2.3522,
start_time: 1.day.ago,
end_time: 1.hour.ago,
state: :published
)
payout = Payout.create!(user: user_without_stripe, event: event, amount_cents: 9000, fee_cents: 1000, status: :pending)
# Mock that Stripe is not available for this user
user_without_stripe.stubs(:has_stripe_account?).returns(false)
service = PayoutService.new(payout)
service.process!
payout.reload
assert_equal :completed, payout.status
assert payout.manual_payout?
assert_match /MANUAL_/, payout.stripe_payout_id
end
end