Laravel 如何转跳到指定页面并携带数据
目前在使用一个基于Laravel开源的外卖点餐系统(Tastyigniter),需要制定一个REDSYS(我这边西班牙的银行刷卡接口)的接口。
因为Tastyigniter自带了Paypal的付款接口,跟我需要的REDSYS差不多,基本就是复制过来直接用了。
最后结账转跳的时候,paypal是直接使用Redirect::to进行转跳,但是REDSYS必须要按照POST进行提交,所以无法直接使用Redirect
try {
//创建接口
$gateway = $this->createGateway($host);
//发送请求
$response = $gateway->purchase($fields)->send();
//转跳到支付页面
if ($response->isRedirect())
return Redirect::to($response->getRedirectUrl());
//LOG记录
$order->logPaymentAttempt('Payment error -> '.$response->getMessage(), 0, $fields, $response->getData());
throw new ApplicationException($response->getMessage());
}
现在的做法是,创建一个路由和Controller,先转跳到创建的路由,输出input type=hidden表单和自动提交按钮转跳到支付页面。
但是转跳是需要传送$response,里面是需要提交的数据。
试过用Redirect::route(“redsys”)->with(“data”,$response)和Session::put()都无法正常传递给Controller
之前在Tastyigniter社区提问过,但是可能由于问题太过简单然后没有解答
由于没有laravel开发经验,一直无法实现,请大家帮忙解答一下!
感谢
推荐文章: