简体   繁体   English

Laravel如何从其他应用程序获得响应?

[英]Laravel how to get response from other application?

I had to send a URL to another application for payment processing to a payment API inside a form. 我必须将URL发送到另一个应用程序,以对表单中的付款API进行付款处理。 So when users of their website click on the link it will redirect them to my site. 因此,当其网站的用户单击链接时,它将把他们重定向到我的网站。 But the problem is when it redirects them to my site, they see that route is not found error though I have that route in my web.php. 但是问题是,当我将其重定向到我的网站时,尽管我的web.php中有该路由,但他们看到未找到该路由的错误。 How do H solve this issue? H如何解决这个问题?

Suppose I have sent the following value through the form to other website: 假设我已通过表单将以下值发送到其他网站:

<input type="hidden" name="cancel_url" value="{{asset('shop-cancel/'.$tran_id)}}" />

And this is the route of my webiste: 这是我的网站的路线:

Route::get('shop-cancel/{itemid}','BillingsController@shopCancel');

instead of 代替

asset('shop-cancel/'.$tran_id)

use 采用

url('shop-cancel', [$tran_id])

This gives fully qualified route. 这给出了完全合格的路线。 Detail documentation can be found here https://laravel.com/docs/5.2/helpers#method-url 详细文档可以在这里找到https://laravel.com/docs/5.2/helpers#method-url

Give a name to your route, make it post type and make argument optional: 为您的路线命名,将其设置为发布类型,并将参数设为可选:

Route::get('shop-cancel/{itemid?}','BillingsController@shopCancel')->name('route.name');

Exclude this route from your VerifyCsrfToken Middleware: 从VerifyCsrfToken中间件中排除此路由:

protected $except = [
 route('route.name'),
]; 

Then use the route helper: 然后使用路由助手:

route('route.name',['itemid' => $item_id]);

asset is use for images,css,js links. 资源用于图片,css,js链接。 You have to use url function to redirect to your cancel url 您必须使用url函数重定向到您的取消url

Try This
<input type="hidden" name="cancel_url" value="{{url('shop-cancel/'.$tran_id)}}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM