I am trying to integrate a middle east based payment gateway for payments via debit card in a Laravel project for first time. I have used this payment gateway in custom PHP projects in past but facing issues integrating it in a Laravel project.
Basically this payment gateway files consist of a class called e24PaymentPipe and a resource/resource.cgn. The brief structure of these two files is as follows:
e24PaymentPipe
Full class source code: 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/resource.cgn
This file contains some strings:
13d6 acd1 35e2 f54d 2dab 7d9d 63bc 9bb2
6f8f 1fd9 2fc2 aa41 4a8e 873e 98a6 2304
Implementation
In the page where the Payment button will be displayed, the following code needs to be added:
// 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 FORM (that displays button which will take user to Payment Gateways page to complete debit card payments, upon completion user will be redirected back to site)
<!-- 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>
I am new to Laravel, this is one of my first projects. Please help, Thanks.
EDIT
By the way, here is GitHub repo for this e24PaymentPipe class, you can view full code of this class and its implementation here:
https://github.com/TigerWolf/e24PaymentPipe-php
Hope this could help.
@Angel M. here's what I'm doing:
Controller Function
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>