我正在尝试在Laravel项目中首次将基于中东的支付网关用于通过借记卡进行支付。我过去在自定义PHP项目中使用过此支付网关,但面临将其集成到Laravel项目中的问题。
这个支付网关文件基本上由一个名为 e24PaymentPipe 的类和一个 resource / resource.cgn 组成。这两个文件的简要结构如下:
e24PaymentPipe
完整的源代码:here!
class e24PaymentPipe {
var $SUCCESS = 0;
var $FAILURE = -1;
var $BUFFER = 2320;
var $strIDOpen = "<id>";
var $strPasswordOpen = "<password>";
..... some more vars ......
function e24PaymentPipe() {
$this->webAddress = "";
$this->port = "443";
$this->id = "";
$this->password = "";
... some more vars
}
function getWebAddress() {
return webAddress;
}
function setWebAddress($s) {
$this->webAddress = $s;
}
... sme more functions ...
}
资源/ resource.cgn
此文件包含一些字符串:
13d6 acd1 35e2 f54d 2dab 7d9d 63bc 9bb2
6f8f 1fd9 2fc2 aa41 4a8e 873e 98a6 2304
实施
在显示付款按钮的页面中,需要添加以下代码:
// BENEFIT PAYMENT Code
require('e24PaymentPipe.inc.php');
date_default_timezone_set('Asia/Bahrain');
$accATM = new e24PaymentPipe;
$accATM->resourcePath = 'resource/';
$accATM->alias = 'SECRET_ALIAS_OF_MERCHANT';
$accATM->action = '1';
$accATM->currency = '048';
$accATM->language = 'USA';
$accATM->amt = 'PRICE_HERE';
$accATM->responseURL = '/response.php';
$accATM->errorURL = '/error_page.php';
$accATM->trackId = date('YmdHis');
$TransVal = $accATM->performPaymentInitialization();
$varRawResponse = $accATM->getRawResponse();
$varPaymentId = $accATM->getPaymentId();
$varPaymentPage = $accATM->getPaymentPage();
$varErrorMsg = $accATM->getErrorMsg();
HTML表格(显示将用户带到付款网关页面以完成借记卡付款的按钮,完成后用户将被重定向回网站)
<!-- Benefit Debit Card Payment Button -->
<form action="<?php echo $varPaymentPage; ?>" method="get" class="pull-left" style="margin-left:20px;">
<input id="PaymentID" name="PaymentID" type="hidden" value="<?php echo $varPaymentId; ?>" />
<input type="submit" class="btn btn-warning btn-lg" value="Debit Card Payment" />
</form>
我是Laravel的新手,这是我的第一个项目之一。请帮忙,谢谢。
修改
顺便说一句,这是 e24PaymentPipe 类的GitHub repo,你可以在这里查看这个类的完整代码及其实现:
https://github.com/TigerWolf/e24PaymentPipe-php
希望这可以提供帮助。
@Angel M.这是我正在做的事情:
控制器功能
public function payment() {
$accATM = new \e24PaymentPipe;
return View::make('site.payment', compact('accATM'));
}
payment.blade.php
<?php
$accATM->resourcePath = app_path().'/views/site/resource';
$accATM->alias = 'SECRET_ALIAS_HERE';
$accATM->action = '1';
$accATM->currency = '048';
$accATM->language = 'USA';
$accATM->amt = $participant->price;
$accATM->responseURL = '/response.php';
$accATM->errorURL = '/error_page.php';
$accATM->trackId = date('YmdHis');
$accATM->udf2 = 'ud2465665';
$accATM->udf3 = 'ud3231213';
$accATM->udf4 = 'ud4785653';
$accATM->udf5 = 'ud5554788';
$TransVal = $accATM->performPaymentInitialization();
$varRawResponse = $accATM->getRawResponse();
$varPaymentId = $accATM->getPaymentId();
$varPaymentPage = $accATM->getPaymentPage();
$varErrorMsg = $accATM->getErrorMsg();
?>
!-- Benefit Debit Card Payment -->
<form action="<?php echo $varPaymentPage; ?>" method="get" class="pull-left" style="margin-left:20px;">
<input id="PaymentID" name="PaymentID" type="hidden" value="<?php echo $varPaymentId; ?>" />
<input type="submit" class="btn btn-warning btn-lg" value="Debit Card Payment" />
</form>
答案 0 :(得分:0)
在App根目录中创建e24PaymentPipe
打开composer.json
"classmap": [
"database",
"app/e24PaymentPipe" <-- add this line to classmap
],
运行composer dump-autoload; 在你的控制器
public function __construct(){
$e24payment = new \e24PaymentPipe;
}