alfallouji/php_optimal_netbanx
Composer 安装命令:
composer require alfallouji/php_optimal_netbanx
包简介
An OOP PHP Client for the Card payments Optimal Netbanx Restful service
README 文档
README
PHP-Optimal-Netbanx
This is an OOP PHP Client for the Card payments Optimal Netbanx Restful service.
Authors & contact
Al-Fallouji Bashar - bashar@alfallouji.com
Documentation and download
Latest version is available on github at : - http://github.com/alfallouji/PHP-Optimal-Netbanx
License
This Code is released under the GNU LGPL
Please do not change the header of the file(s).
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
How to setup
You can use composer to use this library.
{
"require": {
"alfallouji/php_optimal_netbanx": "*"
}
}
You can use composer to generate autoload map files.
composer dumpautoload
How to start
This PHP client works with the Netbanx service (card payments).
You will need an account with Optimal Payment in order to use this library.
You can create testing account here : https://developer.optimalpayments.com/en/
Configuration
In order for you to use the NETBANX REST API, NETBANX must first set you up on their system and provide you with an API key. Your API key looks something like this:
- Key ID – MerchantXYZ
- Key Password – B-tst1-0-51ed39e4-312d02345d3f123120881dff9bb4020a89e8ac44cdfdcecd702151182fdc952272661d290ab2e5849e31bb03deede7
- Account ID - 12345678
They are available from : https://developer.optimalpayments.com/en/my-account/
Please note that on the Optimal My Account page, the API key contains the Key ID and the Key Password. It has the following the format :
API_KEY_ID:API_KEY_PASSWORD
Sample
For an example, you can look at the tests/Functional folder.
/**
* Helper function for test
*
* @param boolean $v Value to assert
*
* @return void
*/
function assertTest($v)
{
if ($v)
{
echo "\t[OK]" . PHP_EOL;
}
else
{
echo "\t[FAILED]" . PHP_EOL;
exit(-1);
}
}
$auth = new \Optimal\Netbanx\Model\Authorization();
$auth->merchantRefNum = 'refNum_' . uniqid();
$auth->amount = 10000 + rand(200, 3000);
$auth->settleWithAuth = false;
$card = new \Optimal\Netbanx\Model\Card();
$card->cardNum = '4530910000012345';
$card->type = 'VI';
$card->lastDigits = '2345';
$expiry = new \Optimal\Netbanx\Model\CardExpiry();
$expiry->month = 11;
$expiry->year = 2019;
$card->cardExpiry = $expiry;
$auth->card = $card;
$billingDetails = new \Optimal\Netbanx\Model\BillingDetails();
$billingDetails->street = '511 rue abelard';
$billingDetails->zip = 'H3E 1B6';
$billingDetails->city = 'Verdun';
$billingDetails->country = 'CA';
$auth->billingDetails = $billingDetails;
$httpClient = new \Optimal\Netbanx\Client\Http($config['apiKey'], $config['apiPassword'], $config['accountId'], 'staging');
$service = new \Optimal\Netbanx\Service\Authorization($httpClient);
// Test 1 - create auth
echo PHP_EOL . 'Testing Authorization creation for ' . $auth->amount;
$result = $service->create($auth);
$id = isset($result['result']['id']) ? $result['result']['id'] : null;
assertTest($id);
// Test 2 - get auth
echo PHP_EOL . 'Testing Authorization get for ' . $id;
$result = $service->get($id);
$getId = isset($result['result']['id']) ? $result['result']['id'] : null;
assertTest($getId && $getId == $id);
// Test 3 - partial reverse of auth
$authReversal = new \Optimal\Netbanx\Model\AuthorizationReversal();
$authReversal->id = $getId;
$authReversal->amount = rand(500, 1000);
$authReversal->merchantRefNum = 'Reverse_for_' . $auth->merchantRefNum;
echo PHP_EOL . 'Testing Authorization reverse for an amount of ' . $authReversal->amount;
$result = $service->reverse($getId, $authReversal);
assertTest(isset($result['result']['status']) && $result['result']['status'] == 'COMPLETED');
// Test 4 - settle authorization
echo PHP_EOL . 'Testing Authorization settlement';
$result = $service->settle($id, array('merchantRefNum' => $auth->merchantRefNum));
assertTest($result['code'] == 200 && isset($result['result']['id']));```
alfallouji/php_optimal_netbanx 适用场景与选型建议
alfallouji/php_optimal_netbanx 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.65k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 alfallouji/php_optimal_netbanx 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alfallouji/php_optimal_netbanx 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-2.1
- 更新时间: 2015-02-27