jvandemo/ogone
Composer 安装命令:
composer require jvandemo/ogone
包简介
README 文档
README
This project is looking for a motivated maintainer.
If you are interested, please contact me: @jvandemo.
Meanwhile take a look at https://github.com/solidshops/PHPpayments.
Ogone classes for PHP
PHP classes for working with the Ogone payment system allow you to easily create Ogone payment forms and handle Ogone responses in an efficient and flexible way.
Requirements
The classes are only supported on PHP 5 and up.
Installation
The easiest way to install this library is by using composer.
Add the following dependency to your composer.json file:
{
"require": {
"jvandemo/ogone": "2.0.*"
}
}
How to use the classes
The first step is to create a form to initiate a payment:
use Jvandemo\Ogone\Form;
// Define form options
// See Ogone_Form for list of supported options
$options = array(
'sha1InPassPhrase' => 'your_sha1_in_password',
'formAction' => Form::OGONE_TEST_URL,
);
// Define form parameters (see Ogone documentation for list)
// Default parameter values can be set in Ogone_Form if required
$params = array(
'PSPID' => 'your_ogone_pspid',
'orderID' => 'your_order_id',
'amount' => 100,
'currency' => 'EUR',
'language' => 'en',
'CN' => 'name of your client',
'EMAIL' => 'email of your client',
'accepturl' => 'where_to_go_if_accepted.html',
'declineurl' => 'where_to_go_if_declined.html',
'exceptionurl' => 'where_to_go_if_exception_occurs.html',
'cancelurl' => 'where_to_go_if_cancelled.html',
);
// Instantiate form
$form = new Form($options, $params);
// You can also add parameters after instantiation
// with the addParam() method
$form->addParam('CN', 'Jurgen Van de Moere')
->addParam('EMAIL', 'email@email.com')
->addParam('language', 'en');
// Automatically generate HTML form with all params and SHA1Sign
echo $form->render();
The second step is to create a script that handles the response by Ogone:
use Jvandemo\Ogone\Response;
// Define response options
// See Ogone_Response for list of supported options
$options = array(
'sha1OutPassPhrase' => 'your_sha1_out_password'
);
// Define array of values returned by Ogone
// Parameters are validated and filtered automatically
// so it is safe to specify a superglobal variable
// like $_POST or $_GET if you don't want to
// specify all parameters manually
$params = $_POST;
// Instantiate response
$response = new Response($options, $params);
// Check if response by Ogone is valid
// The SHA1Sign is calculated automatically and
// verified with the SHA1Sign provided by Ogone
if(! $response->isValid()) {
// Reponse is not valid so handle accordingly
exit('The response is not valid');
}
// Use the dump() method to dump the whole response
// if you need to investigate the response when debugging
$response->dump();
// Use the getParam() method to retrieve
// parameters returned by Ogone
$creditCard = $response->getParam('CreditCard');
$amount = $response->getParam('amount');
// Handle further processing of your website
// such as saving payment details to database
// or sending confirmation email to client
// ...
This code is also available in the /examples directory.
Unit testing
The tests folder contains basic unit tests plus an additional scenario test that actually connects to the Ogone test server with your personal Ogone credentials to check if things are working correctly.
To configure the scenario test with your Ogone details, copy
config/module.config.global.php to module.config.local.php and fill in your Ogone details:
return array(
'jvandemo_ogone' => array(
'pspid' => 'your_ogone_pspid',
'sha1_in_pass_phrase' => 'your_sha1_in_password',
'sha1_out_pass_phrase' => 'your_sha1_out_password'
)
);
The .gitignore file is configured to ignore module.config.local.php so you don't have to worry
about exposing your Ogone details when creating your own public repository.
To actually run the unit test suite, run:
grunt
Change log
1.0.0
- Added Ogone_Form for generating forms to interact with Ogone
- Added Ogone_Response for handling responses from Ogone
2.0.0
- Added composer support
- Introduced namespaces
- Added unit tests
- Fixed some coding standards warnings
- Added grunt support for unit testing and linting
- Added semantic versioning
2.1.0
- Added additional unit tests
- Added scenario test
- Added config file support
jvandemo/ogone 适用场景与选型建议
jvandemo/ogone 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 163 次下载、GitHub Stars 达 9, 最近一次更新时间为 2013 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jvandemo/ogone 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jvandemo/ogone 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 163
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-09-29