Return url of localhost in laravel using transbank

I am totally new to laravel, I have been creating a project to pay with transbank, everything is fine, but when I return my url I can’t find my localhost path.

Laravel’s artisan server starts withphp artisan serve --host=my-ip-address --port:8000 I really don’t know what happens.

Do I occupy windows, do I have to install any configuration? or while this environment should be done on a server like Xampp and do some configuration? I am super lost, my return url in laravel I leave it like this in the browser.

http://my-ip-address:8000/initPay

So it starts, it goes to the transbank page and everything is fine, but when returning the url that I specify in the method it does not work.

my code laravel

web routes

Route::get('/initPay', '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f6a19394a6978fa69a838585b599988284999a9a9384b69f989f82a6978fa19394">[email protected]</a>');
Route::post('/confirm_pay', '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c6b595e6c5d456c50494f4f7f5352484e535050594e7c5f53525a554e516c5d45">[email protected]</a>');

Controller
<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use TransbankWebpayWebpayPlus;
use TransbankWebpayWebpayPlusTransaction;

class WebPayPlussController extends Controller
{

    public function __construct(){
        WebpayPlus::configureForIntegration('597055555532', '579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C');
    }

    public function initPayWeb(Request $request){

        $buy_order ='abc456';
        $session_id='4784568';
        $amount=10000;
        $response = (new Transaction)->create(
            $buy_order, 
            $session_id, 
            $amount,
            'http://my-ip-address:8000/confirm_pay');

        $url =$response->getUrl().'?token_ws='.$response->getToken();
        return redirect()->away($url);
        
    }

    public function confirmPay(Request $request){
       
        $confirm=  (new Transaction)->commit($request->get('token_ws'));

        if($confirmacion->isApproved()){
            return 'is Approved';
        }else{
            return 'is not Approved';
        }
       

      
    }

    
}

Please, if someone can guide me more on the subject or how to make it return to the localhost url, I would really appreciate it, I searched and I am still lost..

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Route /confirm_pay will definitely not work with a private IP address… which isn’t route-able.

You would need to deploy that script to a server with a publicly available IP address.

ngrok might be a possible workaround, but a rather cumbersome one.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x