Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rider's avatar
Level 1

Redirection in Laravel

Iam working in a project using Laravel and Angular 7, and trying to make the payment using stripe

https://example.domain.com/admin - will goes to angular 7

we are trying the payment URL like - https://payment.domain.com configured in route look like

$domain = parse_url(request()->root())['host']; 
if($domain=='payments.domain.com'){
   Route::get('/', function () {
 return 'welcome'; });

Route::get('payment/{id}', 'paymentController@paymentHome');
Route::post('paymentStripe', 'paymentController@make_payment');
Route::get('paymentFails', 'paymentController@paymentFails');

} else {
    remaining routes declared here
} 

if i hit http://payment.domain.com/admin it's directly going to angular(instead of https)

/admin is configured in http://example.domain.com/admin, i don't have any idea why it's directs through payment URL, can anyone please help us to solve this issue.

0 likes
12 replies
s.spaan's avatar

You could also wrap them in a group:

Route::domain('payments.example.com')->group(function () {
    Route::get('/', function () { return 'welcome'; });
    Route::get('payment/{id}', 'paymentController@paymentHome');
    Route::post('paymentStripe', 'paymentController@make_payment');
    Route::get('paymentFails', 'paymentController@paymentFails');
});

Route::domain('www.example.com')->group(function () {
    // remaining routes declared here
});

maybe this will fix the issues?

1 like
khorram's avatar

you can use crud restful api such as resource controllers

Route::resource('/payment', 'PaymentController');

you need to run this command before you write this code:

php artisan make:controller PaymentController -r

hopes this helps

1 like
rider's avatar
Level 1

Hi Spaan can you please change the domain name as shown in my post , your idea has worked, thanks for your reply.

rider's avatar
Level 1

Hi khorram thanks for the reply..

rider's avatar
Level 1

Hi Spaan can you please change the domain name as shown in my post , your idea has worked, thanks for your reply.

s.spaan's avatar

Sorry, i didn't receive any notification of the replies. But i have changed it.

rider's avatar
Level 1

Thank you Mr.Spaan.. and sorry to ask again, please change the second route group look like below, once again thanks for your reply.

Route::domain('www.domain.com')->group(function () {

rider's avatar
Level 1

Thanks for your help Mr.Spaan

rider's avatar
Level 1

Iam trying to make CURL request to get customer from stripe not using any library, iam receiving empty result, can anyone please help me to solve this one, curl looks like

    $url ="https://api.stripe.com/v1/customers?limit=3 \
    -u sk_test_3iIP8u46agjTQ2vPau9oAji5: \
    -G";


    $ch = curl_init(); //open connection
   curl_setopt($ch, CURLOPT_URL, $url);
   $result_count = curl_exec($ch); //execute post
   echo"<pre>";
   print_r($result_count);
   exit;
s.spaan's avatar

It's better to make a different topic for another question.

But anyway:

 $url ="https://api.stripe.com/v1/customers?limit=3";


$ch = curl_init(); //open connection
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer sk_test_xxxxxxx',
]);

$result_count = curl_exec($ch); //execute post

echo"<pre>";
print_r($result_count);
exit;

And it's better to not show the api token in the questions on the forum, even if it's the test token.

rider's avatar
Level 1

works fine now iam trying to change the "past due" invoice to "void" stage and struggling with that, code looks like, invoice is in past due while checked with stripe account

$url ="https://api.stripe.com/v1/invoices/
    in_1EuGWXXXXXXXXXXXXXX/void \
    -u sk_test_XXXXXXXXXXXXXX \
    -X";

    // $url ="https://api.stripe.com/v1/customers?limit=3";

    $ch = curl_init(); //open connection
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Authorization: Bearer sk_test_XXXXXXXXXXXXXXXXXXX',
    ]);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 180);
    $result_count = curl_exec($ch); //execute post

    echo"<pre>";
    print_r($result_count);
    exit;

Please or to participate in this conversation.