承接 e-ghl/omnipay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

e-ghl/omnipay

Composer 安装命令:

composer require e-ghl/omnipay

包简介

Omnipay payment processing library for eGHL payment Gateway

README 文档

README

Package for omnipay to Integrate with eGHL.

Installation

  1. This package can be installed/ required via Composer with the following command

    composer require e-ghl/omnipay

  2. Clone the eGHL_hashing package from private repo using the following command. (Gain access to the private repo by contacting at support.eghl@ghl.com)

git clone https://bitbucket.org/eghl/eghl_hashing.git vendor/e-ghl/merchant-api/src/eghl_hashing

How OmniPay framework fits in any e-commerce payment plugin system?

To understand this, first we need to identify steps required to build a payment plugin for an e-commerce system.

The table below shows all the salient steps involved in devloping the e-commerce payment plugin. Some of these steps are completely e-commerce framework dependent and rest of the steps are handled by omnipay framework. The table below also elaborates that which steps are e-commerce framework dependent and which are handled by omnipay framework.

#Descriptionis e-commerce Framework Dependentis OmniPay Framework Dependent
1Build Payment plugin configuration storage mechanism i.e. MerchantID and MerchantPass etcYes-
2Get and prepare checkout order information required by eGHL for a transactionYes-
3Determine Callback (server to server) and Return (Server to browser) URLYes-
4Validate order information required by eGHL to process a payment transaction-Yes
5Prepare auto submit HTML form containing payment request info along with valid HashValue to be submitted to eGHL payment URL-Yes
6Validate eGHL payment response using Hash Value matching in callback / return URL-Yes
7Determine Transaction status i.e. success, failed or pending-Yes
8Update the order status, create invoice, notify customer depending on transaction statusYes-

Usage

The Developer only require three easy steps of code to integrate with eGHL payment method if the omnipay is already installed.

#StepsRemarks
1Send payment request to eGHLThe autosubmit html form will be generated that will send payment request to eGHL
2Handle callback responseThis is server to server response from eGHL to merchant website. This is URL on merchant website which is specified in MerchantCallBackURL parameter of the payment request. This parameter is not mandatory however it is recommende to be included. This piece of code is responsible to update the order status.
3Handle return responseThis is server to client response from eGHL to merchant website. This URL is on merchant website which is specified in MerchantReturnURL parameter of the payment request. This parameter is mandatory and it is mainly reponsibe to update the order status if it is not already updated by the callback URL and also redirect the shopper to appropriate landing page i.e. successful payment page or failed payment page

Send payment request to eGHL

define('BASE_URL','http://localhost/omni-eghl/demo/');
use Omnipay\Omnipay;

$gateway = Omnipay::create('eGHL');

$gateway->setMerchantId('SIT');
$gateway->setMerchantPassword('sit12345');
$gateway->setTestMode(); // Add tis line only to enable test mode payment

$data = array(
			//'TransactionType' => 'AUTH', // Set TransactionType = AUTH in order to authorize the CC transaction
			'PymtMethod' => 'ANY',
			'OrderNumber' => 'OMNI001',
			//'PaymentID' => 'OMNI001', // if not defined, its generated automatically
			'PaymentDesc' => 'ominpay test',
			'MerchantReturnURL' => BASE_URL.'return.php',
			'MerchantCallBackURL' => BASE_URL.'callback.php',
			'Amount' => '10.00',
			'CurrencyCode' => 'MYR',
			'CustName' => 'Jawad Humayun',
			'CustEmail' => 'jawad.humayun@ghl.com',
			'CustPhone' => '01156301987',
			'PageTimeout' => 700
		);

$PurchaseResponse = $gateway->purchase($data)->send();
	
if ($PurchaseResponse->isRedirect()) {
	$PurchaseResponse->redirect(); // redirect to offsite payment gateway
}

Handle callback response

use Omnipay\Omnipay;

$gateway = Omnipay::create('eGHL');

$gateway->setMerchantId('SIT');
$gateway->setMerchantPassword('sit12345');
$Response = $gateway->completePurchase($_REQUEST)->send();

if($Response->isSuccessful()){
	// Payment successful logic
}
elseif($Response->isCancelled()){
	// Payment canceled by buyer
}
elseif($Response->isPending()){
	// Payment pending logic
}
else{
	// Payment failed logic
}
die('OK'); //acknowlegment sent back to eGHL

Handle return response

use Omnipay\Omnipay;

$gateway = Omnipay::create('eGHL');

$gateway->setMerchantId('SIT');
$gateway->setMerchantPassword('sit12345');
$Response = $gateway->completePurchase($_REQUEST)->send();

if($Response->isSuccessful()){
// Payment successful logic
// Redirect to Success page
}
elseif($Response->isCancelled()){
// Payment canceled by buyer
// Redirect to failed page
}
elseif($Response->isPending()){
// Payment pending logic
// Redirect to pending page
}
else{
// Payment failed logic
// Redirect to failed page
}

Other Features

eGHL Omnipay integration also supports following features which are very useful and common in any payment processing.

  1. Refund (To Refund a Credit Card Transaction)
  2. Void / Reversal (To reverse / void a Credit Card Transaction)
  3. Capture (To capture the authorised Credit Card Transaction)

The example code of each of the above mentioned features is explained below.

Refund

The refund method of Omnipay\eGHL\Gateway object sends online refund request for a credit card transaction to eGHL gateway.

Returns eGHL\MerchantAPI\Refund object if the refund request is successful or pending. Throws exception if transaction is already refunded or failed due to any reason.

Only credit card transactions are refundable online, therefore Direct debit or online banking transactions will not be refunded.

// Require Autoloader
require_once "../vendor/autoload.php";

// Invoke Omnipay namespace
use Omnipay\Omnipay;

$gateway = Omnipay::create('eGHL');

$gateway->setMerchantId('SIT');
$gateway->setMerchantPassword('sit12345');
$gateway->setTestMode(); // Add tis line only to enable test mode payment

$data = array(
            'PymtMethod' => 'CC',
            'PaymentID' => '130#1547432197655ef9',
            'Amount' => '1005.00',
            'CurrencyCode' => 'MYR'
        );

try{
    $RespData = $gateway->refund($data)->getResponse();
    echo "<pre>".print_r($RespData, 1)."</pre>";
}
catch(\Exception $e){
    echo "Caught Exception: ".$e->getMessage();
}

Void / Reverse

The void method of Omnipay\eGHL\Gateway object sends online reversal request for a credit card transaction to eGHL gateway.

Returns eGHL\MerchantAPI\Reversal object if the void request is successful or pending. Throws exception if transaction is already reversed or failed due to any reason.

Only credit card transactions are reversed online, therefore Direct debit or online banking transactions will not be reversed.

// Require Autoloader
require_once "../vendor/autoload.php";

// Invoke Omnipay namespace
use Omnipay\Omnipay;

$gateway = Omnipay::create('eGHL');

$gateway->setMerchantId('SIT');
$gateway->setMerchantPassword('sit12345');
$gateway->setTestMode(); // Add tis line only to enable test mode payment

$data = array(
            'PymtMethod' => 'CC',
            'PaymentID' => 'IPGJAW20190111600016',
            'Amount' => '1.00',
            'CurrencyCode' => 'MYR'
        );

try{
    $RespData = $gateway->void($data)->getResponse();
    echo "<pre>".print_r($RespData, 1)."</pre>";
}
catch(\Exception $e){
    echo "Caught Exception: ".$e->getMessage();
}

Capture

The capture method of Omnipay\eGHL\Gateway object sends online capture request for a credit card transaction to eGHL gateway.

Returns eGHL\MerchantAPI\Capture object if the void request is successful or pending. Throws exception if transaction is already capture, not authorized or failed due to any reason.

Only credit card transactions are capture online, therefore Direct debit or online banking transactions will not be captured.

// Require Autoloader
require_once "../vendor/autoload.php";

// Invoke Omnipay namespace
use Omnipay\Omnipay;

$gateway = Omnipay::create('eGHL');

$gateway->setMerchantId('SIT');
$gateway->setMerchantPassword('sit12345');
$gateway->setTestMode(); // Add tis line only to enable test mode payment

$data = array(
            'PymtMethod' => 'CC',
            'PaymentID' => '130#1547432197655ef9',
            'Amount' => '1005.00',
            'CurrencyCode' => 'MYR'
        );

try{
    $RespData = $gateway->refund($data)->getResponse();
    echo "<pre>".print_r($RespData, 1)."</pre>";
}
catch(\Exception $e){
    echo "Caught Exception: ".$e->getMessage();
}

e-ghl/omnipay 适用场景与选型建议

e-ghl/omnipay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 135 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 11 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payment」 「gateway」 「merchant」 「omnipay」 「eghl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 e-ghl/omnipay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 e-ghl/omnipay 我们能提供哪些服务?
定制开发 / 二次开发

基于 e-ghl/omnipay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 135
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-29