code
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\CardOrder\Filament\Actions;
|
||||
|
||||
use App\Modules\CardOrder\Models\CardOrder;
|
||||
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class PayCardOrderAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('card_order_pay')
|
||||
->label(__('Pay'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation()
|
||||
->action(function (CardOrder $record) {
|
||||
$onlinePayment = CardOrderRepository::make()
|
||||
->createOnlinePaymentOrder($record);
|
||||
|
||||
if ($onlinePayment->successful()) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sending')
|
||||
->send();
|
||||
|
||||
return redirect()->away($onlinePayment->paymentLink());
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Could not send')
|
||||
->send();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user