Fix 500 on attendees and badges pages by adding SmsService.
Deploy Ladill Events / deploy (push) Successful in 53s
Deploy Ladill Events / deploy (push) Successful in 53s
The AttendeeController depends on SMS for programme sharing; the class was referenced but never shipped in this app. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Billing;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SmsService
|
||||
{
|
||||
public function send(string $to, string $message): void
|
||||
{
|
||||
$apiKey = config('services.termii.api_key', '');
|
||||
$senderId = config('services.termii.sender_id', config('app.name', 'LaDill'));
|
||||
|
||||
if ($apiKey === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$phone = preg_replace('/\D+/', '', $to);
|
||||
if (strlen($phone) < 9) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($phone) === 9) {
|
||||
$phone = '233'.$phone;
|
||||
} elseif (str_starts_with($phone, '0')) {
|
||||
$phone = '233'.substr($phone, 1);
|
||||
}
|
||||
|
||||
try {
|
||||
Http::timeout(10)->post('https://v3.api.termii.com/api/sms/send', [
|
||||
'api_key' => $apiKey,
|
||||
'to' => $phone,
|
||||
'from' => $senderId,
|
||||
'sms' => $message,
|
||||
'type' => 'plain',
|
||||
'channel' => 'dnd',
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('SMS send failed', ['to' => $phone, 'error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,11 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
'termii' => [
|
||||
'api_key' => env('TERMII_API_KEY'),
|
||||
'sender_id' => env('TERMII_SENDER_ID', 'LaDill'),
|
||||
],
|
||||
|
||||
// Paystack — guest checkout (and the card fallback for logged-in buyers).
|
||||
'paystack' => [
|
||||
'base_url' => env('PAYSTACK_BASE_URL', 'https://api.paystack.co'),
|
||||
|
||||
Reference in New Issue
Block a user