Redirect User to Page Out Side Filament Panel After A Record is Created

Am working on a solution that involves making payments so after a transaction is created or a payment the gateway returns a unique url where am supposed to redirect the user to complete the payment
6 Replies
codeartisan
codeartisan6mo ago
this redirects to a page with in filament I want to redirect the user to page that handles full payment
Tieme
Tieme6mo ago
Before saying this is within Filament, have you tried this? Because Leandro hase just given you the answer.
protected function getRedirectUrl(): string
{
return "https://www.google.com/";
}
protected function getRedirectUrl(): string
{
return "https://www.google.com/";
}
codeartisan
codeartisan6mo ago
protected function mutateFormDataBeforeCreate(array $data): array
{

$reference = Str::uuid();
$customer_names = Auth::user()->name;
$customer_email = Auth::user()->email;
$customer_id = Auth::user()->id;
$callback_url = "http://localhost:8000/callback";
$cancel_url = "http://localhost:8000/cancel";

$data['user_id'] = Auth::user()->id;
$data['type'] = config("transaction_type.types.credit");
$data['payment_mode'] = "Web";
$data['reference'] = $reference;
$data['status'] = config("status.payment_status.pending");

$res = Pesapal::orderProcess($reference, $data['amount'], $data['phone_number'], $data['description'], $callback_url, $customer_names, $customer_email, $customer_id, $cancel_url);


return $data;

}
protected function mutateFormDataBeforeCreate(array $data): array
{

$reference = Str::uuid();
$customer_names = Auth::user()->name;
$customer_email = Auth::user()->email;
$customer_id = Auth::user()->id;
$callback_url = "http://localhost:8000/callback";
$cancel_url = "http://localhost:8000/cancel";

$data['user_id'] = Auth::user()->id;
$data['type'] = config("transaction_type.types.credit");
$data['payment_mode'] = "Web";
$data['reference'] = $reference;
$data['status'] = config("status.payment_status.pending");

$res = Pesapal::orderProcess($reference, $data['amount'], $data['phone_number'], $data['description'], $callback_url, $customer_names, $customer_email, $customer_id, $cancel_url);


return $data;

}
The url to redirect to is being returned by pesapal
Tieme
Tieme6mo ago
Something like this. You only need to check wat is in $this->getRecord(); and parse the correct info for your function
protected function getRedirectUrl(): string
{

$Data = $this->getRecord();

$reference = Str::uuid();
$customer_names = Auth::user()->name;
$customer_email = Auth::user()->email;
$customer_id = Auth::user()->id;
$callback_url = "http://localhost:8000/callback";
$cancel_url = "http://localhost:8000/cancel";

$data['user_id'] = Auth::user()->id;
$data['type'] = config("transaction_type.types.credit");
$data['payment_mode'] = "Web";
$data['reference'] = $reference;
$data['status'] = config("status.payment_status.pending");

$res = Pesapal::orderProcess($reference, $data['amount'], $data['phone_number'], $data['description'], $callback_url, $customer_names, $customer_email, $customer_id, $cancel_url);


return $Redirect_url;

}
protected function getRedirectUrl(): string
{

$Data = $this->getRecord();

$reference = Str::uuid();
$customer_names = Auth::user()->name;
$customer_email = Auth::user()->email;
$customer_id = Auth::user()->id;
$callback_url = "http://localhost:8000/callback";
$cancel_url = "http://localhost:8000/cancel";

$data['user_id'] = Auth::user()->id;
$data['type'] = config("transaction_type.types.credit");
$data['payment_mode'] = "Web";
$data['reference'] = $reference;
$data['status'] = config("status.payment_status.pending");

$res = Pesapal::orderProcess($reference, $data['amount'], $data['phone_number'], $data['description'], $callback_url, $customer_names, $customer_email, $customer_id, $cancel_url);


return $Redirect_url;

}
codeartisan
codeartisan6mo ago
the redirect url is in the $res variable but let me try some here