alkhatibdev/laravel-zain
Composer 安装命令:
composer require alkhatibdev/laravel-zain
包简介
Zain DSP API integration
关键字:
README 文档
README
Zain DSP API integration with Laravel
Introduction
Laravel Zain is Zain DSP API integration with Laravel, made to simplify the process and API calls and let developers focus on other integration parts and logic. See also Laravel Sudani.
Installation
Requirements
- PHP >=
7.4.x - Laravel >=
7.x
install via composer
composer require alkhatibdev/laravel-zain
Publish Configs
php artisan vendor:publish --tag=laravel-zain-config
A laravel-zain.php config file will be published on your configs directory, with the following content:
<?php return [ 'base_url' => env('ZAIN_SERVER_BASE_API_URL'), 'product_code' => env('ZAIN_PRODUCT_CODE'), 'username' => env('ZAIN_USERNAME'), 'password' => env('ZAIN_PASSWORD'), 'remember_token' => env('ZAIN_REMEMBER_TOKEN', false), 'enable_logging' => false, ];
Don't forget to set all these variable on your .env file
ZAIN_SERVER_BASE_API_URL=https://test.zaindsp.com:3030/api/v1/json/ ZAIN_PRODUCT_CODE=xxxxxx ZAIN_USERNAME=xxxxx ZAIN_PASSWORD=xxxxx ZAIN_REMEMBER_TOKEN=false
Usage
Initial Payment/Subscription
use AlkhatibDev\LaravelZain\Facades\Zain; // Initiate payment request $response = Zain::initiate($phone)
When initiate payment request successfully sent, a SMS with OTP code will be send to the $phone number, and $response will contain a subscribe_request_id and you should save it to the next step verify.
Verify Payment/Subscription
$response = Zain::verify($otp, $requestId)
Check Subscription
$response = Zain::checkSubscription($phone)
Unsubscribe
$response = Zain::unsubscribe($phone) // cacheToken($response['token'])
Login and Cache DSP token
Out of the box the package will login automatically and get the token and use it for each action initiate, verify ..etc per request.
If you want to cache the token and use it for furthor requests, you can request token like this:
$token = Zain::token()
And you can cache it and use it for each request for the next 24 hours.
If you set ZAIN_REMEMBER_TOKEN=true token will be expired after 30 days.
Example of using cached token:
// $token = getCachedToken() $response = Zain::withToken($token)->initiate($phone) $response = Zain::withToken($token)->verify($phone) ...
Logging
You can enable logging from package config file
'enable_logging' => true,
Other Packages
-
Laravel Sudani SPay API Integration
License
Laravel Zain is open-sourced software licensed under the MIT license.
alkhatibdev/laravel-zain 适用场景与选型建议
alkhatibdev/laravel-zain 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 12, 最近一次更新时间为 2022 年 07 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「integration」 「dsp」 「zain」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alkhatibdev/laravel-zain 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alkhatibdev/laravel-zain 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alkhatibdev/laravel-zain 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DreamFactory Services Platform(tm) Library Installer
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
DreamFactory Services Platform(tm) Javascript SDK
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
DreamFactory Services Platform(tm) Admin Console
Laravel integration for blade-to-react
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-13
