Modernize dependencies: replace abandoned packages, update versions

- Replace flowframe/laravel-trend with direct Eloquent DB queries
- Replace srmklive/paypal (abandoned) with new PayPalService using PayPal REST API v2 via Guzzle
- Remove old config/paypal.php, migrate to config('habbo.paypal.*')
- Update blade templates to use habbo.paypal config
- Bump npm packages to latest: @inertiajs/react, axios, esbuild, eslint, sass, tailwindcss, etc.
- Run composer update and yarn upgrade
This commit is contained in:
root
2026-06-20 15:01:48 +02:00
parent 7c72ed82b6
commit 53f88b840a
12 changed files with 1171 additions and 1206 deletions
+29 -33
View File
@@ -4,11 +4,10 @@ namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Http\Requests\AccountTopupFormRequest;
use App\Services\PayPalService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Srmklive\PayPal\Services\PayPal;
use Srmklive\PayPal\Services\PayPal as PayPalClient;
use Symfony\Component\HttpFoundation\Response;
class PayPalController extends Controller
@@ -17,17 +16,11 @@ class PayPalController extends Controller
private const string STATUS_COMPLETED = 'COMPLETED';
private ?PayPalClient $provider = null;
private PayPalService $paypal;
private function getProvider(): PayPalClient
public function __construct(PayPalService $paypal)
{
if (! $this->provider instanceof PayPal) {
$this->provider = new PayPalClient;
$this->provider->setApiCredentials(config('habbo.paypal'));
$this->provider->getAccessToken();
}
return $this->provider;
$this->paypal = $paypal;
}
public function process(AccountTopupFormRequest $request): Response|RedirectResponse
@@ -44,7 +37,7 @@ class PayPalController extends Controller
'user_action' => 'CONTINUE',
],
'purchase_units' => [
0 => [
[
'amount' => [
'currency_code' => config('habbo.paypal.currency'),
'value' => (string) $amount,
@@ -53,14 +46,13 @@ class PayPalController extends Controller
],
];
$response = $this->getProvider()->createOrder($orderData);
$response = $this->paypal->createOrder($orderData);
if (isset($response['id']) === false) {
if ($response === null || ! isset($response['id'])) {
$message = $response['message'] ?? __('Something went wrong');
Log::error('Error creating order', ['response' => $response]);
return to_route('shop.index')->withErrors(
['message' => $response['message'] ?? __('Something went wrong')],
);
return to_route('shop.index')->withErrors(['message' => $message]);
}
foreach ($response['links'] as $links) {
@@ -76,7 +68,7 @@ class PayPalController extends Controller
}
return to_route('shop.index')->withErrors(
['message' => $response['message'] ?? __('Something went wrong')],
['message' => __('Something went wrong')],
);
}
@@ -97,26 +89,30 @@ class PayPalController extends Controller
return to_route('shop.index')->withErrors(['message' => __('Transaction already processed')]);
}
$response = $this->getProvider()->capturePaymentOrder($request['token']);
$paymentDetails = $response['purchase_units'][0]['payments']['captures'][0] ?? null;
$response = $this->paypal->capturePaymentOrder($request['token']);
if ($response === null) {
Log::error('PayPal capture returned null');
return to_route('shop.index')->withErrors(['message' => __('Something went wrong, please try again later')]);
}
if (isset($response['status'], $response['purchase_units'][0]['payments']['captures'][0]) === false) {
if (isset($response['error']['details'][0])) {
$details = $response['error']['details'][0];
$transaction->update([
'status' => $response['name'] ?? 'ERROR',
'description' => sprintf('%s - %s', $details['issue'] ?? '', $details['description'] ?? ''),
'amount' => 0,
]);
}
if (! isset($response['status'], $paymentDetails)) {
Log::error('Invalid response from PayPal', ['response' => $response]);
return to_route('shop.index')->withErrors(['message' => __('Something went wrong, please try again later')]);
}
if (($response['status'] ?? null) === null) {
$details = $response['error']['details'][0];
$transaction->update([
'status' => $response['name'],
'description' => sprintf('%s - %s', $details['issue'], $details['description']),
'amount' => 0,
]);
return to_route('shop.index')->withErrors(['message' => __('Something went wrong, please check your paypal account to make sure nothing was deducted and try again')]);
}
$paymentDetails = $response['purchase_units'][0]['payments']['captures'][0];
$capturedAmount = (float) $paymentDetails['amount']['value'];
$expectedAmount = (float) ($transaction->expected_amount ?? 0);
@@ -144,7 +140,7 @@ class PayPalController extends Controller
if ($response['status'] !== self::STATUS_COMPLETED) {
return to_route('shop.index')->withErrors(
['message' => $response['message'] ?? __('Something went wrong')],
['message' => __('Something went wrong')],
);
}