mirovit/borica-api
Composer 安装命令:
composer require mirovit/borica-api
包简介
Package that enables the communication with BORICA via their API
README 文档
README
This is a simple implementation of the BORICA API for adding payments with their service.
Instalation
Pull from Composer:
composer require mirovit/borica-api
How to use
One way would be to new up a version of Mirovit\Borica\Factory, which accepts Mirovit\Borica\Request and Mirovit\Borica\Response as constructor arguments. Or just use the the Request and Response classes individually.
The Request as its name suggests is responsible for generating the URLs for request to the Borica API - possible requests are: register transaction, check status of transaction, register delayed transaction request, complete a delayed transaction request, reverse delayed transaction request and reverse a partially or the full sum from a registered transaction.
<?php require __DIR__ . '/vendor/autoload.php'; $factory = new Factory( new Request('<terminal id from BORICA>', '<private key signed from BORICA>', '<private key password (optional)>', '<language (optional - BG or EN)>', '<debug (optional, whether you're testing or accepting payments)>'), new Response('<public certificate from BORICA>') );
Registering of a transaction
$factory->request() ->amount('1') // 1 EUR ->orderID(1) // Unique identifier in your system ->description('testing the process') // Short description of the purchase (up to 125 chars) ->currency('EUR') // The currency of the payment ->register(); // Type of the request
Check status of a transaction
$factory->request() ->amount('1') // 1 EUR ->orderID(1) // Unique identifier in your system ->description('testing the process') // Short description of the purchase (up to 125 chars) ->currency('EUR') // The currency of the payment ->status(); // Type of the request
Reverse a transaction
$factory->request() ->amount('1') // 1 EUR - partial reversal (amount less than the original), full reversal the original amount ->orderID(1) // Unique identifier in your system ->reverse(); // Type of the request
Using with Laravel 5
Create a service provider as the one below and register it with the app.
You can either add it to the config/app.php or register it in Providers/AppServiceProvider.php.
<?php
namespace App\Providers;
use Mirovit\Borica\Factory;
use Mirovit\Borica\Request;
use Mirovit\Borica\Response;
use Illuminate\Support\ServiceProvider;
class BoricaServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind(Request::class, function(){
return new Request(env('BORICA_TERMINAL_ID'), 'path/to/private.key', '', app()->getLocale());
});
$this->app->bind(Response::class, function(){
return new Response('path/to/public.cer');
});
$this->app->bind(Factory::class, function(){
return new Factory(app(Request::class), app(Response::class));
}, true);
}
}
Contributing
If you'd like to contribute, feel free to send a pull request!
mirovit/borica-api 适用场景与选型建议
mirovit/borica-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.84k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2016 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mirovit/borica-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mirovit/borica-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-30