roamtech/gateway-api
Composer 安装命令:
composer require roamtech/gateway-api
包简介
Roamtech Gateway API implementation
README 文档
README
Installation
Pull in the package through Composer to get the latest stable version.
$ composer require roamtech/gateway-api
Native Addon
When using vanilla PHP, modify your composer.json file to include:
"scripts": { "post-update-cmd": [ "Roamtech\\Gateway\\Support\\Bootstrap::run" ] },
This script will copy the default configuration file to a config folder in the root directory of your project. Now proceed to require the package.
Laravel
When using Laravel 5.5+, the package will automatically register. For laravel 5.4 and below,
include the service provider and its alias within your config/app.php.
'providers' => [ Roamtech\Gateay\Laravel\ServiceProvider::class, ],
Publish the package specific config using:
php artisan vendor:publish --provider 'Roamtech\Gateay\Laravel\ServiceProvider'
Configuration
Vanilla PHP
For Vanilla PHP you will need to initialize the sdk bootstrapper to get started.
use GuzzleHttp\Client; use Roamtech\Gateway\Engine\Core; use Roamtech\Gateway\Native\NativeCache; use Roamtech\Gateway\Native\NativeConfig; use Roamtech\Gateway\Client as GatewayClient; require "vendor/autoload.php"; $config = new NativeConfig(__DIR__.'/config/roamtechapi.php'); // Configure the HTTP client $client = new Client(['base_uri' => $config->get('roamtechapi.api_endpoint')]); $core = new Core($client, $config, new NativeCache($config)); $gateway = new GatewayClient($core);
Laravel
Laravel configuration is straight forward. After installation the API client is registered in the service container as:
$gateway = resolve('roamtech.client'); // Or Type hint it in method definitions use Roamtech\Gateway\Client as GatewayClient; class Mycontroller extends Controller { /** * @var GatewayClient */ private $apiClient; /** * Inject client in constructor * * @param GatewayClient $apiClient */ public function __construct(GatewayClient $apiClient) { $this->apiClient = $apiClient; } }
SMS
Send Bulk SMS
Send SMS in bulk mode, this endpoints allows you to send multiple messages in a single API call.
$messages = [ ['recipient' => '25472xxxxxxx', 'message' => 'This is a test message'], ['recipient' => '25471xxxxxxx', 'message' => 'This is a a custom message'] ]; // Using the gateway instance we can now invoke the API with our payload $response = $gateway->sms()->sendBulkMessages($messages, ['from' => 'YourSenderId']); var_dump($response);
Send single SMS
This API allows you to send a single message to one or multiple recipients.
$recipients = ['25472xxxxxxx', '25471xxxxxxx']; $message = 'A test message to say hello'; $options = [ 'from' => 'YourSenderId' 'messageId' => '345623', 'callback' => 'http://yoursite.com/sms/callback/345623', ]; // Let us send our message $response = $gateway->sms()->sendMessage($message, $recipients, $options); var_dump($response);
Get Delivery reports
To get delivery reports for messages use this snipet
$messageId = '448768fjkhgcs4cykxuy8747r9c489'; $response = $gateway->sms()->getDeliveryReport($messageId); var_dump($response);
Airtime
You can also credit airtime to your customers instantly. This Api is asynchronous when you initiate a request our API will respond back to you with the transaction and a pending status. We will then send a callback to your application with the final status.
$recipients = [ [ 'phoneNumber' => '25472xxxxxxx', 'amount' => 10 ], [ 'phoneNumber' => '25471xxxxxxx', 'amount' => 10 ] ]; $callback = 'http://mysite.com/callback?id=50'; // initiate the airtime purchase transaction $response = $gateway->airtime() ->setRecipients($recipients) ->setCallback($callback) ->purchase(); var_dump($response);
roamtech/gateway-api 适用场景与选型建议
roamtech/gateway-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 957 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sms」 「gateway」 「laravel」 「roamtech」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 roamtech/gateway-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 roamtech/gateway-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 roamtech/gateway-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
A PSR-7 compatible library for making CRUD API endpoints
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
yii2-sms expand
统计信息
- 总下载量: 957
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-13