forked from laravelcm/laravel.cm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:laravelcm/laravel.cm into develop
- Loading branch information
Showing
16 changed files
with
212 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\Transaction; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class SponsoringPaymentInitialize | ||
{ | ||
use SerializesModels; | ||
|
||
public function __construct(public Transaction $transaction) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Listeners; | ||
|
||
use App\Events\SponsoringPaymentInitialize; | ||
use App\Notifications\NewSponsorPaymentNotification; | ||
use Illuminate\Notifications\AnonymousNotifiable; | ||
|
||
final readonly class SendPaymentNotification | ||
{ | ||
public function __construct(private AnonymousNotifiable $notifiable) | ||
{ | ||
} | ||
|
||
public function handle(SponsoringPaymentInitialize $event): void | ||
{ | ||
$this->notifiable->notify(new NewSponsorPaymentNotification($event->transaction)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Models\Transaction; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Notification; | ||
use NotificationChannels\Telegram\TelegramChannel; | ||
use NotificationChannels\Telegram\TelegramMessage; | ||
|
||
class NewSponsorPaymentNotification extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
public function __construct(public readonly Transaction $transaction) | ||
{ | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function via(mixed $notifiable): array | ||
{ | ||
if ( | ||
! empty(config('services.telegram-bot-api.token')) && | ||
! empty(config('services.telegram-bot-api.channel')) | ||
) { | ||
return [TelegramChannel::class]; | ||
} | ||
|
||
return []; | ||
} | ||
|
||
public function toTelegram(): TelegramMessage | ||
{ | ||
return TelegramMessage::create() | ||
->to(config('services.telegram-bot-api.channel')) | ||
->content($this->content()) | ||
->button('Voir les sponsors', route('sponsors')); | ||
} | ||
|
||
private function content(): string | ||
{ | ||
$content = "*Nouveau paiement de Sponsoring enregistré!*\n\n"; | ||
$content .= 'Auteur: '.$this->transaction->getMetadata('merchant')['name']."\n"; | ||
$content .= 'Montant: '. $this->transaction->amount; | ||
|
||
if ($this->transaction->getMetadata('merchant')['laravel_cm_id']) { | ||
$content .= 'Profil Laravel Cameroun: [@'.$this->transaction->user?->username.']('.route('profile', $this->transaction->user?->username).')'; | ||
} | ||
|
||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"/js/app.js": "/js/app.js?id=0953d0b23f555fd811dda52086298222", | ||
"/css/app.css": "/css/app.css?id=8d5c4c1a62a59a2ffc28ea3c57562b38" | ||
"/css/app.css": "/css/app.css?id=9209b1a63d8215ae6346440a2aa9477f" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.