Skip to content

Instantly share code, notes, and snippets.

@akalongman
Created January 19, 2024 11:06
Show Gist options
  • Save akalongman/9884aa5ac4fe36921fa727ffc7330383 to your computer and use it in GitHub Desktop.
Save akalongman/9884aa5ac4fe36921fa727ffc7330383 to your computer and use it in GitHub Desktop.
private function generateRedirectUrl(Order $order): ?string
{
if (! $order->isPaymentTypeBank()) {
return null;
}
$requestUri = [
'lang_code' => config('project.payments.merchant.lang_code'),
'merch_id' => config('project.payments.merchant.merch_id'),
'o.order_id' => $order->getId(),
];
$locale = app()->getLocale();
if ($order->isClientPlatformMobile()) {
$requestUri['back_url_s'] = $this->replaceLocaleMarker(
(string) config('project.payments.redirect.mobile.success'),
$locale,
);
$requestUri['back_url_f'] = $this->replaceLocaleMarker(
(string) config('project.payments.redirect.mobile.fail'),
$locale,
);
} else {
$requestUri['back_url_s'] = $this->replaceLocaleMarker(
(string) config('project.payments.redirect.web.success'),
$locale,
);
$requestUri['back_url_f'] = $this->replaceLocaleMarker(
(string) config('project.payments.redirect.web.fail'),
$locale,
);
}
$redirectUrl = config('project.payments.merchant.url') . '?' . http_build_query($requestUri);
return $redirectUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment