Skip to content

Commit e1fc7e4

Browse files
committed
Merge remote-tracking branch 'origin/main' into ultra
2 parents 7d8910e + 5f70fec commit e1fc7e4

File tree

18 files changed

+780
-22
lines changed

18 files changed

+780
-22
lines changed

.github/funding.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
github: nativephp
12
open_collective: nativephp

.github/workflows/linting.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
3838
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
3939

40+
- name: Configure Flux Pro auth
41+
run: composer config http-basic.composer.fluxui.dev "${{ secrets.FLUX_EMAIL }}" "${{ secrets.FLUX_LICENSE_KEY }}"
42+
4043
- name: Install Dependencies
4144
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
4245

.github/workflows/tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
4848
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
4949

50+
- name: Configure Flux Pro auth
51+
run: composer config http-basic.composer.fluxui.dev "${{ secrets.FLUX_EMAIL }}" "${{ secrets.FLUX_LICENSE_KEY }}"
52+
5053
- name: Install Dependencies
5154
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
5255

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
88
## Foundational Context
99
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1010

11-
- php - 8.4.18
12-
- filament/filament (FILAMENT) - v3
11+
- php - 8.4.19
12+
- filament/filament (FILAMENT) - v5
1313
- laravel/cashier (CASHIER) - v15
1414
- laravel/framework (LARAVEL) - v12
1515
- laravel/horizon (HORIZON) - v5
@@ -18,7 +18,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
1818
- laravel/prompts (PROMPTS) - v0
1919
- laravel/sanctum (SANCTUM) - v4
2020
- laravel/socialite (SOCIALITE) - v5
21-
- livewire/livewire (LIVEWIRE) - v3
21+
- livewire/livewire (LIVEWIRE) - v4
2222
- laravel/mcp (MCP) - v0
2323
- laravel/pint (PINT) - v1
2424
- laravel/sail (SAIL) - v1

app/Http/Controllers/DeveloperOnboardingController.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
use App\Models\DeveloperAccount;
66
use App\Services\StripeConnectService;
7+
use App\Support\StripeConnectCountries;
78
use Illuminate\Http\RedirectResponse;
89
use Illuminate\Http\Request;
10+
use Illuminate\Validation\Rule;
911
use Illuminate\View\View;
1012

1113
class DeveloperOnboardingController extends Controller
@@ -32,16 +34,33 @@ public function start(Request $request): RedirectResponse
3234
{
3335
$request->validate([
3436
'accepted_plugin_terms' => ['required', 'accepted'],
37+
'country' => ['required', 'string', 'size:2', Rule::in(StripeConnectCountries::supportedCountryCodes())],
38+
'payout_currency' => ['required', 'string', 'size:3'],
3539
], [
3640
'accepted_plugin_terms.required' => 'You must accept the Plugin Developer Terms and Conditions.',
3741
'accepted_plugin_terms.accepted' => 'You must accept the Plugin Developer Terms and Conditions.',
42+
'country.required' => 'Please select your country.',
43+
'country.in' => 'The selected country is not supported for Stripe Connect.',
44+
'payout_currency.required' => 'Please select a payout currency.',
3845
]);
3946

47+
$country = strtoupper($request->input('country'));
48+
$payoutCurrency = strtoupper($request->input('payout_currency'));
49+
50+
if (! StripeConnectCountries::isValidCurrencyForCountry($country, $payoutCurrency)) {
51+
return back()->withErrors(['payout_currency' => 'The selected currency is not available for your country.']);
52+
}
53+
4054
$user = $request->user();
4155
$developerAccount = $user->developerAccount;
4256

4357
if (! $developerAccount) {
44-
$developerAccount = $this->stripeConnectService->createConnectAccount($user);
58+
$developerAccount = $this->stripeConnectService->createConnectAccount($user, $country, $payoutCurrency);
59+
} else {
60+
$developerAccount->update([
61+
'country' => $country,
62+
'payout_currency' => $payoutCurrency,
63+
]);
4564
}
4665

4766
if (! $developerAccount->hasAcceptedCurrentTerms()) {

app/Livewire/Customer/Developer/Onboarding.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Livewire\Customer\Developer;
44

5+
use App\Support\StripeConnectCountries;
56
use Livewire\Attributes\Computed;
67
use Livewire\Attributes\Layout;
78
use Livewire\Attributes\Title;
@@ -11,13 +12,31 @@
1112
#[Title('Developer Onboarding')]
1213
class Onboarding extends Component
1314
{
15+
public string $country = '';
16+
17+
public string $payoutCurrency = '';
18+
1419
public function mount(): void
1520
{
1621
$developerAccount = auth()->user()->developerAccount;
1722

1823
if ($developerAccount && $developerAccount->hasCompletedOnboarding()) {
1924
$this->redirect(route('customer.developer.dashboard'), navigate: true);
2025
}
26+
27+
if ($developerAccount) {
28+
$this->country = $developerAccount->country ?? '';
29+
$this->payoutCurrency = $developerAccount->payout_currency ?? '';
30+
}
31+
}
32+
33+
public function updatedCountry(string $value): void
34+
{
35+
if (StripeConnectCountries::isSupported($value)) {
36+
$this->payoutCurrency = StripeConnectCountries::defaultCurrency($value);
37+
} else {
38+
$this->payoutCurrency = '';
39+
}
2140
}
2241

2342
#[Computed]
@@ -32,6 +51,39 @@ public function hasExistingAccount(): bool
3251
return $this->developerAccount !== null;
3352
}
3453

54+
/**
55+
* @return array<string, array{name: string, flag: string, default_currency: string, currencies: list<string>}>
56+
*/
57+
#[Computed]
58+
public function countries(): array
59+
{
60+
$countries = StripeConnectCountries::all();
61+
62+
uasort($countries, fn (array $a, array $b) => $a['name'] <=> $b['name']);
63+
64+
return $countries;
65+
}
66+
67+
/**
68+
* @return array<string, string>
69+
*/
70+
#[Computed]
71+
public function availableCurrencies(): array
72+
{
73+
if (! $this->country || ! StripeConnectCountries::isSupported($this->country)) {
74+
return [];
75+
}
76+
77+
$currencies = StripeConnectCountries::availableCurrencies($this->country);
78+
79+
$named = [];
80+
foreach ($currencies as $code) {
81+
$named[$code] = StripeConnectCountries::currencyName($code);
82+
}
83+
84+
return $named;
85+
}
86+
3587
public function render()
3688
{
3789
return view('livewire.customer.developer.onboarding');

app/Services/StripeConnectService.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
*/
2020
class StripeConnectService
2121
{
22-
public function createConnectAccount(User $user): DeveloperAccount
22+
public function createConnectAccount(User $user, string $country, string $payoutCurrency): DeveloperAccount
2323
{
2424
$account = Cashier::stripe()->accounts->create([
2525
'type' => 'express',
26+
'country' => $country,
2627
'email' => $user->email,
2728
'metadata' => [
2829
'user_id' => $user->id,
2930
],
3031
'capabilities' => [
32+
'card_payments' => ['requested' => true],
3133
'transfers' => ['requested' => true],
3234
],
3335
]);
@@ -38,6 +40,8 @@ public function createConnectAccount(User $user): DeveloperAccount
3840
'stripe_connect_status' => StripeConnectStatus::Pending,
3941
'payouts_enabled' => false,
4042
'charges_enabled' => false,
43+
'country' => $country,
44+
'payout_currency' => $payoutCurrency,
4145
]);
4246
}
4347

@@ -109,7 +113,7 @@ public function processTransfer(PluginPayout $payout): bool
109113
try {
110114
$transferParams = [
111115
'amount' => $payout->developer_amount,
112-
'currency' => 'usd',
116+
'currency' => strtolower($developerAccount->payout_currency ?? 'usd'),
113117
'destination' => $developerAccount->stripe_connect_account_id,
114118
'metadata' => [
115119
'payout_id' => $payout->id,

0 commit comments

Comments
 (0)