我试图将SagePay Inframe Server集成到使用Laravel作为框架的我的站点中。我已经购买了SSL证书,除Sagepay的通知回复外,一切都完美无瑕。我联系了他们的客户支持,并通过电子邮件发送了一个旧版的开发工具包,用于2.23版本(显然,他们没有为他们的最新协议,从中得到什么),而且大部分代码都是从原始(过时的)代码库进行修改的。Sagepay InFrame服务器laravel路由问题
在过去的三周里,我一直试图在一个控制器(OrdersController)内创建一组函数来处理SagePays的各种POST发送/响应,希望我可以为Laravel创建一个公共库,否则需要经历试图将这个恶梦系统整合在一起的地狱。
目前我的系统正确地注册了交易,从中将notificationURL发送给Sagepay,我在我的数据库中存储了Sagepay所需的VendorTxCode(创建)/ VPSTxId和SecurityKey(sagepay created)字段,我的用户是在iframe中重定向以输入他们的卡片详情。
根据文档,用户输入他们的详细信息并进行交易后,脚本应检查Status/VendorTxCode/VPSTxId,并使用这些值从数据库中提取SecurityKey。如果SecurityKey不存在,则用户将被重定向到(使用RedirectURL)我指定的页面来处理错误。
我会在这里停下来,因为目前我没有从数据库中绘制SecurityKey,因此它不存在,这就是确切的问题 - SagePay应该从这一点将用户重定向到/ failure页面,但它并没有,而是抛出这个普通的错误:
错误代码:5006
错误描述:无法重定向到供应商的网站。供应商未能提供重定向URL。
现在这里的奇怪之处在于,如果我将相同的脚本(Laravel /控制器框架之外)上载到例如'http://www.thisisanothersite/test/notification.php',并更改NotificationURL以反映此情况,则iframe会重定向到所需的RedirectURL 。如果我在浏览器中加载脚本显示以下(正确)响应:
Status = INVALID RedirectURL = https://development.myproject.co.uk/sagepay/failure StatusDetail =无法在我们的数据库中找到事务。
但是如果我试图从Laravel的背景下查看脚本(因此,例如“https://development.myproject.co.uk/sagepay/notification”),脚本与您希望看到一个Laravel错误通常照亮异常处理程序响应。
我的问题是:有没有办法做任何操作:
1)有没有一种方法来关闭与laravel单个功能相关的错误处理,所以我回来了完全相同的消息,因为我在Laravel环境之外获得了吗?
2)在Laravel的上下文中创建一个独立的脚本,因此我可以使用数据库连接,但是可以将它作为独立页面(sagepay/notification.php)进行访问,而不需要控制器路由妨碍?
代码中,我目前已经制定了上述如下:
<?php
class OrdersController extends BaseController {
protected $layout = 'layouts.admin';
public function __construct(Order $order)
{
$this->order = $order;
}
public function notification() {
header("Content-type: text/plain");
$eoln = chr(13) . chr(10);
$strConnectTo = "TEST";
$strStatus=$this->cleanInput($_REQUEST["Status"],"Text");
$strVendorTxCode=$this->cleanInput($_REQUEST["VendorTxCode"],"VendorTxCode");
$strVPSTxId=$this->cleanInput($_REQUEST["VPSTxId"],"Text");
$strSecurityKey="";
$VendorTxCode = $strVendorTxCode;
$VPSTxId = $strVPSTxId;
$strSQL = Order::select('SecurityKey')->where('VendorTxCode', $VendorTxCode)->where('VPSTxId', $VPSTxId)->first();
if (strlen($strSQL->SecurityKey)==0)
{
ob_flush();
header("Content-type: text/html");
echo "Status=INVALID" . $eoln;
if ($strConnectTo=="LIVE") {
echo "RedirectURL=https://development.myproject.co.uk/sagepay/failure" . $eoln;
}
else {
echo "RedirectURL=https://development.myproject.co.uk/sagepay/failure" . $eoln;
}
echo "StatusDetail=Unable to find the transaction in our database." . $eoln;
exit();
}
else
{
// CODE TO DEAL WITH SUCCESS
}
}
}
这些路由:
Route::any('sagepay/notification', '[email protected]');
Route::any('sagepay/failure', '[email protected]');
Route::resource('orders', 'OrdersController');
道歉这个问题的大小,但我真的难倒这里:/
不是你的问题的答案,但看看https://github.com/omnipay/sagepay。它使得Sagepay稍微落后一点。 – beech