dployhub/enett

Enett API支付集成库

dev-master 2017-05-05 05:42 UTC

This package is not auto-updated.

Last update: 2024-09-15 02:43:03 UTC


README

一个简单的Laravel 5 Enett支付网关库。

安装步骤

  1. 在您的终端中使用以下命令安装此库。(当前库处于开发模式)

    composer require dploy/enett dev-master

  2. 更新config/app.php中的服务提供者

     'providers' => [
         // ...
         Dploy\Enett\EnettServiceProvider::class,
     ]
    
  3. 更新config/app.php中的别名

     'aliases' => [
         // ...
         'Enett' => Dploy\Enett\Facade\Enett::class,
     ]
    
  4. 仅在你的项目根目录的composer.json中添加以下行

      "autoload": {
             "psr-4": {
     	        ......
     	        ......
                 "Dploy\\Enett\\": "src/"
             }
         },
    
  5. 在您的终端中使用composer命令

     composer dump-autoload
    
  6. 要使用自己的设置,请发布配置。

     $ php artisan vendor:publish
    

这将添加config/enett.php文件

注意:请确保您的系统已安装curl。

示例

请参考以下示例

	// add name space in your controller
	use Enett
	use Dploy\Enett\Models\ProcessDebitRequest;

	// In controller action, add the following code

	// Create request object, this is going to hold all your parameters
	$req = new ProcessDebitRequest([
		'transID' => '1234567',
		'primaryRef' => '987654',
		'secondaryRef' => '',
		'passengerName' => 'John Citizen',
		'departureDate' => '2017-10-01',
		'notes' => 'Testing notes',
		'ECN' => '500318',
		'amount' => 10.00,
		'currency' => 'AUD',
		'paymentDate' => date('Y-m-d'),
		'agentID' => '500221',
		'payer' => '500221',
	]);

	// Now we are ready to make our call, this is going to make your direct payment in eNett gateway
	$result = Enet::processDebitRequest($req);

	// Here you can check the returned response
	var_dump($result);

结果

如果所有参数都正确,API将返回遵循eNett规范的XML结构。

如果出现错误或缺少参数,将使用类抛出错误

  • EnettException

例如

	throw new EnettException($request);

Enett服务器到服务器支付API注意事项

注意:如果您想执行服务器到服务器的初始支付请求(因为它需要您收集卡数据),则必须完全符合PCI规范。如果您不完全符合PCI规范,可以使用Enett.js安全地收集支付数据。

方法

  • processDebitRequest

配置文件路径

	/src/Config/enett.php

使用的环境变量

	ENETT_ENVIRONMENT = test|live
	ENETT_INTEGRATOR = replace with your integrator ID
	ENETT_KEY = replace with your eNett key
	ENETT_VERSION=1.0
	ENETT_SOURCE = replace with your website URL