dongzhan1878 2015-08-26 08:01
浏览 49

在Laravel 4.2中实现第三方类

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>
  • 写回答

3条回答 默认 最新

  • doutouman6245 2015-08-26 08:14
    关注

    Create e24PaymentPipe in your App root directory
    Open composer.json

     "classmap": [
         "database",
         "app/e24PaymentPipe" <-- add this line to classmap
      ],
    

    run composer dump-autoload; in your controller

    public function __construct(){
        $e24payment = new \e24PaymentPipe;  
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用